Browse Source

Remove use of std::reference_wrapper where possible.

What's left is *a lot* of places taking monstrous
std::vector<std::reference_wrapper> and that can't be changed to
std::vector<Containers::Reference> in a source-compatible way. Even that
would be only a temporary change, since the goal is to fully avoid
dependency on STL in those cases.

The final version of these APIs should take
Containers::ArrayView<Containers::Reference> and be implicitly
convertible froom e.g. std::vector<Containers::Reference>. That's
definitely possible, but not in time for 2019.01, so instead of forcing
users to temporary pass a `{vec.begin(), vec.size()}` everywhere instead
of just `vec`, I'm rather keeping these APIs intact.
pull/374/head
Vladimír Vondruš 7 years ago
parent
commit
a36d8eb033
  1. 9
      doc/changelog.dox
  2. 2
      doc/opengl-mapping.dox
  3. 2
      doc/snippets/MagnumAudio-scenegraph.cpp
  4. 2
      doc/snippets/MagnumGL.cpp
  5. 2
      src/Magnum/Animation/Player.h
  6. 4
      src/Magnum/Animation/Player.hpp
  7. 2
      src/Magnum/Animation/Test/PlayerTest.cpp
  8. 4
      src/Magnum/Audio/Listener.cpp
  9. 2
      src/Magnum/Audio/Listener.h
  10. 1
      src/Magnum/Audio/Test/ListenerALTest.cpp
  11. 1
      src/Magnum/DebugTools/TextureImage.cpp
  12. 7
      src/Magnum/GL/AbstractShaderProgram.cpp
  13. 9
      src/Magnum/GL/AbstractShaderProgram.h
  14. 2
      src/Magnum/GL/Implementation/MeshState.h
  15. 2
      src/Magnum/GL/Mesh.h
  16. 6
      src/Magnum/GL/MeshView.cpp
  17. 15
      src/Magnum/GL/MeshView.h
  18. 5
      src/Magnum/GL/Shader.cpp
  19. 7
      src/Magnum/GL/Shader.h
  20. 1
      src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp
  21. 1
      src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp
  22. 1
      src/Magnum/GL/Test/SampleQueryGLTest.cpp
  23. 2
      src/Magnum/GL/Test/TransformFeedbackGLTest.cpp
  24. 1
      src/Magnum/Shaders/DistanceFieldVector.cpp
  25. 1
      src/Magnum/Shaders/Flat.cpp
  26. 1
      src/Magnum/Shaders/MeshVisualizer.cpp
  27. 1
      src/Magnum/Shaders/Phong.cpp
  28. 1
      src/Magnum/Shaders/Vector.cpp
  29. 1
      src/Magnum/Shaders/VertexColor.cpp
  30. 1
      src/Magnum/TextureTools/DistanceField.cpp

9
doc/changelog.dox

@ -61,7 +61,7 @@ See also:
- @ref Animation::Player::resume() that acts the same as - @ref Animation::Player::resume() that acts the same as
@ref Animation::Player::play() "play()" except it doesn't restart the @ref Animation::Player::play() "play()" except it doesn't restart the
animation from the start if it is already playing animation from the start if it is already playing
- Added @ref Animation::Player::advance(T, std::initializer_list<std::reference_wrapper<Player<T, K>>>) - Added @ref Animation::Player::advance(T, std::initializer_list<Containers::Reference<Player<T, K>>>)
for advancing multiple players at the same time for advancing multiple players at the same time
@subsubsection changelog-latest-new-math Math library @subsubsection changelog-latest-new-math Math library
@ -211,6 +211,13 @@ See also:
@ref GL::Mesh instead of @ref std::pair of a mesh and a buffer, as the @ref GL::Mesh instead of @ref std::pair of a mesh and a buffer, as the
buffer is now owned by the mesh. This change was not possible to be done in buffer is now owned by the mesh. This change was not possible to be done in
a backwards-compatible way. a backwards-compatible way.
- @ref Animation::Player, @ref Audio::Listener, @ref GL::AbstractShaderProgram,
@ref GL::MeshView and @ref GL::Shader APIs that take a
@ref std::initializer_list of references were changed to use
@ref Corrade::Containers::Reference instead of a @ref std::reference_wrapper.
This change should be fully transparent to the user as the type conversion
is done implicitly in both cases, but you may need to add an
@cpp #include <Corrade/Containers/Reference.h> @ce where appropriate.
- Removed deprecated implicit conversion @ref Corrade::Containers::Optional - Removed deprecated implicit conversion @ref Corrade::Containers::Optional
to @cpp std::optional @ce, deprecated in January 2018. The class now to @cpp std::optional @ce, deprecated in January 2018. The class now
contains an *explicit* and opt-in STL compatibility, see its documentation contains an *explicit* and opt-in STL compatibility, see its documentation

2
doc/opengl-mapping.dox

@ -291,7 +291,7 @@ OpenGL function | Matching API
@fn_gl{MapBuffer}, \n `glMapNamedBuffer()`, \n @fn_gl_extension{MapNamedBuffer,EXT,direct_state_access}, \n @fn_gl{MapBufferRange}, \n `glMapNamedBufferRange()`, \n @fn_gl_extension{MapNamedBufferRange,EXT,direct_state_access}, \n @fn_gl{UnmapBuffer}, \n `glUnmapNamedBuffer()`, \n @fn_gl_extension{UnmapNamedBuffer,EXT,direct_state_access} | @ref GL::Buffer::map(), @ref GL::Buffer::unmap() @fn_gl{MapBuffer}, \n `glMapNamedBuffer()`, \n @fn_gl_extension{MapNamedBuffer,EXT,direct_state_access}, \n @fn_gl{MapBufferRange}, \n `glMapNamedBufferRange()`, \n @fn_gl_extension{MapNamedBufferRange,EXT,direct_state_access}, \n @fn_gl{UnmapBuffer}, \n `glUnmapNamedBuffer()`, \n @fn_gl_extension{UnmapNamedBuffer,EXT,direct_state_access} | @ref GL::Buffer::map(), @ref GL::Buffer::unmap()
@fn_gl{MemoryBarrier}, \n `glMemoryBarrierByRegion()` | @ref GL::Renderer::setMemoryBarrier(), \n @ref GL::Renderer::setMemoryBarrierByRegion() @fn_gl{MemoryBarrier}, \n `glMemoryBarrierByRegion()` | @ref GL::Renderer::setMemoryBarrier(), \n @ref GL::Renderer::setMemoryBarrierByRegion()
@fn_gl{MinSampleShading} | @ref GL::Renderer::setMinSampleShading() @fn_gl{MinSampleShading} | @ref GL::Renderer::setMinSampleShading()
@fn_gl{MultiDrawArrays}, \n @fn_gl{MultiDrawElements}, \n @fn_gl{MultiDrawElementsBaseVertex} | @ref GL::MeshView::draw(AbstractShaderProgram&, std::initializer_list<std::reference_wrapper<MeshView>>) @fn_gl{MultiDrawArrays}, \n @fn_gl{MultiDrawElements}, \n @fn_gl{MultiDrawElementsBaseVertex} | @ref GL::MeshView::draw(AbstractShaderProgram&, std::initializer_list<Containers::Reference<MeshView>>)
@fn_gl{MultiDrawArraysIndirectCount}, \n @fn_gl{MultiDrawElementsIndirectCount} | | @fn_gl{MultiDrawArraysIndirectCount}, \n @fn_gl{MultiDrawElementsIndirectCount} | |
@subsection opengl-mapping-functions-o O @subsection opengl-mapping-functions-o O

2
doc/snippets/MagnumAudio-scenegraph.cpp

@ -23,6 +23,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/Reference.h>
#include "Magnum/Audio/Buffer.h" #include "Magnum/Audio/Buffer.h"
#include "Magnum/Audio/Listener.h" #include "Magnum/Audio/Listener.h"
#include "Magnum/Audio/Playable.h" #include "Magnum/Audio/Playable.h"

2
doc/snippets/MagnumGL.cpp

@ -23,6 +23,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/Reference.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/GL/AbstractShaderProgram.h" #include "Magnum/GL/AbstractShaderProgram.h"

2
src/Magnum/Animation/Player.h

@ -263,7 +263,7 @@ template<class T, class K
* *
* Equivalent to calling @ref advance(T) for each item in @p players. * Equivalent to calling @ref advance(T) for each item in @p players.
*/ */
static void advance(T time, std::initializer_list<std::reference_wrapper<Player<T, K>>> players); static void advance(T time, std::initializer_list<Containers::Reference<Player<T, K>>> players);
/** @brief Constructor */ /** @brief Constructor */
explicit Player(); explicit Player();

4
src/Magnum/Animation/Player.hpp

@ -31,8 +31,8 @@
#include "Player.h" #include "Player.h"
#include <functional>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Reference.h>
namespace Magnum { namespace Animation { namespace Magnum { namespace Animation {
@ -71,7 +71,7 @@ template<class T, class K> struct Player<T, K>::Track {
}; };
#endif #endif
template<class T, class K> void Player<T, K>::advance(const T time, const std::initializer_list<std::reference_wrapper<Player<T, K>>> players) { template<class T, class K> void Player<T, K>::advance(const T time, const std::initializer_list<Containers::Reference<Player<T, K>>> players) {
for(Player<T, K>& p: players) p.advance(time); for(Player<T, K>& p: players) p.advance(time);
} }

2
src/Magnum/Animation/Test/PlayerTest.cpp

@ -23,8 +23,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <functional>
#include <sstream> #include <sstream>
#include <Corrade/Containers/Reference.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>

4
src/Magnum/Audio/Listener.cpp

@ -26,6 +26,8 @@
#include "Listener.h" #include "Listener.h"
#include <Corrade/Containers/Reference.h>
#include "Magnum/Audio/Playable.h" #include "Magnum/Audio/Playable.h"
#include "Magnum/Audio/PlayableGroup.h" #include "Magnum/Audio/PlayableGroup.h"
#include "Magnum/Audio/Renderer.h" #include "Magnum/Audio/Renderer.h"
@ -69,7 +71,7 @@ template<UnsignedInt dimensions> void Listener<dimensions>::clean(const MatrixTy
/** @todo velocity */ /** @todo velocity */
} }
template<UnsignedInt dimensions> void Listener<dimensions>::update(std::initializer_list<std::reference_wrapper<PlayableGroup<dimensions>>> groups) { template<UnsignedInt dimensions> void Listener<dimensions>::update(std::initializer_list<Containers::Reference<PlayableGroup<dimensions>>> groups) {
/* Check if active listener just changed to this */ /* Check if active listener just changed to this */
if(this != activeListener) { if(this != activeListener) {
/* Ensure that clean() is called also when switching between (clean) /* Ensure that clean() is called also when switching between (clean)

2
src/Magnum/Audio/Listener.h

@ -119,7 +119,7 @@ template<UnsignedInt dimensions> class Listener: public SceneGraph::AbstractFeat
* listener-related configuration for @ref Renderer (position, * listener-related configuration for @ref Renderer (position,
* orientation, gain). * orientation, gain).
*/ */
void update(std::initializer_list<std::reference_wrapper<PlayableGroup<dimensions>>> groups); void update(std::initializer_list<Containers::Reference<PlayableGroup<dimensions>>> groups);
/** @brief Listener gain */ /** @brief Listener gain */
Float gain() const { return _gain; } Float gain() const { return _gain; }

1
src/Magnum/Audio/Test/ListenerALTest.cpp

@ -24,6 +24,7 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/Reference.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include "Magnum/Audio/Context.h" #include "Magnum/Audio/Context.h"

1
src/Magnum/DebugTools/TextureImage.cpp

@ -35,6 +35,7 @@
#include "Magnum/GL/Texture.h" #include "Magnum/GL/Texture.h"
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2)
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include "Magnum/GL/AbstractShaderProgram.h" #include "Magnum/GL/AbstractShaderProgram.h"

7
src/Magnum/GL/AbstractShaderProgram.cpp

@ -26,6 +26,7 @@
#include "AbstractShaderProgram.h" #include "AbstractShaderProgram.h"
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/Reference.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"
@ -348,7 +349,7 @@ void AbstractShaderProgram::attachShader(Shader& shader) {
glAttachShader(_id, shader.id()); glAttachShader(_id, shader.id());
} }
void AbstractShaderProgram::attachShaders(std::initializer_list<std::reference_wrapper<Shader>> shaders) { void AbstractShaderProgram::attachShaders(std::initializer_list<Containers::Reference<Shader>> shaders) {
for(Shader& s: shaders) attachShader(s); for(Shader& s: shaders) attachShader(s);
} }
@ -394,7 +395,9 @@ void AbstractShaderProgram::transformFeedbackVaryingsImplementationDanglingWorka
#endif #endif
#endif #endif
bool AbstractShaderProgram::link(std::initializer_list<std::reference_wrapper<AbstractShaderProgram>> shaders) { bool AbstractShaderProgram::link() { return link({*this}); }
bool AbstractShaderProgram::link(std::initializer_list<Containers::Reference<AbstractShaderProgram>> shaders) {
bool allSuccess = true; bool allSuccess = true;
/* Invoke (possibly parallel) linking on all shaders */ /* Invoke (possibly parallel) linking on all shaders */

9
src/Magnum/GL/AbstractShaderProgram.h

@ -29,7 +29,6 @@
* @brief Class @ref Magnum::GL::AbstractShaderProgram * @brief Class @ref Magnum::GL::AbstractShaderProgram
*/ */
#include <functional>
#include <string> #include <string>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
@ -757,7 +756,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @def_gl{LINK_STATUS} and @def_gl{INFO_LOG_LENGTH}, * @def_gl{LINK_STATUS} and @def_gl{INFO_LOG_LENGTH},
* @fn_gl_keyword{GetProgramInfoLog} * @fn_gl_keyword{GetProgramInfoLog}
*/ */
static bool link(std::initializer_list<std::reference_wrapper<AbstractShaderProgram>> shaders); static bool link(std::initializer_list<Containers::Reference<AbstractShaderProgram>> shaders);
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
/** /**
@ -810,7 +809,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* than one shader at once. Other than that there is no other * than one shader at once. Other than that there is no other
* (performance) difference when using this function. * (performance) difference when using this function.
*/ */
void attachShaders(std::initializer_list<std::reference_wrapper<Shader>> shaders); void attachShaders(std::initializer_list<Containers::Reference<Shader>> shaders);
/** /**
* @brief Bind attribute to given location * @brief Bind attribute to given location
@ -930,11 +929,11 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @brief Link the shader * @brief Link the shader
* *
* Links single shader. If possible, prefer to link multiple shaders * Links single shader. If possible, prefer to link multiple shaders
* at once using @ref link(std::initializer_list<std::reference_wrapper<AbstractShaderProgram>>) * at once using @ref link(std::initializer_list<Containers::Reference<AbstractShaderProgram>>)
* for improved performance, see its documentation for more * for improved performance, see its documentation for more
* information. * information.
*/ */
bool link() { return link({*this}); } bool link();
/** /**
* @brief Get uniform location * @brief Get uniform location

2
src/Magnum/GL/Implementation/MeshState.h

@ -59,7 +59,7 @@ struct MeshState {
#endif #endif
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
void(*multiDrawImplementation)(std::initializer_list<std::reference_wrapper<MeshView>>); void(*multiDrawImplementation)(std::initializer_list<Containers::Reference<MeshView>>);
#endif #endif
void(*bindVAOImplementation)(GLuint); void(*bindVAOImplementation)(GLuint);

2
src/Magnum/GL/Mesh.h

@ -926,7 +926,7 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
* @see @ref setCount(), @ref setInstanceCount(), * @see @ref setCount(), @ref setInstanceCount(),
* @ref draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt), * @ref draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt),
* @ref MeshView::draw(AbstractShaderProgram&), * @ref MeshView::draw(AbstractShaderProgram&),
* @ref MeshView::draw(AbstractShaderProgram&, std::initializer_list<std::reference_wrapper<MeshView>>), * @ref MeshView::draw(AbstractShaderProgram&, std::initializer_list<Containers::Reference<MeshView>>),
* @fn_gl_keyword{UseProgram}, @fn_gl_keyword{EnableVertexAttribArray}, * @fn_gl_keyword{UseProgram}, @fn_gl_keyword{EnableVertexAttribArray},
* @fn_gl{BindBuffer}, @fn_gl_keyword{VertexAttribPointer}, * @fn_gl{BindBuffer}, @fn_gl_keyword{VertexAttribPointer},
* @fn_gl_keyword{DisableVertexAttribArray} or @fn_gl_keyword{BindVertexArray}, * @fn_gl_keyword{DisableVertexAttribArray} or @fn_gl_keyword{BindVertexArray},

6
src/Magnum/GL/MeshView.cpp

@ -36,7 +36,7 @@
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
void MeshView::draw(AbstractShaderProgram& shader, std::initializer_list<std::reference_wrapper<MeshView>> meshes) { void MeshView::draw(AbstractShaderProgram& shader, std::initializer_list<Containers::Reference<MeshView>> meshes) {
/* Why std::initializer_list doesn't have empty()? */ /* Why std::initializer_list doesn't have empty()? */
if(!meshes.size()) return; if(!meshes.size()) return;
@ -56,7 +56,7 @@ void MeshView::draw(AbstractShaderProgram& shader, std::initializer_list<std::re
} }
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void MeshView::multiDrawImplementationDefault(std::initializer_list<std::reference_wrapper<MeshView>> meshes) { void MeshView::multiDrawImplementationDefault(std::initializer_list<Containers::Reference<MeshView>> meshes) {
CORRADE_INTERNAL_ASSERT(meshes.size()); CORRADE_INTERNAL_ASSERT(meshes.size());
const Implementation::MeshState& state = *Context::current().state().mesh; const Implementation::MeshState& state = *Context::current().state().mesh;
@ -123,7 +123,7 @@ void MeshView::multiDrawImplementationDefault(std::initializer_list<std::referen
#endif #endif
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
void MeshView::multiDrawImplementationFallback(std::initializer_list<std::reference_wrapper<MeshView>> meshes) { void MeshView::multiDrawImplementationFallback(std::initializer_list<Containers::Reference<MeshView>> meshes) {
for(MeshView& mesh: meshes) { for(MeshView& mesh: meshes) {
/* Nothing to draw in this mesh */ /* Nothing to draw in this mesh */
if(!mesh._count) continue; if(!mesh._count) continue;

15
src/Magnum/GL/MeshView.h

@ -29,9 +29,10 @@
* @brief Class @ref Magnum::GL::MeshView * @brief Class @ref Magnum::GL::MeshView
*/ */
#include <functional>
#include <initializer_list> #include <initializer_list>
#include <Corrade/Containers/Reference.h>
#include "Magnum/Magnum.h"
#include "Magnum/GL/GL.h" #include "Magnum/GL/GL.h"
#include "Magnum/GL/OpenGL.h" #include "Magnum/GL/OpenGL.h"
#include "Magnum/GL/visibility.h" #include "Magnum/GL/visibility.h"
@ -88,10 +89,10 @@ class MAGNUM_GL_EXPORT MeshView {
* @requires_gl Specifying base vertex for indexed meshes is not * @requires_gl Specifying base vertex for indexed meshes is not
* available in OpenGL ES or WebGL. * available in OpenGL ES or WebGL.
*/ */
static void draw(AbstractShaderProgram& shader, std::initializer_list<std::reference_wrapper<MeshView>> meshes); static void draw(AbstractShaderProgram& shader, std::initializer_list<Containers::Reference<MeshView>> meshes);
/** @overload */ /** @overload */
static void draw(AbstractShaderProgram&& shader, std::initializer_list<std::reference_wrapper<MeshView>> meshes) { static void draw(AbstractShaderProgram&& shader, std::initializer_list<Containers::Reference<MeshView>> meshes) {
draw(shader, meshes); draw(shader, meshes);
} }
@ -238,7 +239,7 @@ class MAGNUM_GL_EXPORT MeshView {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* See @ref Mesh::draw(AbstractShaderProgram&) for more information. * See @ref Mesh::draw(AbstractShaderProgram&) for more information.
* @see @ref draw(AbstractShaderProgram&, std::initializer_list<std::reference_wrapper<MeshView>>), * @see @ref draw(AbstractShaderProgram&, std::initializer_list<Containers::Reference<MeshView>>),
* @ref draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt) * @ref draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt)
* @requires_gl32 Extension @gl_extension{ARB,draw_elements_base_vertex} * @requires_gl32 Extension @gl_extension{ARB,draw_elements_base_vertex}
* if the mesh is indexed and @ref baseVertex() is not `0`. * if the mesh is indexed and @ref baseVertex() is not `0`.
@ -286,11 +287,11 @@ class MAGNUM_GL_EXPORT MeshView {
private: private:
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
static MAGNUM_GL_LOCAL void multiDrawImplementationDefault(std::initializer_list<std::reference_wrapper<MeshView>> meshes); static MAGNUM_GL_LOCAL void multiDrawImplementationDefault(std::initializer_list<Containers::Reference<MeshView>> meshes);
#endif #endif
static MAGNUM_GL_LOCAL void multiDrawImplementationFallback(std::initializer_list<std::reference_wrapper<MeshView>> meshes); static MAGNUM_GL_LOCAL void multiDrawImplementationFallback(std::initializer_list<Containers::Reference<MeshView>> meshes);
std::reference_wrapper<Mesh> _original; Containers::Reference<Mesh> _original;
bool _countSet{}; bool _countSet{};
Int _count{}, _baseVertex{}, _instanceCount{1}; Int _count{}, _baseVertex{}, _instanceCount{1};

5
src/Magnum/GL/Shader.cpp

@ -26,6 +26,7 @@
#include "Shader.h" #include "Shader.h"
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Assert.h> #include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Debug.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
@ -746,7 +747,9 @@ Shader& Shader::addFile(const std::string& filename) {
return *this; return *this;
} }
bool Shader::compile(std::initializer_list<std::reference_wrapper<Shader>> shaders) { bool Shader::compile() { return compile({*this}); }
bool Shader::compile(std::initializer_list<Containers::Reference<Shader>> shaders) {
bool allSuccess = true; bool allSuccess = true;
/* Allocate large enough array for source pointers and sizes (to avoid /* Allocate large enough array for source pointers and sizes (to avoid

7
src/Magnum/GL/Shader.h

@ -29,7 +29,6 @@
* @brief Class @ref Magnum::GL::Shader * @brief Class @ref Magnum::GL::Shader
*/ */
#include <functional>
#include <string> #include <string>
#include <vector> #include <vector>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
@ -498,7 +497,7 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
* @fn_gl_keyword{GetShader} with @def_gl{COMPILE_STATUS} and * @fn_gl_keyword{GetShader} with @def_gl{COMPILE_STATUS} and
* @def_gl{INFO_LOG_LENGTH}, @fn_gl_keyword{GetShaderInfoLog} * @def_gl{INFO_LOG_LENGTH}, @fn_gl_keyword{GetShaderInfoLog}
*/ */
static bool compile(std::initializer_list<std::reference_wrapper<Shader>> shaders); static bool compile(std::initializer_list<Containers::Reference<Shader>> shaders);
/** /**
* @brief Constructor * @brief Constructor
@ -610,11 +609,11 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
* @brief Compile shader * @brief Compile shader
* *
* Compiles single shader. Prefer to compile multiple shaders at once * Compiles single shader. Prefer to compile multiple shaders at once
* using @ref compile(std::initializer_list<std::reference_wrapper<Shader>>) * using @ref compile(std::initializer_list<Containers::Reference<Shader>>)
* for improved performance, see its documentation for more * for improved performance, see its documentation for more
* information. * information.
*/ */
bool compile() { return compile({*this}); } bool compile();
private: private:
Shader& setLabelInternal(Containers::ArrayView<const char> label); Shader& setLabelInternal(Containers::ArrayView<const char> label);

1
src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp

@ -24,6 +24,7 @@
*/ */
#include <sstream> #include <sstream>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>

1
src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp

@ -23,6 +23,7 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Assert.h> #include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>

1
src/Magnum/GL/Test/SampleQueryGLTest.cpp

@ -23,6 +23,7 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Assert.h> #include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>

2
src/Magnum/GL/Test/TransformFeedbackGLTest.cpp

@ -23,6 +23,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/Reference.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/GL/AbstractShaderProgram.h" #include "Magnum/GL/AbstractShaderProgram.h"
#include "Magnum/GL/Buffer.h" #include "Magnum/GL/Buffer.h"

1
src/Magnum/Shaders/DistanceFieldVector.cpp

@ -25,6 +25,7 @@
#include "DistanceFieldVector.h" #include "DistanceFieldVector.h"
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"

1
src/Magnum/Shaders/Flat.cpp

@ -26,6 +26,7 @@
#include "Flat.h" #include "Flat.h"
#include <Corrade/Containers/EnumSet.hpp> #include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"

1
src/Magnum/Shaders/MeshVisualizer.cpp

@ -27,6 +27,7 @@
#include <Corrade/Containers/EnumSet.hpp> #include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"

1
src/Magnum/Shaders/Phong.cpp

@ -29,6 +29,7 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#endif #endif
#include <Corrade/Containers/EnumSet.hpp> #include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Format.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>

1
src/Magnum/Shaders/Vector.cpp

@ -25,6 +25,7 @@
#include "Vector.h" #include "Vector.h"
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"

1
src/Magnum/Shaders/VertexColor.cpp

@ -25,6 +25,7 @@
#include "VertexColor.h" #include "VertexColor.h"
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"

1
src/Magnum/TextureTools/DistanceField.cpp

@ -25,6 +25,7 @@
#include "DistanceField.h" #include "DistanceField.h"
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Format.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>

Loading…
Cancel
Save