From f7aa2c05a62855b8eab24562e6cd5ac01fa3c934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 26 May 2013 01:27:20 +0200 Subject: [PATCH] Deinlined heavy functions and removed redundant `inline` everywhere else. --- doc/coding-style.dox | 2 +- src/AbstractFramebuffer.cpp | 2 + src/AbstractFramebuffer.h | 6 +- src/AbstractImage.cpp | 2 + src/AbstractImage.h | 12 +- src/AbstractResourceLoader.h | 46 +-- src/AbstractShaderProgram.h | 104 +++--- src/AbstractTexture.h | 50 +-- src/Array.h | 70 ++-- src/Buffer.h | 42 +-- src/BufferImage.h | 6 +- src/BufferTexture.h | 8 +- src/Color.h | 80 ++--- src/Context.h | 36 +- src/CubeMapTexture.h | 28 +- src/CubeMapTextureArray.h | 30 +- src/DebugMarker.h | 2 +- src/DefaultFramebuffer.h | 6 +- src/Framebuffer.h | 36 +- src/Image.h | 12 +- src/ImageWrapper.h | 12 +- src/Implementation/BufferState.h | 2 +- src/Implementation/FramebufferState.h | 2 +- src/Implementation/MeshState.h | 2 +- src/Implementation/RendererState.h | 2 +- src/Implementation/ShaderProgramState.h | 2 +- src/Mesh.h | 31 +- src/Query.h | 14 +- src/Renderbuffer.h | 10 +- src/Renderer.h | 12 +- src/Resource.h | 154 ++++---- src/ResourceManager.h | 443 +++++++++++++----------- src/Shader.h | 2 +- src/Swizzle.h | 2 +- src/Test/ResourceManagerTest.cpp | 4 +- src/Texture.h | 30 +- src/Timeline.h | 8 +- 37 files changed, 676 insertions(+), 636 deletions(-) diff --git a/doc/coding-style.dox b/doc/coding-style.dox index a5ed9e5d8..28e892516 100644 --- a/doc/coding-style.dox +++ b/doc/coding-style.dox @@ -139,7 +139,7 @@ in @c \@see block with @c \@fn_gl command. If only specific definition is used in the function, document it with @c \@def_gl command. Example usage: @code // @see @fn_gl{Enable}/@fn_gl{Disable} with @def_gl{TEXTURE_CUBE_MAP_SEAMLESS} -inline static void setSeamless(bool enabled) { +static void setSeamless(bool enabled) { enabled ? glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS) : glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS); } @endcode diff --git a/src/AbstractFramebuffer.cpp b/src/AbstractFramebuffer.cpp index 870114e49..bc9b20eb5 100644 --- a/src/AbstractFramebuffer.cpp +++ b/src/AbstractFramebuffer.cpp @@ -43,6 +43,8 @@ AbstractFramebuffer::ReadBufferImplementation AbstractFramebuffer::readBufferImp FramebufferTarget AbstractFramebuffer::readTarget = FramebufferTarget::ReadDraw; FramebufferTarget AbstractFramebuffer::drawTarget = FramebufferTarget::ReadDraw; +AbstractFramebuffer::~AbstractFramebuffer() {} + void AbstractFramebuffer::bind(FramebufferTarget target) { bindInternal(target); setViewportInternal(); diff --git a/src/AbstractFramebuffer.h b/src/AbstractFramebuffer.h index ddd3f281d..3e7916dda 100644 --- a/src/AbstractFramebuffer.h +++ b/src/AbstractFramebuffer.h @@ -186,7 +186,7 @@ class MAGNUM_EXPORT AbstractFramebuffer { * @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or * @es_extension{NV,framebuffer_blit} */ - inline static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Rectanglei& rectangle, FramebufferBlitMask mask) { + static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Rectanglei& rectangle, FramebufferBlitMask mask) { blit(source, destination, rectangle, rectangle, mask, FramebufferBlitFilter::Nearest); } @@ -205,7 +205,7 @@ class MAGNUM_EXPORT AbstractFramebuffer { void bind(FramebufferTarget target); /** @brief Viewport rectangle */ - inline Rectanglei viewport() const { return _viewport; } + Rectanglei viewport() const { return _viewport; } /** * @brief Set viewport @@ -316,8 +316,6 @@ class MAGNUM_EXPORT AbstractFramebuffer { static ReadImplementation MAGNUM_LOCAL readImplementation; }; -inline AbstractFramebuffer::~AbstractFramebuffer() {} - CORRADE_ENUMSET_OPERATORS(FramebufferClearMask) CORRADE_ENUMSET_OPERATORS(FramebufferBlitMask) diff --git a/src/AbstractImage.cpp b/src/AbstractImage.cpp index 8c70d25ec..253f2ec37 100644 --- a/src/AbstractImage.cpp +++ b/src/AbstractImage.cpp @@ -30,6 +30,8 @@ namespace Magnum { +AbstractImage::~AbstractImage() {} + std::size_t AbstractImage::pixelSize(ImageFormat format, ImageType type) { std::size_t size = 0; switch(type) { diff --git a/src/AbstractImage.h b/src/AbstractImage.h index e602bf17f..aef3c71ec 100644 --- a/src/AbstractImage.h +++ b/src/AbstractImage.h @@ -66,25 +66,23 @@ class MAGNUM_EXPORT AbstractImage { * @param format Format of pixel data * @param type Data type of pixel data */ - inline explicit AbstractImage(ImageFormat format, ImageType type): _format(format), _type(type) {} + explicit AbstractImage(ImageFormat format, ImageType type): _format(format), _type(type) {} /** @brief Destructor */ virtual ~AbstractImage() = 0; /** @brief Format of pixel data */ - inline ImageFormat format() const { return _format; } + ImageFormat format() const { return _format; } /** @brief Data type of pixel data */ - inline ImageType type() const { return _type; } + ImageType type() const { return _type; } /** * @brief Pixel size (in bytes) * * Convenience member alternative for pixelSize(Format, Type). */ - inline std::size_t pixelSize() const { - return pixelSize(_format, _type); - } + std::size_t pixelSize() const { return pixelSize(_format, _type); } #ifdef DOXYGEN_GENERATING_OUTPUT private: @@ -95,8 +93,6 @@ class MAGNUM_EXPORT AbstractImage { ImageType _type; }; -inline AbstractImage::~AbstractImage() {} - } #endif diff --git a/src/AbstractResourceLoader.h b/src/AbstractResourceLoader.h index 194157607..ae38375b5 100644 --- a/src/AbstractResourceLoader.h +++ b/src/AbstractResourceLoader.h @@ -98,18 +98,16 @@ template class AbstractResourceLoader { friend class Implementation::ResourceManagerData; public: - inline explicit AbstractResourceLoader(): manager(nullptr), _requestedCount(0), _loadedCount(0), _notFoundCount(0) {} + explicit AbstractResourceLoader(): manager(nullptr), _requestedCount(0), _loadedCount(0), _notFoundCount(0) {} - inline virtual ~AbstractResourceLoader() { - if(manager) manager->_loader = nullptr; - } + virtual ~AbstractResourceLoader(); /** * @brief Count of requested resources * * Count of resources requested by calling load(). */ - inline std::size_t requestedCount() const { return _requestedCount; } + std::size_t requestedCount() const { return _requestedCount; } /** * @brief Count of not found resources @@ -117,7 +115,7 @@ template class AbstractResourceLoader { * Count of resources requested by calling load(), but not found by * the loader. */ - inline std::size_t notFoundCount() const { return _notFoundCount; } + std::size_t notFoundCount() const { return _notFoundCount; } /** * @brief Count of loaded resources @@ -125,7 +123,7 @@ template class AbstractResourceLoader { * Count of resources requested by calling load(), but not found by * the loader. */ - inline std::size_t loadedCount() const { return _loadedCount; } + std::size_t loadedCount() const { return _loadedCount; } /** * @brief %Resource name corresponding to given key @@ -160,12 +158,7 @@ template class AbstractResourceLoader { * ResourceManager::set() for more information. * @see loadedCount() */ - inline void set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy) { - CORRADE_ASSERT(state == ResourceDataState::Mutable || state == ResourceDataState::Final, - "AbstractResourceLoader::set(): state must be either Mutable or Final", ); - ++_loadedCount; - manager->set(key, data, state, policy); - } + void set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy); /** * @brief Mark resource as not found @@ -174,11 +167,7 @@ template class AbstractResourceLoader { * ResourceManager::setNotFound() for more information. * @see notFountCount() */ - inline void setNotFound(ResourceKey key) { - ++_notFoundCount; - /** @todo What policy for notfound resources? */ - manager->set(key, nullptr, ResourceDataState::NotFound, ResourcePolicy::Resident); - } + void setNotFound(ResourceKey key); private: Implementation::ResourceManagerData* manager; @@ -187,14 +176,31 @@ template class AbstractResourceLoader { std::size_t _notFoundCount; }; -template inline std::string AbstractResourceLoader::name(ResourceKey) const { return {}; } +template AbstractResourceLoader::~AbstractResourceLoader() { + if(manager) manager->_loader = nullptr; +} + +template std::string AbstractResourceLoader::name(ResourceKey) const { return {}; } -template inline void AbstractResourceLoader::load(ResourceKey key) { +template void AbstractResourceLoader::load(ResourceKey key) { ++_requestedCount; /** @todo What policy for loading resources? */ manager->set(key, nullptr, ResourceDataState::Loading, ResourcePolicy::Resident); } +template void AbstractResourceLoader::set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy) { + CORRADE_ASSERT(state == ResourceDataState::Mutable || state == ResourceDataState::Final, + "AbstractResourceLoader::set(): state must be either Mutable or Final", ); + ++_loadedCount; + manager->set(key, data, state, policy); +} + +template inline void AbstractResourceLoader::setNotFound(ResourceKey key) { + ++_notFoundCount; + /** @todo What policy for notfound resources? */ + manager->set(key, nullptr, ResourceDataState::NotFound, ResourcePolicy::Resident); +} + } #endif diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index b473aa2c8..4f38a26d9 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -320,7 +320,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { virtual ~AbstractShaderProgram() = 0; /** @brief OpenGL program ID */ - inline GLuint id() const { return _id; } + GLuint id() const { return _id; } /** * @brief Validate program @@ -349,7 +349,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl41 %Extension @extension{ARB,get_program_binary} * @requires_gles30 Always allowed in OpenGL ES 2.0. */ - inline void setRetrievableBinary(bool enabled) { + void setRetrievableBinary(bool enabled) { glProgramParameteri(_id, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, enabled ? GL_TRUE : GL_FALSE); } #endif @@ -362,7 +362,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl41 %Extension @extension{ARB,separate_shader_objects} * @requires_es_extension %Extension @es_extension{EXT,separate_shader_objects} */ - inline void setSeparable(bool enabled) { + void setSeparable(bool enabled) { /** @todo Remove when extension wrangler is available for ES */ #ifndef MAGNUM_TARGET_GLES glProgramParameteri(_id, GL_PROGRAM_SEPARABLE, enabled ? GL_TRUE : GL_FALSE); @@ -464,26 +464,26 @@ class MAGNUM_EXPORT AbstractShaderProgram { #ifdef DOXYGEN_GENERATING_OUTPUT template inline void setUniform(Int location, const T& value); #else - inline void setUniform(Int location, Float value) { + void setUniform(Int location, Float value) { setUniform(location, 1, &value); } - inline void setUniform(Int location, Int value) { + void setUniform(Int location, Int value) { setUniform(location, 1, &value); } #ifndef MAGNUM_TARGET_GLES2 - inline void setUniform(Int location, UnsignedInt value) { + void setUniform(Int location, UnsignedInt value) { setUniform(location, 1, &value); } #endif #ifndef MAGNUM_TARGET_GLES - inline void setUniform(Int location, Double value) { + void setUniform(Int location, Double value) { setUniform(location, 1, &value); } #endif - template inline void setUniform(Int location, const Math::Vector& value) { + template void setUniform(Int location, const Math::Vector& value) { setUniform(location, 1, &value); } - template inline void setUniform(Int location, const Math::RectangularMatrix& value) { + template void setUniform(Int location, const Math::RectangularMatrix& value) { setUniform(location, 1, &value); } #endif @@ -500,42 +500,42 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @see setUniform(Int, const T&), @fn_gl{UseProgram}, @fn_gl{Uniform} * or @fn_gl{ProgramUniform}/@fn_gl_extension{ProgramUniform,EXT,direct_state_access}. */ - inline void setUniform(Int location, UnsignedInt count, const Float* values) { + void setUniform(Int location, UnsignedInt count, const Float* values) { (this->*uniform1fvImplementation)(location, count, values); } /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<2, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<2, Float>* values) { (this->*uniform2fvImplementation)(location, count, values); } /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<3, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<3, Float>* values) { (this->*uniform3fvImplementation)(location, count, values); } /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<4, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<4, Float>* values) { (this->*uniform4fvImplementation)(location, count, values); } /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Int* values) { + void setUniform(Int location, UnsignedInt count, const Int* values) { (this->*uniform1ivImplementation)(location, count, values); } /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<2, Int>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<2, Int>* values) { (this->*uniform2ivImplementation)(location, count, values); } /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<3, Int>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<3, Int>* values) { (this->*uniform3ivImplementation)(location, count, values); } /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<4, Int>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<4, Int>* values) { (this->*uniform4ivImplementation)(location, count, values); } @@ -545,7 +545,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl30 %Extension @extension{EXT,gpu_shader4} * @requires_gles30 Only signed integers are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const UnsignedInt* values) { + void setUniform(Int location, UnsignedInt count, const UnsignedInt* values) { (this->*uniform1uivImplementation)(location, count, values); } @@ -554,7 +554,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl30 %Extension @extension{EXT,gpu_shader4} * @requires_gles30 Only signed integers are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<2, UnsignedInt>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<2, UnsignedInt>* values) { (this->*uniform2uivImplementation)(location, count, values); } @@ -563,7 +563,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl30 %Extension @extension{EXT,gpu_shader4} * @requires_gles30 Only signed integers are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<3, UnsignedInt>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<3, UnsignedInt>* values) { (this->*uniform3uivImplementation)(location, count, values); } @@ -572,7 +572,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl30 %Extension @extension{EXT,gpu_shader4} * @requires_gles30 Only signed integers are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<4, UnsignedInt>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<4, UnsignedInt>* values) { (this->*uniform4uivImplementation)(location, count, values); } #endif @@ -583,7 +583,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Double* values) { + void setUniform(Int location, UnsignedInt count, const Double* values) { (this->*uniform1dvImplementation)(location, count, values); } @@ -592,7 +592,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<2, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<2, Double>* values) { (this->*uniform2dvImplementation)(location, count, values); } @@ -601,7 +601,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<3, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<3, Double>* values) { (this->*uniform3dvImplementation)(location, count, values); } @@ -610,23 +610,23 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::Vector<4, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::Vector<4, Double>* values) { (this->*uniform4dvImplementation)(location, count, values); } #endif /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 2, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 2, Float>* values) { (this->*uniformMatrix2fvImplementation)(location, count, values); } /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 3, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 3, Float>* values) { (this->*uniformMatrix3fvImplementation)(location, count, values); } /** @copydoc setUniform(Int, UnsignedInt, const Float*) */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 4, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 4, Float>* values) { (this->*uniformMatrix4fvImplementation)(location, count, values); } @@ -635,7 +635,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @copydoc setUniform(Int, UnsignedInt, const Float*) * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 3, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 3, Float>* values) { (this->*uniformMatrix2x3fvImplementation)(location, count, values); } @@ -643,7 +643,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @copydoc setUniform(Int, UnsignedInt, const Float*) * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 2, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 2, Float>* values) { (this->*uniformMatrix3x2fvImplementation)(location, count, values); } @@ -651,7 +651,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @copydoc setUniform(Int, UnsignedInt, const Float*) * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 4, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 4, Float>* values) { (this->*uniformMatrix2x4fvImplementation)(location, count, values); } @@ -659,7 +659,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @copydoc setUniform(Int, UnsignedInt, const Float*) * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 2, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 2, Float>* values) { (this->*uniformMatrix4x2fvImplementation)(location, count, values); } @@ -667,7 +667,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @copydoc setUniform(Int, UnsignedInt, const Float*) * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 4, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 4, Float>* values) { (this->*uniformMatrix3x4fvImplementation)(location, count, values); } @@ -675,7 +675,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @copydoc setUniform(Int, UnsignedInt, const Float*) * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 3, Float>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 3, Float>* values) { (this->*uniformMatrix4x3fvImplementation)(location, count, values); } #endif @@ -686,7 +686,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 2, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 2, Double>* values) { (this->*uniformMatrix2dvImplementation)(location, count, values); } @@ -695,7 +695,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 3, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 3, Double>* values) { (this->*uniformMatrix3dvImplementation)(location, count, values); } @@ -704,7 +704,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 4, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 4, Double>* values) { (this->*uniformMatrix4dvImplementation)(location, count, values); } @@ -713,7 +713,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 3, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 3, Double>* values) { (this->*uniformMatrix2x3dvImplementation)(location, count, values); } @@ -722,7 +722,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 2, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 2, Double>* values) { (this->*uniformMatrix3x2dvImplementation)(location, count, values); } @@ -731,7 +731,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 4, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 4, Double>* values) { (this->*uniformMatrix2x4dvImplementation)(location, count, values); } @@ -740,7 +740,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 2, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 2, Double>* values) { (this->*uniformMatrix4x2dvImplementation)(location, count, values); } @@ -749,7 +749,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 4, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 4, Double>* values) { (this->*uniformMatrix3x4dvImplementation)(location, count, values); } @@ -758,7 +758,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gl40 %Extension @extension{ARB,gpu_shader_fp64} * @requires_gl Only floats are available in OpenGL ES. */ - inline void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 3, Double>* values) { + void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 3, Double>* values) { (this->*uniformMatrix4x3dvImplementation)(location, count, values); } #endif @@ -1108,7 +1108,7 @@ template class AbstractShaderProgram::Attribute { * type used in shader (e.g. DataType::Integer for Vector4i). * @param dataOptions Data options. Default is no options. */ - inline constexpr Attribute(Components components, DataType dataType = Implementation::Attribute::DefaultDataType, DataOptions dataOptions = DataOptions()): _components(components), _dataType(dataType), _dataOptions(dataOptions) {} + constexpr Attribute(Components components, DataType dataType = Implementation::Attribute::DefaultDataType, DataOptions dataOptions = DataOptions()): _components(components), _dataType(dataType), _dataOptions(dataOptions) {} /** * @brief Constructor @@ -1119,21 +1119,21 @@ template class AbstractShaderProgram::Attribute { * Component count is set to the same value as in type used in shader * (e.g. @ref Components "Components::Three" for Vector3). */ - inline constexpr Attribute(DataType dataType = Implementation::Attribute::DefaultDataType, DataOptions dataOptions = DataOptions()): _components(Implementation::Attribute::DefaultComponents), _dataType(dataType), _dataOptions(dataOptions) {} + constexpr Attribute(DataType dataType = Implementation::Attribute::DefaultDataType, DataOptions dataOptions = DataOptions()): _components(Implementation::Attribute::DefaultComponents), _dataType(dataType), _dataOptions(dataOptions) {} /** @brief Component count of passed data */ - inline constexpr Components components() const { return _components; } + constexpr Components components() const { return _components; } /** @brief Type of passed data */ - inline constexpr DataType dataType() const { return _dataType; } + constexpr DataType dataType() const { return _dataType; } /** @brief Size of passed data */ - inline std::size_t dataSize() const { + std::size_t dataSize() const { return Implementation::Attribute::size(GLint(_components)*Implementation::Attribute::vectorCount(), _dataType); } /** @brief Data options */ - inline constexpr DataOptions dataOptions() const { return _dataOptions; } + constexpr DataOptions dataOptions() const { return _dataOptions; } private: const Components _components; @@ -1156,7 +1156,7 @@ template struct SizedAttribute; /* Vector attribute sizes */ template struct SizedVectorAttribute { - inline constexpr static std::size_t vectorCount() { return cols; } + constexpr static std::size_t vectorCount() { return cols; } }; template<> struct SizedAttribute<1, 1>: SizedVectorAttribute<1> { enum class Components: GLint { One = 1 }; @@ -1281,7 +1281,7 @@ struct UnsignedIntAttribute { typedef IntAttribute::DataOption DataOption; typedef Containers::EnumSet DataOptions; - inline static std::size_t size(GLint components, DataType dataType) { + static std::size_t size(GLint components, DataType dataType) { return IntAttribute::size(components, dataType); } }; @@ -1352,7 +1352,7 @@ template<> struct Attribute> { }; typedef Containers::EnumSet DataOptions; - inline constexpr static std::size_t vectorCount() { return 1; } + constexpr static std::size_t vectorCount() { return 1; } static std::size_t MAGNUM_EXPORT size(GLint components, DataType dataType); }; diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 7098dd37c..912800636 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -104,7 +104,7 @@ class MAGNUM_EXPORT AbstractTexture { static Int maxSupportedLayerCount(); #ifndef DOXYGEN_GENERATING_OUTPUT - inline explicit AbstractTexture(GLenum target): _target(target) { + explicit AbstractTexture(GLenum target): _target(target) { glGenTextures(1, &_id); } #endif @@ -124,7 +124,7 @@ class MAGNUM_EXPORT AbstractTexture { AbstractTexture& operator=(AbstractTexture&& other); /** @brief OpenGL texture ID */ - inline GLuint id() const { return _id; } + GLuint id() const { return _id; } /** * @brief Bind texture for rendering @@ -174,7 +174,7 @@ class MAGNUM_EXPORT AbstractTexture { * or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * with @def_gl{TEXTURE_MAG_FILTER} */ - inline AbstractTexture* setMagnificationFilter(Sampler::Filter filter) { + AbstractTexture* setMagnificationFilter(Sampler::Filter filter) { (this->*parameteriImplementation)(GL_TEXTURE_MAG_FILTER, static_cast(filter)); return this; } @@ -193,7 +193,7 @@ class MAGNUM_EXPORT AbstractTexture { * with @def_gl{TEXTURE_BORDER_COLOR} * @requires_es_extension %Extension @es_extension{NV,texture_border_clamp} */ - inline AbstractTexture* setBorderColor(const Color4<>& color) { + AbstractTexture* setBorderColor(const Color4<>& color) { #ifndef MAGNUM_TARGET_GLES (this->*parameterfvImplementation)(GL_TEXTURE_BORDER_COLOR, color.data()); #else @@ -217,7 +217,7 @@ class MAGNUM_EXPORT AbstractTexture { * @requires_extension %Extension @extension{EXT,texture_filter_anisotropic} * @requires_es_extension %Extension @es_extension2{EXT,texture_filter_anisotropic,texture_filter_anisotropic} */ - inline AbstractTexture* setMaxAnisotropy(Float anisotropy) { + AbstractTexture* setMaxAnisotropy(Float anisotropy) { (this->*parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); return this; } @@ -232,7 +232,7 @@ class MAGNUM_EXPORT AbstractTexture { * @see @ref Texture::invalidateSubImage() "invalidateSubImage()", * @fn_gl{InvalidateTexImage} */ - inline void invalidateImage(Int level) { + void invalidateImage(Int level) { (this->*invalidateImageImplementation)(level); } @@ -406,7 +406,7 @@ class MAGNUM_EXPORT AbstractTexture { #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { template struct ImageHelper { - inline static const GLvoid* dataOrPixelUnpackBuffer(Image* image) { + static const GLvoid* dataOrPixelUnpackBuffer(Image* image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbind(Buffer::Target::PixelUnpack); #endif @@ -427,27 +427,27 @@ template<> struct AbstractTexture::DataHelper<1> { Texture1D = GL_TEXTURE_1D }; - inline constexpr static Target target() { return Target::Texture1D; } + constexpr static Target target() { return Target::Texture1D; } static Math::Vector<1, GLint> imageSize(AbstractTexture* texture, GLenum target, GLint level); - inline static void setWrapping(AbstractTexture* texture, const Array1D& wrapping) { + static void setWrapping(AbstractTexture* texture, const Array1D& wrapping) { (texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast(wrapping.x())); } - inline static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { + static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { (texture->*storage1DImplementation)(target, levels, internalFormat, size); } - template inline static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, Image* image) { + template static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, Image* image) { (texture->*image1DImplementation)(target, level, internalFormat, image->size(), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } - template inline static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Math::Vector<1, GLint>& offset, Image* image) { + template static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Math::Vector<1, GLint>& offset, Image* image) { (texture->*subImage1DImplementation)(target, level, offset, image->size(), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } - inline static void invalidateSubImage(AbstractTexture* texture, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size) { + static void invalidateSubImage(AbstractTexture* texture, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size) { (texture->*invalidateSubImageImplementation)(level, {offset[0], 0, 0}, {size[0], 1, 1}); } }; @@ -462,7 +462,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { #endif }; - inline constexpr static Target target() { return Target::Texture2D; } + constexpr static Target target() { return Target::Texture2D; } #ifndef MAGNUM_TARGET_GLES static Vector2i imageSize(AbstractTexture* texture, GLenum target, GLint level); @@ -470,23 +470,23 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { static void setWrapping(AbstractTexture* texture, const Array2D& wrapping); - inline static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { + static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { (texture->*storage2DImplementation)(target, levels, internalFormat, size); } - template inline static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, Image* image) { + template static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, Image* image) { (texture->*image2DImplementation)(target, level, internalFormat, image->size(), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } - template inline static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector2i& offset, Image* image) { + template static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector2i& offset, Image* image) { (texture->*subImage2DImplementation)(target, level, offset, image->size(), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } - template inline static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector2i& offset, Image* image) { + template static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector2i& offset, Image* image) { (texture->*subImage2DImplementation)(target, level, offset, Vector2i(image->size(), 1), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } - inline static void invalidateSubImage(AbstractTexture* texture, GLint level, const Vector2i& offset, const Vector2i& size) { + static void invalidateSubImage(AbstractTexture* texture, GLint level, const Vector2i& offset, const Vector2i& size) { (texture->*invalidateSubImageImplementation)(level, {offset, 0}, {size, 1}); } }; @@ -503,7 +503,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { #endif }; - inline constexpr static Target target() { return Target::Texture3D; } + constexpr static Target target() { return Target::Texture3D; } #ifndef MAGNUM_TARGET_GLES static Vector3i imageSize(AbstractTexture* texture, GLenum target, GLint level); @@ -511,23 +511,23 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { static void setWrapping(AbstractTexture* texture, const Array3D& wrapping); - inline static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { + static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { (texture->*storage3DImplementation)(target, levels, internalFormat, size); } - template inline static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, Image* image) { + template static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, Image* image) { (texture->*image3DImplementation)(target, level, internalFormat, image->size(), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } - template inline static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector3i& offset, Image* image) { + template static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector3i& offset, Image* image) { (texture->*subImage3DImplementation)(target, level, offset, image->size(), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } - template inline static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector3i& offset, Image* image) { + template static typename std::enable_if::type setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector3i& offset, Image* image) { (texture->*subImage3DImplementation)(target, level, offset, Vector3i(image->size(), 1), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } - inline static void invalidateSubImage(AbstractTexture* texture, GLint level, const Vector3i& offset, const Vector3i& size) { + static void invalidateSubImage(AbstractTexture* texture, GLint level, const Vector3i& offset, const Vector3i& size) { (texture->*invalidateSubImageImplementation)(level, offset, size); } }; diff --git a/src/Array.h b/src/Array.h index 5c79267e2..b1c6fb763 100644 --- a/src/Array.h +++ b/src/Array.h @@ -55,7 +55,7 @@ template class Array { * * Sets all components to their default-constructed values */ - inline constexpr /*implicit*/ Array(): _data() {} + constexpr /*implicit*/ Array(): _data() {} /** * @brief Initializer-list constructor @@ -63,45 +63,45 @@ template class Array { * @param next Next values */ #ifndef DOXYGEN_GENERATING_OUTPUT - template inline constexpr /*implicit*/ Array(T first, T second, U... next): _data{first, second, next...} { + template constexpr /*implicit*/ Array(T first, T second, U... next): _data{first, second, next...} { static_assert(sizeof...(next)+2 == dimensions, "Improper number of arguments passed to Array constructor"); } - template inline constexpr /*implicit*/ Array(typename std::enable_if::value && dimensions == 1, U>::type first): _data{first} {} + template constexpr /*implicit*/ Array(typename std::enable_if::value && dimensions == 1, U>::type first): _data{first} {} #else - template inline constexpr /*implicit*/ Array(T first, U... next); + template constexpr /*implicit*/ Array(T first, U... next); #endif /** * @brief Constructor * @param value Value for all fields */ - template::value && dimensions != 1, U>::type> inline /*implicit*/ Array(U value) { + template::value && dimensions != 1, U>::type> /*implicit*/ Array(U value) { for(UnsignedInt i = 0; i != dimensions; ++i) _data[i] = value; } /** @brief Equality */ - inline bool operator==(const Array& other) const { + bool operator==(const Array& other) const { for(UnsignedInt i = 0; i != dimensions; ++i) if(_data[i] != other._data[i]) return false; return true; } /** @brief Non-equality */ - inline bool operator!=(const Array& other) const { + bool operator!=(const Array& other) const { return !operator==(other); } /** @brief Value at given position */ - inline T& operator[](UnsignedInt pos) { return _data[pos]; } - inline constexpr T operator[](UnsignedInt pos) const { return _data[pos]; } /**< @overload */ + T& operator[](UnsignedInt pos) { return _data[pos]; } + constexpr T operator[](UnsignedInt pos) const { return _data[pos]; } /**< @overload */ /** * @brief Raw data * @return One-dimensional array of `dimensions` length */ - inline T* data() { return _data; } - inline constexpr const T* data() const { return _data; } /**< @overload */ + T* data() { return _data; } + constexpr const T* data() const { return _data; } /**< @overload */ private: T _data[dimensions]; @@ -114,19 +114,19 @@ template class Array { template class Array1D: public Array<1, T> { public: /** @copydoc Array::Array() */ - inline constexpr /*implicit*/ Array1D() = default; + constexpr /*implicit*/ Array1D() = default; /** * @brief Constructor * @param x X component */ - inline constexpr /*implicit*/ Array1D(T x): Array<1, T>(x) {} + constexpr /*implicit*/ Array1D(T x): Array<1, T>(x) {} /** @brief Copy constructor */ - inline constexpr Array1D(const Array<1, T>& other): Array<1, T>(other) {} + constexpr Array1D(const Array<1, T>& other): Array<1, T>(other) {} - inline T& x() { return (*this)[0]; } /**< @brief X component */ - inline constexpr T x() const { return (*this)[0]; } /**< @overload */ + T& x() { return (*this)[0]; } /**< @brief X component */ + constexpr T x() const { return (*this)[0]; } /**< @overload */ }; /** @@ -136,25 +136,25 @@ template class Array1D: public Array<1, T> { template class Array2D: public Array<2, T> { public: /** @copydoc Array::Array() */ - inline constexpr /*implicit*/ Array2D() = default; + constexpr /*implicit*/ Array2D() = default; /** * @brief Constructor * @param x X component * @param y Y component */ - inline constexpr /*implicit*/ Array2D(T x, T y): Array<2, T>(x, y) {} + constexpr /*implicit*/ Array2D(T x, T y): Array<2, T>(x, y) {} /** @copydoc Array::Array(U) */ - inline constexpr /*implicit*/ Array2D(T value): Array<2, T>(value, value) {} + constexpr /*implicit*/ Array2D(T value): Array<2, T>(value, value) {} /** @brief Copy constructor */ - inline constexpr Array2D(const Array<2, T>& other): Array<2, T>(other) {} + constexpr Array2D(const Array<2, T>& other): Array<2, T>(other) {} - inline T& x() { return (*this)[0]; } /**< @brief X component */ - inline constexpr T x() const { return (*this)[0]; } /**< @overload */ - inline T& y() { return (*this)[1]; } /**< @brief Y component */ - inline constexpr T y() const { return (*this)[1]; } /**< @overload */ + T& x() { return (*this)[0]; } /**< @brief X component */ + constexpr T x() const { return (*this)[0]; } /**< @overload */ + T& y() { return (*this)[1]; } /**< @brief Y component */ + constexpr T y() const { return (*this)[1]; } /**< @overload */ }; /** @@ -164,7 +164,7 @@ template class Array2D: public Array<2, T> { template class Array3D: public Array<3, T> { public: /** @copydoc Array::Array() */ - inline constexpr /*implicit*/ Array3D() {} + constexpr /*implicit*/ Array3D() {} /** * @brief Constructor @@ -172,20 +172,20 @@ template class Array3D: public Array<3, T> { * @param y Y component * @param z Z component */ - inline constexpr /*implicit*/ Array3D(T x, T y, T z): Array<3, T>(x, y, z) {} + constexpr /*implicit*/ Array3D(T x, T y, T z): Array<3, T>(x, y, z) {} /** @copydoc Array::Array(U) */ - inline constexpr /*implicit*/ Array3D(T value): Array<3, T>(value, value, value) {} + constexpr /*implicit*/ Array3D(T value): Array<3, T>(value, value, value) {} /** @brief Copy constructor */ - inline constexpr Array3D(const Array<3, T>& other): Array<3, T>(other) {} - - inline T& x() { return (*this)[0]; } /**< @brief X component */ - inline constexpr T x() const { return (*this)[0]; } /**< @overload */ - inline T& y() { return (*this)[1]; } /**< @brief Y component */ - inline constexpr T y() const { return (*this)[1]; } /**< @overload */ - inline T& z() { return (*this)[2]; } /**< @brief Z component */ - inline constexpr T z() const { return (*this)[2]; } /**< @overload */ + constexpr Array3D(const Array<3, T>& other): Array<3, T>(other) {} + + T& x() { return (*this)[0]; } /**< @brief X component */ + constexpr T x() const { return (*this)[0]; } /**< @overload */ + T& y() { return (*this)[1]; } /**< @brief Y component */ + constexpr T y() const { return (*this)[1]; } /**< @overload */ + T& z() { return (*this)[2]; } /**< @brief Z component */ + constexpr T z() const { return (*this)[2]; } /**< @overload */ }; /** @debugoperator{Magnum::Array} */ diff --git a/src/Buffer.h b/src/Buffer.h index 600b9c076..48924f652 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -437,7 +437,7 @@ class MAGNUM_EXPORT Buffer { * * @see @fn_gl{BindBuffer} */ - inline static void unbind(Target target) { bind(target, 0); } + static void unbind(Target target) { bind(target, 0); } #ifndef MAGNUM_TARGET_GLES2 /** @@ -457,7 +457,7 @@ class MAGNUM_EXPORT Buffer { * @requires_gl31 %Extension @extension{ARB,copy_buffer} * @requires_gles30 %Buffer copying is not available in OpenGL ES 2.0. */ - inline static void copy(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { + static void copy(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { copyImplementation(read, write, readOffset, writeOffset, size); } #endif @@ -470,7 +470,7 @@ class MAGNUM_EXPORT Buffer { * Generates new OpenGL buffer. * @see @fn_gl{GenBuffers} */ - inline explicit Buffer(Target targetHint = Target::Array): _targetHint(targetHint) { + explicit Buffer(Target targetHint = Target::Array): _targetHint(targetHint) { glGenBuffers(1, &_id); } @@ -483,10 +483,10 @@ class MAGNUM_EXPORT Buffer { virtual ~Buffer(); /** @brief OpenGL buffer ID */ - inline GLuint id() const { return _id; } + GLuint id() const { return _id; } /** @brief Target hint */ - inline Target targetHint() const { return _targetHint; } + Target targetHint() const { return _targetHint; } /** * @brief Set target hint @@ -503,7 +503,7 @@ class MAGNUM_EXPORT Buffer { * http://www.opengl.org/wiki/Vertex_Specification#Index_buffers * ... damned GL state */ - inline Buffer* setTargetHint(Target hint) { + Buffer* setTargetHint(Target hint) { _targetHint = hint; return this; } @@ -518,7 +518,7 @@ class MAGNUM_EXPORT Buffer { * @todo Don't allow user to bind buffers? * @see @fn_gl{BindBuffer} */ - inline void bind(Target target) { bind(target, _id); } + void bind(Target target) { bind(target, _id); } /** * @brief Buffer size @@ -571,7 +571,7 @@ class MAGNUM_EXPORT Buffer { * @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferData} or * @fn_gl_extension{NamedBufferData,EXT,direct_state_access} */ - inline Buffer* setData(GLsizeiptr size, const GLvoid* data, Usage usage) { + Buffer* setData(GLsizeiptr size, const GLvoid* data, Usage usage) { (this->*dataImplementation)(size, data, usage); return this; } @@ -584,7 +584,7 @@ class MAGNUM_EXPORT Buffer { * * @see setData(GLsizeiptr, const GLvoid*, Usage). */ - template inline Buffer* setData(const T(&data)[size], Usage usage) { + template Buffer* setData(const T(&data)[size], Usage usage) { setData(size*sizeof(T), data, usage); return this; } @@ -597,13 +597,13 @@ class MAGNUM_EXPORT Buffer { * * @see setData(GLsizeiptr, const GLvoid*, Usage) */ - template inline Buffer* setData(const std::vector& data, Usage usage) { + template Buffer* setData(const std::vector& data, Usage usage) { setData(data.size()*sizeof(T), data.data(), usage); return this; } /** @overload */ - template inline void setData(const std::array& data, Usage usage) { + template void setData(const std::array& data, Usage usage) { setData(data.size()*sizeof(T), data.data(), usage); } @@ -620,7 +620,7 @@ class MAGNUM_EXPORT Buffer { * @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferSubData} * or @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access} */ - inline Buffer* setSubData(GLintptr offset, GLsizeiptr size, const GLvoid* data) { + Buffer* setSubData(GLintptr offset, GLsizeiptr size, const GLvoid* data) { (this->*subDataImplementation)(offset, size, data); return this; } @@ -633,7 +633,7 @@ class MAGNUM_EXPORT Buffer { * * @see setSubData(GLintptr, GLsizeiptr, const GLvoid*) */ - template inline Buffer* setSubData(GLintptr offset, const T(&data)[size]) { + template Buffer* setSubData(GLintptr offset, const T(&data)[size]) { setSubData(offset, size*sizeof(T), data); return this; } @@ -646,13 +646,13 @@ class MAGNUM_EXPORT Buffer { * * @see setSubData(GLintptr, GLsizeiptr, const GLvoid*) */ - template inline Buffer* setSubData(GLintptr offset, const std::vector& data) { + template Buffer* setSubData(GLintptr offset, const std::vector& data) { setSubData(offset, data.size()*sizeof(T), data.data()); return this; } /** @overload */ - template inline Buffer* setSubData(GLintptr offset, const std::array& data) { + template Buffer* setSubData(GLintptr offset, const std::array& data) { setSubData(offset, data.size()*sizeof(T), data.data()); return this; } @@ -666,7 +666,7 @@ class MAGNUM_EXPORT Buffer { * is not available, this function does nothing. * @see @ref MapFlag "MapFlag::InvalidateBuffer", @fn_gl{InvalidateBufferData} */ - inline Buffer* invalidateData() { + Buffer* invalidateData() { (this->*invalidateImplementation)(); return this; } @@ -681,7 +681,7 @@ class MAGNUM_EXPORT Buffer { * is not available, this function does nothing. * @see @ref MapFlag "MapFlag::InvalidateRange", @fn_gl{InvalidateBufferData} */ - inline Buffer* invalidateSubData(GLintptr offset, GLsizeiptr length) { + Buffer* invalidateSubData(GLintptr offset, GLsizeiptr length) { (this->*invalidateSubImplementation)(offset, length); return this; } @@ -704,7 +704,7 @@ class MAGNUM_EXPORT Buffer { * OpenGL ES 2.0, use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)" * in OpenGL ES 3.0 instead. */ - inline void* map(MapAccess access) { + void* map(MapAccess access) { return (this->*mapImplementation)(access); } #endif @@ -725,7 +725,7 @@ class MAGNUM_EXPORT Buffer { * @requires_gl30 %Extension @extension{ARB,map_buffer_range} * @requires_gles30 %Extension @es_extension{EXT,map_buffer_range} */ - inline void* map(GLintptr offset, GLsizeiptr length, MapFlags flags) { + void* map(GLintptr offset, GLsizeiptr length, MapFlags flags) { return (this->*mapRangeImplementation)(offset, length, flags); } @@ -747,7 +747,7 @@ class MAGNUM_EXPORT Buffer { * @requires_gl30 %Extension @extension{ARB,map_buffer_range} * @requires_gles30 %Extension @es_extension{EXT,map_buffer_range} */ - inline Buffer* flushMappedRange(GLintptr offset, GLsizeiptr length) { + Buffer* flushMappedRange(GLintptr offset, GLsizeiptr length) { (this->*flushMappedRangeImplementation)(offset, length); return this; } @@ -766,7 +766,7 @@ class MAGNUM_EXPORT Buffer { * @fn_gl_extension{UnmapNamedBuffer,EXT,direct_state_access} * @requires_gles30 %Extension @es_extension{OES,mapbuffer} */ - inline bool unmap() { + bool unmap() { return (this->*unmapImplementation)(); } diff --git a/src/BufferImage.h b/src/BufferImage.h index 3e2436201..d49462817 100644 --- a/src/BufferImage.h +++ b/src/BufferImage.h @@ -58,15 +58,15 @@ template class MAGNUM_EXPORT BufferImage: public Abstrac * Dimensions and buffer are empty, call setData() to fill the image * with data. */ - inline explicit BufferImage(ImageFormat format, ImageType type): AbstractImage(format, type) { + explicit BufferImage(ImageFormat format, ImageType type): AbstractImage(format, type) { _buffer.setTargetHint(Buffer::Target::PixelPack); } /** @brief %Image size */ - inline typename DimensionTraits::VectorType size() const { return _size; } + typename DimensionTraits::VectorType size() const { return _size; } /** @brief %Image buffer */ - inline Buffer* buffer() { return &_buffer; } + Buffer* buffer() { return &_buffer; } /** * @brief Set image data diff --git a/src/BufferTexture.h b/src/BufferTexture.h index 8b089f8d5..6f41e922e 100644 --- a/src/BufferTexture.h +++ b/src/BufferTexture.h @@ -90,10 +90,10 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture { BufferTexture& operator=(BufferTexture&&) = delete; public: - inline explicit BufferTexture(): AbstractTexture(GL_TEXTURE_BUFFER) {} + explicit BufferTexture(): AbstractTexture(GL_TEXTURE_BUFFER) {} /** @copydoc AbstractTexture::bind() */ - inline void bind(Int layer) { AbstractTexture::bind(layer); } + void bind(Int layer) { AbstractTexture::bind(layer); } /** * @brief Set texture buffer @@ -106,7 +106,7 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture { * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer} * or @fn_gl_extension{TextureBuffer,EXT,direct_state_access} */ - inline void setBuffer(BufferTextureFormat internalFormat, Buffer* buffer) { + void setBuffer(BufferTextureFormat internalFormat, Buffer* buffer) { (this->*setBufferImplementation)(internalFormat, buffer); } @@ -124,7 +124,7 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture { * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBufferRange} * or @fn_gl_extension{TextureBufferRange,EXT,direct_state_access} */ - inline void setBuffer(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { + void setBuffer(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { (this->*setBufferRangeImplementation)(internalFormat, buffer, offset, size); } diff --git a/src/Color.h b/src/Color.h index c2113f6f8..e38290eec 100644 --- a/src/Color.h +++ b/src/Color.h @@ -39,7 +39,7 @@ namespace Magnum { namespace Implementation { /* Convert color from HSV */ -template inline typename std::enable_if::value, Color3>::type fromHSV(typename Color3::HSV hsv) { +template typename std::enable_if::value, Color3>::type fromHSV(typename Color3::HSV hsv) { Math::Deg hue; T saturation, value; std::tie(hue, saturation, value) = hsv; @@ -172,11 +172,11 @@ class Color3: public Math::Vector3 { * * Hue can overflow the range @f$ [0.0, 360.0] @f$. */ - inline constexpr static Color3 fromHSV(HSV hsv) { + constexpr static Color3 fromHSV(HSV hsv) { return Implementation::fromHSV(hsv); } /** @overload */ - inline constexpr static Color3 fromHSV(Math::Deg hue, FloatingPointType saturation, FloatingPointType value) { + constexpr static Color3 fromHSV(Math::Deg hue, FloatingPointType saturation, FloatingPointType value) { return fromHSV(std::make_tuple(hue, saturation, value)); } @@ -185,13 +185,13 @@ class Color3: public Math::Vector3 { * * All components are set to zero. */ - inline constexpr /*implicit*/ Color3() {} + constexpr /*implicit*/ Color3() {} /** * @brief Gray constructor * @param rgb RGB value */ - inline constexpr explicit Color3(T rgb): Math::Vector3(rgb) {} + constexpr explicit Color3(T rgb): Math::Vector3(rgb) {} /** * @brief Constructor @@ -199,20 +199,20 @@ class Color3: public Math::Vector3 { * @param g G value * @param b B value */ - inline constexpr /*implicit*/ Color3(T r, T g, T b): Math::Vector3(r, g, b) {} + constexpr /*implicit*/ Color3(T r, T g, T b): Math::Vector3(r, g, b) {} /** @copydoc Math::Vector::Vector(const Vector&) */ - template inline constexpr explicit Color3(const Math::Vector<3, U>& other): Math::Vector3(other) {} + template constexpr explicit Color3(const Math::Vector<3, U>& other): Math::Vector3(other) {} /** @brief Copy constructor */ - inline constexpr Color3(const Math::Vector<3, T>& other): Math::Vector3(other) {} + constexpr Color3(const Math::Vector<3, T>& other): Math::Vector3(other) {} - inline T& r() { return Math::Vector3::x(); } /**< @brief R component */ - inline constexpr T r() const { return Math::Vector3::x(); } /**< @overload */ - inline T& g() { return Math::Vector3::y(); } /**< @brief G component */ - inline constexpr T g() const { return Math::Vector3::y(); } /**< @overload */ - inline T& b() { return Math::Vector3::z(); } /**< @brief B component */ - inline constexpr T b() const { return Math::Vector3::z(); } /**< @overload */ + T& r() { return Math::Vector3::x(); } /**< @brief R component */ + constexpr T r() const { return Math::Vector3::x(); } /**< @overload */ + T& g() { return Math::Vector3::y(); } /**< @brief G component */ + constexpr T g() const { return Math::Vector3::y(); } /**< @overload */ + T& b() { return Math::Vector3::z(); } /**< @brief B component */ + constexpr T b() const { return Math::Vector3::z(); } /**< @overload */ /** * @brief Convert to HSV @@ -225,7 +225,7 @@ class Color3: public Math::Vector3 { * * @see hue(), saturation(), value(), fromHSV() */ - inline constexpr HSV toHSV() const { + constexpr HSV toHSV() const { return Implementation::toHSV(*this); } @@ -235,7 +235,7 @@ class Color3: public Math::Vector3 { * * @see saturation(), value(), toHSV(), fromHSV() */ - inline constexpr Math::Deg hue() const { + constexpr Math::Deg hue() const { return Math::Deg(Implementation::hue(*this)); } @@ -245,7 +245,7 @@ class Color3: public Math::Vector3 { * * @see hue(), value(), toHSV(), fromHSV() */ - inline constexpr FloatingPointType saturation() const { + constexpr FloatingPointType saturation() const { return Implementation::saturation(*this); } @@ -255,7 +255,7 @@ class Color3: public Math::Vector3 { * * @see hue(), saturation(), toHSV(), fromHSV() */ - inline constexpr FloatingPointType value() const { + constexpr FloatingPointType value() const { return Implementation::value(*this); } @@ -289,11 +289,11 @@ class Color4: public Math::Vector4 { * @param a Alpha value, defaults to 1.0 for floating-point types * and maximum positive value for integral types. */ - inline constexpr static Color4 fromHSV(HSV hsv, T a = Implementation::defaultAlpha()) { + constexpr static Color4 fromHSV(HSV hsv, T a = Implementation::defaultAlpha()) { return Color4(Implementation::fromHSV(hsv), a); } /** @overload */ - inline constexpr static Color4 fromHSV(Math::Deg hue, FloatingPointType saturation, FloatingPointType value, T alpha) { + constexpr static Color4 fromHSV(Math::Deg hue, FloatingPointType saturation, FloatingPointType value, T alpha) { return fromHSV(std::make_tuple(hue, saturation, value), alpha); } @@ -303,14 +303,14 @@ class Color4: public Math::Vector4 { * RGB components are set to zero, A component is set to 1.0 for * floating-point types and maximum positive value for integral types. */ - inline constexpr /*implicit*/ Color4(): Math::Vector4(T(0), T(0), T(0), Implementation::defaultAlpha()) {} + constexpr /*implicit*/ Color4(): Math::Vector4(T(0), T(0), T(0), Implementation::defaultAlpha()) {} /** * @copydoc Color3::Color3(T) * @param alpha Alpha value, defaults to 1.0 for floating-point types * and maximum positive value for integral types. */ - inline constexpr explicit Color4(T rgb, T alpha = Implementation::defaultAlpha()): Math::Vector4(rgb, rgb, rgb, alpha) {} + constexpr explicit Color4(T rgb, T alpha = Implementation::defaultAlpha()): Math::Vector4(rgb, rgb, rgb, alpha) {} /** * @brief Constructor @@ -320,7 +320,7 @@ class Color4: public Math::Vector4 { * @param a A value, defaults to 1.0 for floating-point types and * maximum positive value for integral types. */ - inline constexpr /*implicit*/ Color4(T r, T g, T b, T a = Implementation::defaultAlpha()): Math::Vector4(r, g, b, a) {} + constexpr /*implicit*/ Color4(T r, T g, T b, T a = Implementation::defaultAlpha()): Math::Vector4(r, g, b, a) {} /** * @brief Constructor @@ -329,22 +329,22 @@ class Color4: public Math::Vector4 { */ /* Not marked as explicit, because conversion from Color3 to Color4 is fairly common, nearly always with A set to 1 */ - inline constexpr /*implicit*/ Color4(const Math::Vector3& rgb, T a = Implementation::defaultAlpha()): Math::Vector4(rgb[0], rgb[1], rgb[2], a) {} + constexpr /*implicit*/ Color4(const Math::Vector3& rgb, T a = Implementation::defaultAlpha()): Math::Vector4(rgb[0], rgb[1], rgb[2], a) {} /** @copydoc Math::Vector::Vector(const Vector&) */ - template inline constexpr explicit Color4(const Math::Vector<4, U>& other): Math::Vector4(other) {} + template constexpr explicit Color4(const Math::Vector<4, U>& other): Math::Vector4(other) {} /** @brief Copy constructor */ - inline constexpr Color4(const Math::Vector<4, T>& other): Math::Vector4(other) {} + constexpr Color4(const Math::Vector<4, T>& other): Math::Vector4(other) {} - inline T& r() { return Math::Vector4::x(); } /**< @brief R component */ - inline constexpr T r() const { return Math::Vector4::x(); } /**< @overload */ - inline T& g() { return Math::Vector4::y(); } /**< @brief G component */ - inline constexpr T g() const { return Math::Vector4::y(); } /**< @overload */ - inline T& b() { return Math::Vector4::z(); } /**< @brief B component */ - inline constexpr T b() const { return Math::Vector4::z(); } /**< @overload */ - inline T& a() { return Math::Vector4::w(); } /**< @brief A component */ - inline constexpr T a() const { return Math::Vector4::w(); } /**< @overload */ + T& r() { return Math::Vector4::x(); } /**< @brief R component */ + constexpr T r() const { return Math::Vector4::x(); } /**< @overload */ + T& g() { return Math::Vector4::y(); } /**< @brief G component */ + constexpr T g() const { return Math::Vector4::y(); } /**< @overload */ + T& b() { return Math::Vector4::z(); } /**< @brief B component */ + constexpr T b() const { return Math::Vector4::z(); } /**< @overload */ + T& a() { return Math::Vector4::w(); } /**< @brief A component */ + constexpr T a() const { return Math::Vector4::w(); } /**< @overload */ /** * @brief RGB part of the vector @@ -352,26 +352,26 @@ class Color4: public Math::Vector4 { * * @see swizzle() */ - inline Color3& rgb() { return Color3::from(Math::Vector4::data()); } - inline constexpr Color3 rgb() const { return Color3::from(Math::Vector4::data()); } /**< @overload */ + Color3& rgb() { return Color3::from(Math::Vector4::data()); } + constexpr Color3 rgb() const { return Color3::from(Math::Vector4::data()); } /**< @overload */ /** @copydoc Color3::toHSV() */ - inline constexpr HSV toHSV() const { + constexpr HSV toHSV() const { return Implementation::toHSV(rgb()); } /** @copydoc Color3::hue() */ - inline constexpr Math::Deg hue() const { + constexpr Math::Deg hue() const { return Implementation::hue(rgb()); } /** @copydoc Color3::saturation() */ - inline constexpr FloatingPointType saturation() const { + constexpr FloatingPointType saturation() const { return Implementation::saturation(rgb()); } /** @copydoc Color3::value() */ - inline constexpr FloatingPointType value() const { + constexpr FloatingPointType value() const { return Implementation::value(rgb()); } diff --git a/src/Context.h b/src/Context.h index d48dab731..644b84ac8 100644 --- a/src/Context.h +++ b/src/Context.h @@ -109,13 +109,13 @@ class MAGNUM_EXPORT Extension { static const std::vector& extensions(Version version); /** @brief Minimal version required by this extension */ - inline constexpr Version requiredVersion() const { return _requiredVersion; } + constexpr Version requiredVersion() const { return _requiredVersion; } /** @brief Version in which this extension was adopted to core */ - inline constexpr Version coreVersion() const { return _coreVersion; } + constexpr Version coreVersion() const { return _coreVersion; } /** @brief %Extension string */ - inline constexpr const char* string() const { return _string; } + constexpr const char* string() const { return _string; } private: /* GCC 4.6 doesn't like const members, as std::vector doesn't have @@ -125,7 +125,7 @@ class MAGNUM_EXPORT Extension { Version _coreVersion; const char* _string; - inline constexpr Extension(std::size_t index, Version requiredVersion, Version coreVersion, const char* string): _index(index), _requiredVersion(requiredVersion), _coreVersion(coreVersion), _string(string) {} + constexpr Extension(std::size_t index, Version requiredVersion, Version coreVersion, const char* string): _index(index), _requiredVersion(requiredVersion), _coreVersion(coreVersion), _string(string) {} }; /** @@ -197,7 +197,7 @@ class MAGNUM_EXPORT Context { ~Context(); /** @brief Current context */ - inline static Context* current() { return _current; } + static Context* current() { return _current; } /** * @brief OpenGL version @@ -205,7 +205,7 @@ class MAGNUM_EXPORT Context { * @see majorVersion(), minorVersion(), versionString(), * shadingLanguageVersionString() */ - inline Version version() const { return _version; } + Version version() const { return _version; } /** * @brief Major OpenGL version (e.g. `4`) @@ -213,7 +213,7 @@ class MAGNUM_EXPORT Context { * @see minorVersion(), version(), versionString(), * shadingLanguageVersionString() */ - inline Int majorVersion() const { return _majorVersion; } + Int majorVersion() const { return _majorVersion; } /** * @brief Minor OpenGL version (e.g. `3`) @@ -221,7 +221,7 @@ class MAGNUM_EXPORT Context { * @see majorVersion(), version(), versionString(), * shadingLanguageVersionString() */ - inline Int minorVersion() const { return _minorVersion; } + Int minorVersion() const { return _minorVersion; } /** * @brief Vendor string @@ -230,7 +230,7 @@ class MAGNUM_EXPORT Context { * OpenGL calls. * @see rendererString(), @fn_gl{GetString} with @def_gl{VENDOR} */ - inline std::string vendorString() const { + std::string vendorString() const { return reinterpret_cast(glGetString(GL_VENDOR)); } @@ -241,7 +241,7 @@ class MAGNUM_EXPORT Context { * OpenGL calls. * @see vendorString(), @fn_gl{GetString} with @def_gl{RENDERER} */ - inline std::string rendererString() const { + std::string rendererString() const { return reinterpret_cast(glGetString(GL_RENDERER)); } @@ -253,7 +253,7 @@ class MAGNUM_EXPORT Context { * @see shadingLanguageVersionString(), version(), @fn_gl{GetString} * with @def_gl{VERSION} */ - inline std::string versionString() const { + std::string versionString() const { return reinterpret_cast(glGetString(GL_VERSION)); } @@ -265,7 +265,7 @@ class MAGNUM_EXPORT Context { * @see versionString(), version(), @fn_gl{GetString} with * @def_gl{SHADING_LANGUAGE_VERSION} */ - inline std::string shadingLanguageVersionString() const { + std::string shadingLanguageVersionString() const { return reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION)); } @@ -280,7 +280,7 @@ class MAGNUM_EXPORT Context { std::vector shadingLanguageVersionStrings() const; /** @brief Context flags */ - inline Flags flags() const { return _flags; } + Flags flags() const { return _flags; } /** * @brief Supported extensions @@ -290,7 +290,7 @@ class MAGNUM_EXPORT Context { * * @see isExtensionSupported(), Extension::extensions() */ - inline const std::vector& supportedExtensions() const { + const std::vector& supportedExtensions() const { return _supportedExtensions; } @@ -299,7 +299,7 @@ class MAGNUM_EXPORT Context { * * @see supportedVersion(), MAGNUM_ASSERT_VERSION_SUPPORTED() */ - inline bool isVersionSupported(Version version) const { + bool isVersionSupported(Version version) const { return _version >= version; } @@ -335,7 +335,7 @@ class MAGNUM_EXPORT Context { * @see isExtensionSupported(const Extension&) const, * MAGNUM_ASSERT_EXTENSION_SUPPORTED() */ - template inline bool isExtensionSupported() const { + template bool isExtensionSupported() const { return isVersionSupported(T::coreVersion()) || (isVersionSupported(T::requiredVersion()) && extensionStatus[T::Index]); } @@ -349,12 +349,12 @@ class MAGNUM_EXPORT Context { * @see supportedExtensions(), Extension::extensions(), * MAGNUM_ASSERT_EXTENSION_SUPPORTED() */ - inline bool isExtensionSupported(const Extension& extension) const { + bool isExtensionSupported(const Extension& extension) const { return isVersionSupported(extension._coreVersion) || (isVersionSupported(extension._requiredVersion) && extensionStatus[extension._index]); } #ifndef DOXYGEN_GENERATING_OUTPUT - inline Implementation::State* state() { return _state; } + Implementation::State* state() { return _state; } #endif private: diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index 61a6ccfcd..b9f99ba88 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -94,14 +94,14 @@ class CubeMapTexture: public AbstractTexture { * Creates one cube map OpenGL texture. * @see @fn_gl{GenTextures} with @def_gl{TEXTURE_CUBE_MAP} */ - inline explicit CubeMapTexture(): AbstractTexture(GL_TEXTURE_CUBE_MAP) {} + explicit CubeMapTexture(): AbstractTexture(GL_TEXTURE_CUBE_MAP) {} /** * @brief Set wrapping * * See Texture::setWrapping() for more information. */ - inline CubeMapTexture* setWrapping(const Array3D& wrapping) { + CubeMapTexture* setWrapping(const Array3D& wrapping) { DataHelper<3>::setWrapping(this, wrapping); return this; } @@ -115,7 +115,7 @@ class CubeMapTexture: public AbstractTexture { * See Texture::imageSize() for more information. * @requires_gl %Texture image queries are not available in OpenGL ES. */ - inline Vector2i imageSize(Coordinate coordinate, Int level) { + Vector2i imageSize(Coordinate coordinate, Int level) { return DataHelper<2>::imageSize(this, static_cast(coordinate), level); } #endif @@ -125,7 +125,7 @@ class CubeMapTexture: public AbstractTexture { * * See Texture::setStorage() for more information. */ - inline CubeMapTexture* setStorage(Int levels, TextureFormat internalFormat, const Vector2i& size) { + CubeMapTexture* setStorage(Int levels, TextureFormat internalFormat, const Vector2i& size) { DataHelper<2>::setStorage(this, _target, levels, internalFormat, size); return this; } @@ -140,7 +140,7 @@ class CubeMapTexture: public AbstractTexture { * See Texture::image(Int, Image*) for more information. * @requires_gl %Texture image queries are not available in OpenGL ES. */ - inline void image(Coordinate coordinate, Int level, Image2D* image) { + void image(Coordinate coordinate, Int level, Image2D* image) { AbstractTexture::image<2>(GLenum(coordinate), level, image); } @@ -155,7 +155,7 @@ class CubeMapTexture: public AbstractTexture { * information. * @requires_gl %Texture image queries are not available in OpenGL ES. */ - inline void image(Coordinate coordinate, Int level, BufferImage2D* image, Buffer::Usage usage) { + void image(Coordinate coordinate, Int level, BufferImage2D* image, Buffer::Usage usage) { AbstractTexture::image<2>(GLenum(coordinate), level, image, usage); } #endif @@ -171,7 +171,7 @@ class CubeMapTexture: public AbstractTexture { * * See Texture::setImage() for more information. */ - template inline CubeMapTexture* setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, Image* image) { + template CubeMapTexture* setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, Image* image) { DataHelper<2>::setImage(this, static_cast(coordinate), level, internalFormat, image); return this; } @@ -187,7 +187,7 @@ class CubeMapTexture: public AbstractTexture { * * See Texture::setSubImage() for more information. */ - template inline CubeMapTexture* setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const Image* image) { + template CubeMapTexture* setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const Image* image) { DataHelper<2>::setSubImage(this, static_cast(coordinate), level, offset, image); return this; } @@ -204,31 +204,31 @@ class CubeMapTexture: public AbstractTexture { * * See Texture::invalidateSubImage() for more information. */ - inline void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) { + void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) { DataHelper<3>::invalidateSubImage(this, level, offset, size); } /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - inline CubeMapTexture* setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap = Sampler::Mipmap::Base) { + CubeMapTexture* setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap = Sampler::Mipmap::Base) { AbstractTexture::setMinificationFilter(filter, mipmap); return this; } - inline CubeMapTexture* setMagnificationFilter(Sampler::Filter filter) { + CubeMapTexture* setMagnificationFilter(Sampler::Filter filter) { AbstractTexture::setMagnificationFilter(filter); return this; } #ifndef MAGNUM_TARGET_GLES3 - inline CubeMapTexture* setBorderColor(const Color4<>& color) { + CubeMapTexture* setBorderColor(const Color4<>& color) { AbstractTexture::setBorderColor(color); return this; } - inline CubeMapTexture* setMaxAnisotropy(Float anisotropy) { + CubeMapTexture* setMaxAnisotropy(Float anisotropy) { AbstractTexture::setMaxAnisotropy(anisotropy); return this; } #endif - inline CubeMapTexture* generateMipmap() { + CubeMapTexture* generateMipmap() { AbstractTexture::generateMipmap(); return this; } diff --git a/src/CubeMapTextureArray.h b/src/CubeMapTextureArray.h index 6ce6cad4d..e4e443a2d 100644 --- a/src/CubeMapTextureArray.h +++ b/src/CubeMapTextureArray.h @@ -98,14 +98,14 @@ class CubeMapTextureArray: public AbstractTexture { * Creates one cube map OpenGL texture. * @see @fn_gl{GenTextures} with @def_gl{TEXTURE_CUBE_MAP} */ - inline explicit CubeMapTextureArray(): AbstractTexture(GL_TEXTURE_CUBE_MAP_ARRAY) {} + explicit CubeMapTextureArray(): AbstractTexture(GL_TEXTURE_CUBE_MAP_ARRAY) {} /** * @brief Set wrapping * * See Texture::setWrapping() for more information. */ - inline CubeMapTextureArray* setWrapping(const Array3D& wrapping) { + CubeMapTextureArray* setWrapping(const Array3D& wrapping) { DataHelper<3>::setWrapping(this, wrapping); return this; } @@ -117,7 +117,7 @@ class CubeMapTextureArray: public AbstractTexture { * * See Texture::imageSize() for more information. */ - inline Vector3i imageSize(Coordinate coordinate, Int level) { + Vector3i imageSize(Coordinate coordinate, Int level) { return DataHelper<3>::imageSize(this, GL_TEXTURE_CUBE_MAP_POSITIVE_X + static_cast(coordinate), level); } @@ -126,7 +126,7 @@ class CubeMapTextureArray: public AbstractTexture { * * See Texture::setStorage() for more information. */ - inline CubeMapTextureArray* setStorage(Int levels, TextureFormat internalFormat, const Vector3i& size) { + CubeMapTextureArray* setStorage(Int levels, TextureFormat internalFormat, const Vector3i& size) { DataHelper<3>::setStorage(this, _target, levels, internalFormat, size); return this; } @@ -141,7 +141,7 @@ class CubeMapTextureArray: public AbstractTexture { * See Texture::image(Int, Image*) for more information. * @requires_gl %Texture image queries are not available in OpenGL ES. */ - inline void image(Coordinate coordinate, Int level, Image3D* image) { + void image(Coordinate coordinate, Int level, Image3D* image) { AbstractTexture::image<3>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level, image); } @@ -156,7 +156,7 @@ class CubeMapTextureArray: public AbstractTexture { * information. * @requires_gl %Texture image queries are not available in OpenGL ES. */ - inline void image(Coordinate coordinate, Int level, BufferImage3D* image, Buffer::Usage usage) { + void image(Coordinate coordinate, Int level, BufferImage3D* image, Buffer::Usage usage) { AbstractTexture::image<3>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level, image, usage); } #endif @@ -175,7 +175,7 @@ class CubeMapTextureArray: public AbstractTexture { * * See Texture::setImage() for more information. */ - template inline CubeMapTextureArray* setImage(Int level, TextureFormat internalFormat, T* image) { + template CubeMapTextureArray* setImage(Int level, TextureFormat internalFormat, T* image) { DataHelper<3>::setImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image); return this; } @@ -199,7 +199,7 @@ class CubeMapTextureArray: public AbstractTexture { * * @see setSubImage(Int, Coordinate, Int, const Math::Vector<2, Int>&, const Image*) */ - template inline CubeMapTextureArray* setSubImage(Int level, const Vector3i& offset, const Image* image) { + template CubeMapTextureArray* setSubImage(Int level, const Vector3i& offset, const Image* image) { DataHelper<3>::setSubImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, offset, image, Vector3i(Math::Vector())); return this; } @@ -218,7 +218,7 @@ class CubeMapTextureArray: public AbstractTexture { * * @see setSubImage(Int, const Math::Vector<3, Int>&, const Image*) */ - template inline CubeMapTextureArray* setSubImage(Int layer, Coordinate coordinate, Int level, const Vector2i& offset, const Image* image) { + template CubeMapTextureArray* setSubImage(Int layer, Coordinate coordinate, Int level, const Vector2i& offset, const Image* image) { DataHelper<3>::setSubImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, Vector3i(offset, layer*6+static_cast(coordinate)), image, Vector2i(Math::Vector())); return this; } @@ -235,31 +235,31 @@ class CubeMapTextureArray: public AbstractTexture { * * See Texture::invalidateSubImage() for more information. */ - inline void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) { + void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) { DataHelper<3>::invalidateSubImage(this, level, offset, size); } /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - inline CubeMapTextureArray* setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap = Sampler::Mipmap::Base) { + CubeMapTextureArray* setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap = Sampler::Mipmap::Base) { AbstractTexture::setMinificationFilter(filter, mipmap); return this; } - inline CubeMapTextureArray* setMagnificationFilter(Sampler::Filter filter) { + CubeMapTextureArray* setMagnificationFilter(Sampler::Filter filter) { AbstractTexture::setMagnificationFilter(filter); return this; } #ifndef MAGNUM_TARGET_GLES3 - inline CubeMapTextureArray* setBorderColor(const Color4<>& color) { + CubeMapTextureArray* setBorderColor(const Color4<>& color) { AbstractTexture::setBorderColor(color); return this; } - inline CubeMapTextureArray* setMaxAnisotropy(Float anisotropy) { + CubeMapTextureArray* setMaxAnisotropy(Float anisotropy) { AbstractTexture::setMaxAnisotropy(anisotropy); return this; } #endif - inline CubeMapTextureArray* generateMipmap() { + CubeMapTextureArray* generateMipmap() { AbstractTexture::generateMipmap(); return this; } diff --git a/src/DebugMarker.h b/src/DebugMarker.h index 3429c3c53..04bf3625a 100644 --- a/src/DebugMarker.h +++ b/src/DebugMarker.h @@ -53,7 +53,7 @@ class MAGNUM_EXPORT DebugMarker { DebugMarker() = delete; /** @brief Put string mark into OpenGL command stream */ - inline static void mark(const std::string& string) { + static void mark(const std::string& string) { markImplementation(string); } diff --git a/src/DefaultFramebuffer.h b/src/DefaultFramebuffer.h index c7ae2effc..8f0a38148 100644 --- a/src/DefaultFramebuffer.h +++ b/src/DefaultFramebuffer.h @@ -311,7 +311,7 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer { * @requires_gles30 Draw attachments for default framebuffer are * available only in OpenGL ES 3.0. */ - inline DefaultFramebuffer* mapForDraw(DrawAttachment attachment) { + DefaultFramebuffer* mapForDraw(DrawAttachment attachment) { (this->*drawBufferImplementation)(static_cast(attachment)); return this; } @@ -329,7 +329,7 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer { * @fn_gl_extension{FramebufferReadBuffer,EXT,direct_state_access} * @requires_gles30 %Extension @es_extension2{NV,read_buffer,GL_NV_read_buffer} */ - inline DefaultFramebuffer* mapForRead(ReadAttachment attachment) { + DefaultFramebuffer* mapForRead(ReadAttachment attachment) { (this->*readBufferImplementation)(static_cast(attachment)); return this; } @@ -367,7 +367,7 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer { /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - inline DefaultFramebuffer* setViewport(const Rectanglei& rectangle) { + DefaultFramebuffer* setViewport(const Rectanglei& rectangle) { AbstractFramebuffer::setViewport(rectangle); return this; } diff --git a/src/Framebuffer.h b/src/Framebuffer.h index 096d98752..e839d7488 100644 --- a/src/Framebuffer.h +++ b/src/Framebuffer.h @@ -114,10 +114,10 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @brief Constructor * @param id Color attachment id */ - inline constexpr explicit ColorAttachment(UnsignedInt id): attachment(GL_COLOR_ATTACHMENT0 + id) {} + constexpr explicit ColorAttachment(UnsignedInt id): attachment(GL_COLOR_ATTACHMENT0 + id) {} #ifndef DOXYGEN_GENERATING_OUTPUT - inline constexpr explicit operator GLenum() const { return attachment; } + constexpr explicit operator GLenum() const { return attachment; } #endif private: @@ -135,14 +135,14 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { static const DrawAttachment None; /** @brief Color attachment */ - inline constexpr /*implicit*/ DrawAttachment(Framebuffer::ColorAttachment attachment): attachment(GLenum(attachment)) {} + constexpr /*implicit*/ DrawAttachment(Framebuffer::ColorAttachment attachment): attachment(GLenum(attachment)) {} #ifndef DOXYGEN_GENERATING_OUTPUT - inline constexpr explicit operator GLenum() const { return attachment; } + constexpr explicit operator GLenum() const { return attachment; } #endif private: - inline constexpr explicit DrawAttachment(GLenum attachment): attachment(attachment) {} + constexpr explicit DrawAttachment(GLenum attachment): attachment(attachment) {} GLenum attachment; }; @@ -172,14 +172,14 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { #endif /** @brief Color buffer */ - inline constexpr /*implicit*/ BufferAttachment(Framebuffer::ColorAttachment attachment): attachment(GLenum(attachment)) {} + constexpr /*implicit*/ BufferAttachment(Framebuffer::ColorAttachment attachment): attachment(GLenum(attachment)) {} #ifndef DOXYGEN_GENERATING_OUTPUT - inline constexpr explicit operator GLenum() const { return attachment; } + constexpr explicit operator GLenum() const { return attachment; } #endif private: - inline constexpr explicit BufferAttachment(GLenum attachment): attachment(attachment) {} + constexpr explicit BufferAttachment(GLenum attachment): attachment(attachment) {} GLenum attachment; }; @@ -200,14 +200,14 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { static const InvalidationAttachment Stencil; /** @brief Invalidate color buffer */ - inline constexpr /*implicit*/ InvalidationAttachment(Framebuffer::ColorAttachment attachment): attachment(GLenum(attachment)) {} + constexpr /*implicit*/ InvalidationAttachment(Framebuffer::ColorAttachment attachment): attachment(GLenum(attachment)) {} #ifndef DOXYGEN_GENERATING_OUTPUT - inline constexpr explicit operator GLenum() const { return attachment; } + constexpr explicit operator GLenum() const { return attachment; } #endif private: - inline constexpr explicit InvalidationAttachment(GLenum attachment): attachment(attachment) {} + constexpr explicit InvalidationAttachment(GLenum attachment): attachment(attachment) {} GLenum attachment; }; @@ -266,7 +266,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @fn_gl{DrawBuffers} in OpenGL ES 3.0 * @requires_gles30 %Extension @es_extension2{NV,draw_buffers,GL_NV_draw_buffers} */ - inline Framebuffer* mapForDraw(DrawAttachment attachment) { + Framebuffer* mapForDraw(DrawAttachment attachment) { (this->*drawBufferImplementation)(GLenum(attachment)); return this; } @@ -314,7 +314,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @fn_gl_extension{FramebufferReadBuffer,EXT,direct_state_access} * @requires_gles30 %Extension @es_extension2{NV,read_buffer,GL_NV_read_buffer} */ - inline Framebuffer* mapForRead(ColorAttachment attachment) { + Framebuffer* mapForRead(ColorAttachment attachment) { (this->*readBufferImplementation)(GLenum(attachment)); return this; } @@ -331,7 +331,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @see @fn_gl{BindFramebuffer}, @fn_gl{FramebufferRenderbuffer} or * @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access} */ - inline Framebuffer* attachRenderbuffer(BufferAttachment attachment, Renderbuffer* renderbuffer) { + Framebuffer* attachRenderbuffer(BufferAttachment attachment, Renderbuffer* renderbuffer) { (this->*renderbufferImplementation)(attachment, renderbuffer); return this; } @@ -351,7 +351,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @fn_gl_extension{NamedFramebufferTexture1D,EXT,direct_state_access} * @requires_gl Only 2D and 3D textures are available in OpenGL ES. */ - inline Framebuffer* attachTexture1D(BufferAttachment attachment, Texture1D* texture, Int level) { + Framebuffer* attachTexture1D(BufferAttachment attachment, Texture1D* texture, Int level) { (this->*texture1DImplementation)(attachment, texture, level); return this; } @@ -386,7 +386,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @see attachTexture2D(), @fn_gl{BindFramebuffer}, @fn_gl{FramebufferTexture} * or @fn_gl_extension{NamedFramebufferTexture2D,EXT,direct_state_access} */ - inline Framebuffer* attachCubeMapTexture(BufferAttachment attachment, CubeMapTexture* texture, CubeMapTexture::Coordinate coordinate, Int level) { + Framebuffer* attachCubeMapTexture(BufferAttachment attachment, CubeMapTexture* texture, CubeMapTexture::Coordinate coordinate, Int level) { (this->*texture2DImplementation)(attachment, GLenum(coordinate), texture->id(), level); return this; } @@ -406,7 +406,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @fn_gl_extension{NamedFramebufferTexture3D,EXT,direct_state_access} * @requires_es_extension %Extension @es_extension{OES,texture_3D} */ - inline Framebuffer* attachTexture3D(BufferAttachment attachment, Texture3D* texture, Int level, Int layer) { + Framebuffer* attachTexture3D(BufferAttachment attachment, Texture3D* texture, Int level, Int layer) { /** @todo Check for texture target compatibility */ (this->*texture3DImplementation)(attachment, texture, level, layer); return this; @@ -414,7 +414,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - inline Framebuffer* setViewport(const Rectanglei& rectangle) { + Framebuffer* setViewport(const Rectanglei& rectangle) { AbstractFramebuffer::setViewport(rectangle); return this; } diff --git a/src/Image.h b/src/Image.h index 8c7055f63..54712ae18 100644 --- a/src/Image.h +++ b/src/Image.h @@ -55,7 +55,7 @@ template class Image: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - inline explicit Image(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + explicit Image(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** * @brief Constructor @@ -65,17 +65,17 @@ template class Image: public AbstractImage { * Dimensions and data pointer are set to zero, call setData() to fill * the image with data. */ - inline explicit Image(ImageFormat format, ImageType type): AbstractImage(format, type), _data(nullptr) {} + explicit Image(ImageFormat format, ImageType type): AbstractImage(format, type), _data(nullptr) {} /** @brief Destructor */ - inline ~Image() { delete[] _data; } + ~Image() { delete[] _data; } /** @brief %Image size */ - inline typename DimensionTraits::VectorType size() const { return _size; } + typename DimensionTraits::VectorType size() const { return _size; } /** @brief Pointer to raw data */ - inline unsigned char* data() { return _data; } - inline const unsigned char* data() const { return _data; } /**< @overload */ + unsigned char* data() { return _data; } + const unsigned char* data() const { return _data; } /**< @overload */ /** * @brief Set image data diff --git a/src/ImageWrapper.h b/src/ImageWrapper.h index bc0f87beb..8acbd16ac 100644 --- a/src/ImageWrapper.h +++ b/src/ImageWrapper.h @@ -62,7 +62,7 @@ template class ImageWrapper: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - inline explicit ImageWrapper(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + explicit ImageWrapper(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** * @brief Constructor @@ -73,14 +73,14 @@ template class ImageWrapper: public AbstractImage { * Data pointer is set to zero, call setData() to fill the image with * data. */ - inline explicit ImageWrapper(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type): AbstractImage(format, type), _size(size), _data(nullptr) {} + explicit ImageWrapper(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type): AbstractImage(format, type), _size(size), _data(nullptr) {} /** @brief %Image size */ - inline typename DimensionTraits::VectorType size() const { return _size; } + typename DimensionTraits::VectorType size() const { return _size; } /** @brief Pointer to raw data */ - inline unsigned char* data() { return _data; } - inline const unsigned char* data() const { return _data; } /**< @overload */ + unsigned char* data() { return _data; } + const unsigned char* data() const { return _data; } /**< @overload */ /** * @brief Set image data @@ -90,7 +90,7 @@ template class ImageWrapper: public AbstractImage { * passed in constructor. The data are not copied nor deleted on * destruction. */ - inline void setData(void* data) { + void setData(void* data) { _data = reinterpret_cast(data); } diff --git a/src/Implementation/BufferState.h b/src/Implementation/BufferState.h index 0378d8d6b..5c69f7201 100644 --- a/src/Implementation/BufferState.h +++ b/src/Implementation/BufferState.h @@ -43,7 +43,7 @@ struct BufferState { static std::size_t indexForTarget(Buffer::Target target); static const Buffer::Target targetForIndex[TargetCount-1]; - inline constexpr BufferState(): bindings() {} + constexpr BufferState(): bindings() {} /* Currently bound buffer for all targets */ GLuint bindings[TargetCount]; diff --git a/src/Implementation/FramebufferState.h b/src/Implementation/FramebufferState.h index e9748c788..f8c2d5ba4 100644 --- a/src/Implementation/FramebufferState.h +++ b/src/Implementation/FramebufferState.h @@ -31,7 +31,7 @@ namespace Magnum { namespace Implementation { struct FramebufferState { - inline constexpr FramebufferState(): readBinding(0), drawBinding(0), renderbufferBinding(0) {} + constexpr FramebufferState(): readBinding(0), drawBinding(0), renderbufferBinding(0) {} GLuint readBinding, drawBinding, renderbufferBinding; Rectanglei viewport; diff --git a/src/Implementation/MeshState.h b/src/Implementation/MeshState.h index b12b1c5ae..e7c79ca6c 100644 --- a/src/Implementation/MeshState.h +++ b/src/Implementation/MeshState.h @@ -29,7 +29,7 @@ namespace Magnum { namespace Implementation { struct MeshState { - inline constexpr MeshState(): currentVAO(0) {} + constexpr MeshState(): currentVAO(0) {} GLuint currentVAO; }; diff --git a/src/Implementation/RendererState.h b/src/Implementation/RendererState.h index 8d1eb2287..3092f9165 100644 --- a/src/Implementation/RendererState.h +++ b/src/Implementation/RendererState.h @@ -29,7 +29,7 @@ namespace Magnum { namespace Implementation { struct RendererState { - inline constexpr RendererState() + constexpr RendererState() #ifndef MAGNUM_TARGET_GLES3 : resetNotificationStrategy() #endif diff --git a/src/Implementation/ShaderProgramState.h b/src/Implementation/ShaderProgramState.h index 3dc2e5513..a3c02205d 100644 --- a/src/Implementation/ShaderProgramState.h +++ b/src/Implementation/ShaderProgramState.h @@ -29,7 +29,7 @@ namespace Magnum { namespace Implementation { struct ShaderProgramState { - inline constexpr ShaderProgramState(): current(0), maxSupportedVertexAttributeCount(0) {} + constexpr ShaderProgramState(): current(0), maxSupportedVertexAttributeCount(0) {} /* Currently used program */ GLuint current; diff --git a/src/Mesh.h b/src/Mesh.h index 014c423ad..2db8523d9 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -362,7 +362,7 @@ class MAGNUM_EXPORT Mesh { Mesh& operator=(Mesh&& other); /** @brief Primitive type */ - inline Primitive primitive() const { return _primitive; } + Primitive primitive() const { return _primitive; } /** * @brief Set primitive type @@ -372,13 +372,13 @@ class MAGNUM_EXPORT Mesh { * @see setVertexCount(), addVertexBuffer(), * addInterleavedVertexBuffer(), addVertexBufferStride() */ - inline Mesh* setPrimitive(Primitive primitive) { + Mesh* setPrimitive(Primitive primitive) { _primitive = primitive; return this; } /** @brief Vertex count */ - inline Int vertexCount() const { return _vertexCount; } + Int vertexCount() const { return _vertexCount; } /** * @brief Set vertex count @@ -388,13 +388,13 @@ class MAGNUM_EXPORT Mesh { * @see setPrimitive(), addVertexBuffer(), addInterleavedVertexBuffer(), * addVertexBufferStride(), MeshTools::interleave() */ - inline Mesh* setVertexCount(Int vertexCount) { + Mesh* setVertexCount(Int vertexCount) { _vertexCount = vertexCount; return this; } /** @brief Index count */ - inline Int indexCount() const { return _indexCount; } + Int indexCount() const { return _indexCount; } /** * @brief Set index count @@ -403,7 +403,7 @@ class MAGNUM_EXPORT Mesh { * Default is zero. * @see setIndexBuffer(), MeshTools::compressIndices() */ - inline Mesh* setIndexCount(Int count) { + Mesh* setIndexCount(Int count) { _indexCount = count; return this; } @@ -457,13 +457,7 @@ class MAGNUM_EXPORT Mesh { * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} * if @extension{APPLE,vertex_array_object} is available */ - template inline Mesh* addVertexBuffer(Buffer* buffer, GLintptr offset, const T&... attributes) { - CORRADE_ASSERT(sizeof...(attributes) == 1 || _vertexCount != 0, - "Mesh::addVertexBuffer(): vertex count must be set before binding attributes", this); - - addVertexBufferInternal(buffer, offset, attributes...); - return this; - } + template Mesh* addVertexBuffer(Buffer* buffer, GLintptr offset, const T&... attributes); /** * @brief Add buffer with interleaved vertex attributes for use with given shader @@ -574,7 +568,7 @@ class MAGNUM_EXPORT Mesh { * @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if * @extension{APPLE,vertex_array_object} is available) */ - inline Mesh* setIndexBuffer(Buffer* buffer, GLintptr offset, IndexType type) { + Mesh* setIndexBuffer(Buffer* buffer, GLintptr offset, IndexType type) { return setIndexBuffer(buffer, offset, type, 0, 0); } @@ -789,6 +783,15 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::Primitive value); /** @debugoperator{Magnum::Mesh} */ Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value); +template inline Mesh* Mesh::addVertexBuffer(Buffer* buffer, GLintptr offset, const T&... attributes) { + CORRADE_ASSERT(sizeof...(attributes) == 1 || _vertexCount != 0, + "Mesh::addVertexBuffer(): vertex count must be set before binding attributes", this); + + addVertexBufferInternal(buffer, offset, attributes...); + return this; +} + + } namespace Corrade { namespace Utility { diff --git a/src/Query.h b/src/Query.h index 4a68c50f1..7433d30fe 100644 --- a/src/Query.h +++ b/src/Query.h @@ -66,7 +66,7 @@ class MAGNUM_EXPORT AbstractQuery { #endif /** @brief OpenGL query ID */ - inline GLuint id() const { return _id; } + GLuint id() const { return _id; } /** * @brief Whether the result is available @@ -172,7 +172,7 @@ class PrimitiveQuery: public AbstractQuery { * Begins counting of given @p target until end() is called. * @see @fn_gl{BeginQuery} */ - inline void begin(Target target) { + void begin(Target target) { AbstractQuery::begin(GLenum(target)); } }; @@ -285,7 +285,7 @@ class SampleQuery: public AbstractQuery { #endif /** @copydoc PrimitiveQuery::begin() */ - inline void begin(Target target) { + void begin(Target target) { AbstractQuery::begin(GLenum(target)); } @@ -297,7 +297,7 @@ class SampleQuery: public AbstractQuery { * @requires_gl30 %Extension @extension{NV,conditional_render} * @requires_gl Conditional rendering is not available in OpenGL ES. */ - inline void beginConditionalRender(ConditionalRenderMode mode) { + void beginConditionalRender(ConditionalRenderMode mode) { glBeginConditionalRender(id(), static_cast(mode)); } @@ -308,7 +308,7 @@ class SampleQuery: public AbstractQuery { * @requires_gl30 %Extension @extension{NV,conditional_render} * @requires_gl Conditional rendering is not available in OpenGL ES. */ - inline void endConditionalRender() { + void endConditionalRender() { glEndConditionalRender(); } #endif @@ -366,7 +366,7 @@ class TimeQuery: public AbstractQuery { * * @see @fn_gl{QueryCounter} with @def_gl{TIMESTAMP} */ - inline void timestamp() { + void timestamp() { /** @todo Enable when extension wrangler for ES is available */ #ifndef MAGNUM_TARGET_GLES glQueryCounter(id(), GL_TIMESTAMP); @@ -377,7 +377,7 @@ class TimeQuery: public AbstractQuery { } /** @copydoc PrimitiveQuery::begin() */ - inline void begin(Target target) { + void begin(Target target) { AbstractQuery::begin(GLenum(target)); } }; diff --git a/src/Renderbuffer.h b/src/Renderbuffer.h index 916ec4f14..f35ac0bac 100644 --- a/src/Renderbuffer.h +++ b/src/Renderbuffer.h @@ -66,9 +66,7 @@ class MAGNUM_EXPORT Renderbuffer { * Generates new OpenGL renderbuffer. * @see @fn_gl{GenRenderbuffers} */ - inline explicit Renderbuffer() { - glGenRenderbuffers(1, &_id); - } + explicit Renderbuffer() { glGenRenderbuffers(1, &_id); } /** * @brief Destructor @@ -79,7 +77,7 @@ class MAGNUM_EXPORT Renderbuffer { ~Renderbuffer(); /** @brief OpenGL internal renderbuffer ID */ - inline GLuint id() const { return _id; } + GLuint id() const { return _id; } /** * @brief Set renderbuffer storage @@ -92,7 +90,7 @@ class MAGNUM_EXPORT Renderbuffer { * @see @fn_gl{BindRenderbuffer}, @fn_gl{RenderbufferStorage} or * @fn_gl_extension{NamedRenderbufferStorage,EXT,direct_state_access} */ - inline void setStorage(RenderbufferFormat internalFormat, const Vector2i& size) { + void setStorage(RenderbufferFormat internalFormat, const Vector2i& size) { (this->*storageImplementation)(internalFormat, size); } @@ -112,7 +110,7 @@ class MAGNUM_EXPORT Renderbuffer { * or @es_extension{NV,framebuffer_multisample} * @todo How about @es_extension{APPLE,framebuffer_multisample}? */ - inline void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size) { + void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size) { (this->*storageMultisampleImplementation)(samples, internalFormat, size); } diff --git a/src/Renderer.h b/src/Renderer.h index af1716b5f..f93f8672c 100644 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -231,7 +231,7 @@ class MAGNUM_EXPORT Renderer { * If OpenGL ES, OpenGL 4.1 or extension @extension{ARB,ES2_compatibility} * is not available, this function behaves exactly as setClearDepth(Double). */ - inline static void setClearDepth(Float depth) { + static void setClearDepth(Float depth) { clearDepthfImplementation(depth); } @@ -824,9 +824,7 @@ class MAGNUM_EXPORT Renderer { * * @see finish(), @fn_gl{Flush} */ - inline static void flush() { - glFlush(); - } + static void flush() { glFlush(); } /** * @brief Finish the pipeline @@ -834,9 +832,7 @@ class MAGNUM_EXPORT Renderer { * Blocks until all commands in the pipeline are finished. * @see flush(), @fn_gl{Finish} */ - inline static void finish() { - glFinish(); - } + static void finish() { glFinish(); } #ifndef MAGNUM_TARGET_GLES3 /** @@ -922,7 +918,7 @@ class MAGNUM_EXPORT Renderer { * @ref GraphicsResetStatus "GraphicsResetStatus::NoError". * @see resetNotificationStrategy(), @fn_gl_extension{GetGraphicsResetStatus,ARB,robustness} */ - inline static GraphicsResetStatus graphicsResetStatus() { + static GraphicsResetStatus graphicsResetStatus() { return graphicsResetStatusImplementation(); } #endif diff --git a/src/Resource.h b/src/Resource.h index e79d77ad0..cf71f7998 100644 --- a/src/Resource.h +++ b/src/Resource.h @@ -86,16 +86,16 @@ class ResourceKey: public Utility::MurmurHash2::Digest { * Creates zero key. Note that it is not the same as calling other * constructors with empty string. */ - inline constexpr ResourceKey() {} + constexpr ResourceKey() {} /** @brief Constructor */ - inline ResourceKey(const std::string& key): Utility::MurmurHash2::Digest(Utility::MurmurHash2()(key)) {} + ResourceKey(const std::string& key): Utility::MurmurHash2::Digest(Utility::MurmurHash2()(key)) {} /** * @brief Constructor * @todo constexpr */ - template inline constexpr ResourceKey(const char(&key)[size]): Utility::MurmurHash2::Digest(Utility::MurmurHash2()(key)) {} + template constexpr ResourceKey(const char(&key)[size]): Utility::MurmurHash2::Digest(Utility::MurmurHash2()(key)) {} }; /** @debugoperator{Magnum::ResourceKey} */ @@ -112,10 +112,10 @@ namespace Implementation { See ResourceManager for more information. */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else +#ifdef DOXYGEN_GENERATING_OUTPUT template +#else +template #endif class Resource { friend class Implementation::ResourceManagerData; @@ -127,60 +127,39 @@ class Resource { * Creates empty resource. Resources are acquired from the manager by * calling ResourceManager::get(). */ - inline explicit Resource(): manager(nullptr), lastCheck(0), _state(ResourceState::Final), data(nullptr) {} + explicit Resource(): manager(nullptr), lastCheck(0), _state(ResourceState::Final), data(nullptr) {} /** @brief Copy constructor */ - inline Resource(const Resource& other): manager(other.manager), _key(other._key), lastCheck(other.lastCheck), _state(other._state), data(other.data) { + Resource(const Resource& other): manager(other.manager), _key(other._key), lastCheck(other.lastCheck), _state(other._state), data(other.data) { if(manager) manager->incrementReferenceCount(_key); } /** @brief Move constructor */ - inline Resource(Resource&& other): manager(other.manager), _key(other._key), lastCheck(other.lastCheck), _state(other._state), data(other.data) { + Resource(Resource&& other): manager(other.manager), _key(other._key), lastCheck(other.lastCheck), _state(other._state), data(other.data) { + /** @brief Make other's state well-defined */ other.manager = nullptr; } /** @brief Destructor */ - inline ~Resource() { + ~Resource() { if(manager) manager->decrementReferenceCount(_key); } - /** @brief Assignment operator */ - Resource& operator=(const Resource& other) { - if(manager) manager->decrementReferenceCount(_key); + /** @brief Copy assignment */ + Resource& operator=(const Resource& other); - manager = other.manager; - _key = other._key; - lastCheck = other.lastCheck; - _state = other._state; - data = other.data; - - if(manager) manager->incrementReferenceCount(_key); - return *this; - } - - /** @brief Assignment move operator */ - Resource& operator=(Resource&& other) { - if(manager) manager->decrementReferenceCount(_key); - - manager = other.manager; - _key = other._key; - lastCheck = other.lastCheck; - _state = other._state; - data = other.data; - - other.manager = nullptr; - return *this; - } + /** @brief Move assignment */ + Resource& operator=(Resource&& other); /** @brief Resource key */ - inline ResourceKey key() const { return _key; } + ResourceKey key() const { return _key; } /** * @brief %Resource state * * @see operator bool(), ResourceManager::state() */ - inline ResourceState state() { + ResourceState state() { acquire(); return _state; } @@ -193,7 +172,7 @@ class Resource { * @ref ResourceState "ResourceState::Loading" or * @ref ResourceState "ResourceState::NotFound"), true otherwise. */ - inline operator bool() { + operator bool() { acquire(); return data; } @@ -204,61 +183,32 @@ class Resource { * The resource must be loaded before accessing it. Use boolean * conversion operator or state() for testing whether it is loaded. */ - inline operator U*() { + operator U*() { acquire(); CORRADE_ASSERT(data, "Resource: accessing not loaded data with key" << key(), nullptr); return static_cast(data); } /** @overload */ - inline U* operator->() { + U* operator->() { acquire(); CORRADE_ASSERT(data, "Resource: accessing not loaded data with key" << key(), nullptr); return static_cast(data); } /** @overload */ - inline U& operator*() { + U& operator*() { acquire(); CORRADE_ASSERT(data, "Resource: accessing not loaded data with key" << key(), *static_cast(data)); return *static_cast(data); } private: - inline Resource(Implementation::ResourceManagerData* manager, ResourceKey key): manager(manager), _key(key), lastCheck(0), _state(ResourceState::NotLoaded), data(nullptr) { + Resource(Implementation::ResourceManagerData* manager, ResourceKey key): manager(manager), _key(key), lastCheck(0), _state(ResourceState::NotLoaded), data(nullptr) { manager->incrementReferenceCount(key); } - void acquire() { - /* The data are already final, nothing to do */ - if(_state == ResourceState::Final) return; - - /* Nothing changed since last check */ - if(manager->lastChange() < lastCheck) return; - - /* Acquire new data and save last check time */ - const typename Implementation::ResourceManagerData::Data& d = manager->data(_key); - lastCheck = manager->lastChange(); - - /* Try to get the data */ - data = d.data; - _state = static_cast(d.state); - - /* Data are not available */ - if(!data) { - /* Fallback found, add *Fallback to state */ - if((data = manager->fallback())) { - if(_state == ResourceState::Loading) - _state = ResourceState::LoadingFallback; - else if(_state == ResourceState::NotFound) - _state = ResourceState::NotFoundFallback; - else _state = ResourceState::NotLoadedFallback; - - /* Fallback not found and loading didn't start yet */ - } else if(_state != ResourceState::Loading && _state != ResourceState::NotFound) - _state = ResourceState::NotLoaded; - } - } + void acquire(); Implementation::ResourceManagerData* manager; ResourceKey _key; @@ -267,6 +217,64 @@ class Resource { T* data; }; +template Resource& Resource::operator=(const Resource& other) { + if(manager) manager->decrementReferenceCount(_key); + + manager = other.manager; + _key = other._key; + lastCheck = other.lastCheck; + _state = other._state; + data = other.data; + + if(manager) manager->incrementReferenceCount(_key); + return *this; +} + +template Resource& Resource::operator=(Resource&& other) { + /** @todo Just swap the values */ + if(manager) manager->decrementReferenceCount(_key); + + manager = other.manager; + _key = other._key; + lastCheck = other.lastCheck; + _state = other._state; + data = other.data; + + other.manager = nullptr; + return *this; +} + +template void Resource::acquire() { + /* The data are already final, nothing to do */ + if(_state == ResourceState::Final) return; + + /* Nothing changed since last check */ + if(manager->lastChange() < lastCheck) return; + + /* Acquire new data and save last check time */ + const typename Implementation::ResourceManagerData::Data& d = manager->data(_key); + lastCheck = manager->lastChange(); + + /* Try to get the data */ + data = d.data; + _state = static_cast(d.state); + + /* Data are not available */ + if(!data) { + /* Fallback found, add *Fallback to state */ + if((data = manager->fallback())) { + if(_state == ResourceState::Loading) + _state = ResourceState::LoadingFallback; + else if(_state == ResourceState::NotFound) + _state = ResourceState::NotFoundFallback; + else _state = ResourceState::NotLoadedFallback; + + /* Fallback not found and loading didn't start yet */ + } else if(_state != ResourceState::Loading && _state != ResourceState::NotFound) + _state = ResourceState::NotLoaded; + } +} + } /* Make the definition complete */ diff --git a/src/ResourceManager.h b/src/ResourceManager.h index cfd9c90de..8038ff458 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -90,185 +90,69 @@ enum class ResourcePolicy: UnsignedByte { template class AbstractResourceLoader; namespace Implementation { - struct ResourceKeyHash { - inline std::size_t operator()(ResourceKey key) const { - return *reinterpret_cast(key.byteArray()); + +struct ResourceKeyHash { + std::size_t operator()(ResourceKey key) const { + return *reinterpret_cast(key.byteArray()); + } +}; + +template class ResourceManagerData { + template friend class Magnum::Resource; + friend class AbstractResourceLoader; + + ResourceManagerData(const ResourceManagerData&) = delete; + ResourceManagerData(ResourceManagerData&&) = delete; + ResourceManagerData& operator=(const ResourceManagerData&) = delete; + ResourceManagerData& operator=(ResourceManagerData&&) = delete; + + public: + virtual ~ResourceManagerData(); + + std::size_t lastChange() const { return _lastChange; } + + std::size_t count() const { return _data.size(); } + + std::size_t referenceCount(ResourceKey key) const; + + ResourceState state(ResourceKey key) const; + + template Resource get(ResourceKey key); + + void set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy); + + T* fallback() { return _fallback; } + const T* fallback() const { return _fallback; } + + void setFallback(T* data); + + void free(); + + AbstractResourceLoader* loader() { return _loader; } + const AbstractResourceLoader* loader() const { return _loader; } + + void setLoader(AbstractResourceLoader* loader); + + protected: + ResourceManagerData(): _fallback(nullptr), _loader(nullptr), _lastChange(0) {} + + private: + struct Data; + + const Data& data(ResourceKey key) { return _data[key]; } + + void incrementReferenceCount(ResourceKey key) { + ++_data[key].referenceCount; } - }; - - template class ResourceManagerData { - template friend class Magnum::Resource; - friend class AbstractResourceLoader; - - ResourceManagerData(const ResourceManagerData&) = delete; - ResourceManagerData(ResourceManagerData&&) = delete; - ResourceManagerData& operator=(const ResourceManagerData&) = delete; - ResourceManagerData& operator=(ResourceManagerData&&) = delete; - - public: - inline virtual ~ResourceManagerData() { - delete _fallback; - - if(_loader) { - _loader->manager = nullptr; - delete _loader; - } - } - - inline std::size_t lastChange() const { return _lastChange; } - - inline std::size_t count() const { return _data.size(); } - - std::size_t referenceCount(ResourceKey key) const { - auto it = _data.find(key); - if(it == _data.end()) return 0; - return it->second.referenceCount; - } - - ResourceState state(ResourceKey key) const { - auto it = _data.find(key); - - /* Resource not loaded */ - if(it == _data.end() || !it->second.data) { - /* Fallback found, add *Fallback to state */ - if(_fallback) { - if(it != _data.end() && it->second.state == ResourceDataState::Loading) - return ResourceState::LoadingFallback; - else if(it != _data.end() && it->second.state == ResourceDataState::NotFound) - return ResourceState::NotFoundFallback; - else return ResourceState::NotLoadedFallback; - } - - /* Fallback not found, loading didn't start yet */ - if(it == _data.end() || (it->second.state != ResourceDataState::Loading && it->second.state != ResourceDataState::NotFound)) - return ResourceState::NotLoaded; - } - - /* Loading / NotFound without fallback, Mutable / Final */ - return static_cast(it->second.state); - } - - template inline Resource get(ResourceKey key) { - /* Ask loader for the data, if they aren't there yet */ - if(_loader && _data.find(key) == _data.end()) - _loader->load(key); - - return Resource(this, key); - } - - void set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy) { - auto it = _data.find(key); - - /* NotFound / Loading state shouldn't have any data */ - CORRADE_ASSERT((data == nullptr) == (state == ResourceDataState::NotFound || state == ResourceDataState::Loading), - "ResourceManager::set(): data should be null if and only if state is NotFound or Loading", ); - - /* Cannot change resource with already final state */ - CORRADE_ASSERT(it == _data.end() || it->second.state != ResourceDataState::Final, - "ResourceManager::set(): cannot change already final resource" << key, ); - - /* If nothing is referencing reference-counted resource, we're done */ - if(policy == ResourcePolicy::ReferenceCounted && (it == _data.end() || it->second.referenceCount == 0)) { - Warning() << "ResourceManager: Reference-counted resource with key" << key << "isn't referenced from anywhere, deleting it immediately"; - delete data; - - /* Delete also already present resource (it could be here - because previous policy could be other than - ReferenceCounted) */ - if(it != _data.end()) _data.erase(it); - - return; - - /* Insert it, if not already here */ - } else if(it == _data.end()) - it = _data.insert(std::make_pair(key, Data())).first; - - /* Replace previous data */ - delete it->second.data; - it->second.data = data; - it->second.state = state; - it->second.policy = policy; - ++_lastChange; - } - - inline T* fallback() { return _fallback; } - inline const T* fallback() const { return _fallback; } - - inline void setFallback(T* data) { - delete _fallback; - _fallback = data; - } - - void free() { - /* Delete all non-referenced non-resident resources */ - for(auto it = _data.begin(); it != _data.end(); ) { - if(it->second.policy != ResourcePolicy::Resident && !it->second.referenceCount) - it = _data.erase(it); - else ++it; - } - } - - inline AbstractResourceLoader* loader() { return _loader; } - inline const AbstractResourceLoader* loader() const { return _loader; } - - inline void setLoader(AbstractResourceLoader* loader) { - /* Delete previous loader */ - delete _loader; - - /* Add new loader */ - _loader = loader; - if(_loader) _loader->manager = this; - } - - protected: - inline ResourceManagerData(): _fallback(nullptr), _loader(nullptr), _lastChange(0) {} - - private: - struct Data { - Data(const Data&) = delete; - Data& operator=(const Data&) = delete; - Data& operator=(Data&&) = delete; - - inline Data(): data(nullptr), state(ResourceDataState::Mutable), policy(ResourcePolicy::Manual), referenceCount(0) {} - - inline Data(Data&& other): data(other.data), state(other.state), policy(other.policy), referenceCount(other.referenceCount) { - other.data = nullptr; - other.referenceCount = 0; - } - - inline ~Data() { - CORRADE_ASSERT(referenceCount == 0, - "ResourceManager::~ResourceManager(): destroyed while data are still referenced", ); - delete data; - } - - T* data; - ResourceDataState state; - ResourcePolicy policy; - std::size_t referenceCount; - }; - - inline const Data& data(ResourceKey key) { - return _data[key]; - } - - inline void incrementReferenceCount(ResourceKey key) { - ++_data[key].referenceCount; - } - - inline void decrementReferenceCount(ResourceKey key) { - auto it = _data.find(key); - - /* Free the resource if it is reference counted */ - if(--it->second.referenceCount == 0 && it->second.policy == ResourcePolicy::ReferenceCounted) - _data.erase(it); - } - - std::unordered_map _data; - T* _fallback; - AbstractResourceLoader* _loader; - std::size_t _lastChange; - }; + + void decrementReferenceCount(ResourceKey key); + + std::unordered_map _data; + T* _fallback; + AbstractResourceLoader* _loader; + std::size_t _lastChange; +}; + } /** @@ -342,10 +226,7 @@ cube->draw(); template class ResourceManager: private Implementation::ResourceManagerData... { public: /** @brief Global instance */ - inline static ResourceManager* instance() { - CORRADE_ASSERT(internalInstance(), "ResourceManager::instance(): no instance exists", nullptr); - return internalInstance(); - } + static ResourceManager* instance(); /** * @brief Constructor @@ -355,10 +236,7 @@ template class ResourceManager: private Implementation::Resource * created. * @see instance() */ - inline ResourceManager() { - CORRADE_ASSERT(!internalInstance(), "ResourceManager::ResourceManager(): another instance is already created", ); - internalInstance() = this; - } + explicit ResourceManager(); /** * @brief Destructor @@ -366,13 +244,10 @@ template class ResourceManager: private Implementation::Resource * Sets global instance pointer to `nullptr`. * @see instance() */ - inline ~ResourceManager() { - CORRADE_INTERNAL_ASSERT(internalInstance() == this); - internalInstance() = nullptr; - } + ~ResourceManager(); /** @brief Count of resources of given type */ - template inline std::size_t count() { + template std::size_t count() { return this->Implementation::ResourceManagerData::count(); } @@ -388,7 +263,7 @@ template class ResourceManager: private Implementation::Resource * Resource shader = manager->get("shader"); * @endcode */ - template inline Resource get(ResourceKey key) { + template Resource get(ResourceKey key) { return this->Implementation::ResourceManagerData::template get(key); } @@ -397,7 +272,7 @@ template class ResourceManager: private Implementation::Resource * * @see set() */ - template inline std::size_t referenceCount(ResourceKey key) const { + template std::size_t referenceCount(ResourceKey key) const { return this->Implementation::ResourceManagerData::referenceCount(key); } @@ -406,7 +281,7 @@ template class ResourceManager: private Implementation::Resource * * @see set(), Resource::state() */ - template inline ResourceState state(ResourceKey key) const { + template ResourceState state(ResourceKey key) const { return this->Implementation::ResourceManagerData::state(key); } @@ -429,7 +304,7 @@ template class ResourceManager: private Implementation::Resource * subsequent updates are not possible. * @see referenceCount(), state() */ - template inline ResourceManager* set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy) { + template ResourceManager* set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy) { this->Implementation::ResourceManagerData::set(key, data, state, policy); return this; } @@ -441,18 +316,18 @@ template class ResourceManager: private Implementation::Resource * Same as above function with state set to @ref ResourceDataState "ResourceDataState::Final" * and policy to @ref ResourcePolicy "ResourcePolicy::Resident". */ - template inline ResourceManager* set(ResourceKey key, T* data) { + template ResourceManager* set(ResourceKey key, T* data) { this->Implementation::ResourceManagerData::set(key, data, ResourceDataState::Final, ResourcePolicy::Resident); return this; } /** @brief Fallback for not found resources */ - template inline T* fallback() { + template T* fallback() { return this->Implementation::ResourceManagerData::fallback(); } /** @overload */ - template inline const T* fallback() const { + template const T* fallback() const { return this->Implementation::ResourceManagerData::fallback(); } @@ -460,7 +335,7 @@ template class ResourceManager: private Implementation::Resource * @brief Set fallback for not found resources * @return Pointer to self (for method chaining) */ - template inline ResourceManager* setFallback(T* data) { + template ResourceManager* setFallback(T* data) { this->Implementation::ResourceManagerData::setFallback(data); return this; } @@ -469,7 +344,7 @@ template class ResourceManager: private Implementation::Resource * @brief Free all resources of given type which are not referenced * @return Pointer to self (for method chaining) */ - template inline ResourceManager* free() { + template ResourceManager* free() { this->Implementation::ResourceManagerData::free(); return this; } @@ -478,18 +353,18 @@ template class ResourceManager: private Implementation::Resource * @brief Free all resources which are not referenced * @return Pointer to self (for method chaining) */ - inline ResourceManager* free() { + ResourceManager* free() { freeInternal(std::common_type()...); return this; } /** @brief Loader for given type of resources */ - template inline AbstractResourceLoader* loader() { + template AbstractResourceLoader* loader() { return this->Implementation::ResourceManagerData::loader(); } /** @overload */ - template inline const AbstractResourceLoader* loader() const { + template const AbstractResourceLoader* loader() const { return this->Implementation::ResourceManagerData::loader(); } @@ -499,17 +374,17 @@ template class ResourceManager: private Implementation::Resource * * See AbstractResourceLoader documentation for more information. */ - template inline ResourceManager* setLoader(AbstractResourceLoader* loader) { + template ResourceManager* setLoader(AbstractResourceLoader* loader) { this->Implementation::ResourceManagerData::setLoader(loader); return this; } private: - template inline void freeInternal(std::common_type, std::common_type... t) { + template void freeInternal(std::common_type, std::common_type... t) { free(); freeInternal(t...); } - inline void freeInternal() const {} + void freeInternal() const {} static ResourceManager*& internalInstance(); }; @@ -521,6 +396,162 @@ template ResourceManager*& ResourceManager:: } #endif +namespace Implementation { + +template ResourceManagerData::~ResourceManagerData() { + delete _fallback; + + if(_loader) { + _loader->manager = nullptr; + delete _loader; + } +} + +template std::size_t ResourceManagerData::referenceCount(const ResourceKey key) const { + auto it = _data.find(key); + if(it == _data.end()) return 0; + return it->second.referenceCount; +} + +template ResourceState ResourceManagerData::state(const ResourceKey key) const { + const auto it = _data.find(key); + + /* Resource not loaded */ + if(it == _data.end() || !it->second.data) { + /* Fallback found, add *Fallback to state */ + if(_fallback) { + if(it != _data.end() && it->second.state == ResourceDataState::Loading) + return ResourceState::LoadingFallback; + else if(it != _data.end() && it->second.state == ResourceDataState::NotFound) + return ResourceState::NotFoundFallback; + else return ResourceState::NotLoadedFallback; + } + + /* Fallback not found, loading didn't start yet */ + if(it == _data.end() || (it->second.state != ResourceDataState::Loading && it->second.state != ResourceDataState::NotFound)) + return ResourceState::NotLoaded; + } + + /* Loading / NotFound without fallback, Mutable / Final */ + return static_cast(it->second.state); +} + +template template Resource ResourceManagerData::get(ResourceKey key) { + /* Ask loader for the data, if they aren't there yet */ + if(_loader && _data.find(key) == _data.end()) + _loader->load(key); + + return Resource(this, key); +} + +template void ResourceManagerData::set(const ResourceKey key, T* const data, const ResourceDataState state, const ResourcePolicy policy) { + auto it = _data.find(key); + + /* NotFound / Loading state shouldn't have any data */ + CORRADE_ASSERT((data == nullptr) == (state == ResourceDataState::NotFound || state == ResourceDataState::Loading), + "ResourceManager::set(): data should be null if and only if state is NotFound or Loading", ); + + /* Cannot change resource with already final state */ + CORRADE_ASSERT(it == _data.end() || it->second.state != ResourceDataState::Final, + "ResourceManager::set(): cannot change already final resource" << key, ); + + /* If nothing is referencing reference-counted resource, we're done */ + if(policy == ResourcePolicy::ReferenceCounted && (it == _data.end() || it->second.referenceCount == 0)) { + Warning() << "ResourceManager: Reference-counted resource with key" << key << "isn't referenced from anywhere, deleting it immediately"; + delete data; + + /* Delete also already present resource (it could be here + because previous policy could be other than + ReferenceCounted) */ + if(it != _data.end()) _data.erase(it); + + return; + + /* Insert it, if not already here */ + } else if(it == _data.end()) + it = _data.insert(std::make_pair(key, Data())).first; + + /* Replace previous data */ + delete it->second.data; + it->second.data = data; + it->second.state = state; + it->second.policy = policy; + ++_lastChange; +} + +template void ResourceManagerData::setFallback(T* const data) { + delete _fallback; + _fallback = data; +} + +template void ResourceManagerData::free() { + /* Delete all non-referenced non-resident resources */ + for(auto it = _data.begin(); it != _data.end(); ) { + if(it->second.policy != ResourcePolicy::Resident && !it->second.referenceCount) + it = _data.erase(it); + else ++it; + } +} + +template void ResourceManagerData::setLoader(AbstractResourceLoader* const loader) { + /* Delete previous loader */ + delete _loader; + + /* Add new loader */ + if((_loader = loader)) _loader->manager = this; +} + +template void ResourceManagerData::decrementReferenceCount(ResourceKey key) { + auto it = _data.find(key); + + /* Free the resource if it is reference counted */ + if(--it->second.referenceCount == 0 && it->second.policy == ResourcePolicy::ReferenceCounted) + _data.erase(it); +} + +template struct ResourceManagerData::Data { + Data(const Data&) = delete; + Data& operator=(const Data&) = delete; + Data& operator=(Data&&) = delete; + + Data(): data(nullptr), state(ResourceDataState::Mutable), policy(ResourcePolicy::Manual), referenceCount(0) {} + + Data(Data&& other): data(other.data), state(other.state), policy(other.policy), referenceCount(other.referenceCount) { + other.data = nullptr; + other.referenceCount = 0; + } + + ~Data(); + + T* data; + ResourceDataState state; + ResourcePolicy policy; + std::size_t referenceCount; +}; + +template inline ResourceManagerData::Data::~Data() { + CORRADE_ASSERT(referenceCount == 0, + "ResourceManager::~ResourceManager(): destroyed while data are still referenced", ); + delete data; +} + +} + +template ResourceManager* ResourceManager::instance() { + CORRADE_ASSERT(internalInstance(), "ResourceManager::instance(): no instance exists", nullptr); + return internalInstance(); +} + +template ResourceManager::ResourceManager() { + CORRADE_ASSERT(!internalInstance(), "ResourceManager::ResourceManager(): another instance is already created", ); + internalInstance() = this; +} + +template ResourceManager::~ResourceManager() { + CORRADE_INTERNAL_ASSERT(internalInstance() == this); + internalInstance() = nullptr; +} + } /* Make the definition complete */ diff --git a/src/Shader.h b/src/Shader.h index 0e885f1d6..838671e70 100644 --- a/src/Shader.h +++ b/src/Shader.h @@ -111,7 +111,7 @@ class MAGNUM_EXPORT Shader { Shader& operator=(Shader&& other); /** @brief OpenGL shader ID */ - inline GLuint id() const { return _id; } + GLuint id() const { return _id; } /** * @brief Add shader source diff --git a/src/Swizzle.h b/src/Swizzle.h index 28e931a17..07216c3b1 100644 --- a/src/Swizzle.h +++ b/src/Swizzle.h @@ -72,7 +72,7 @@ Color3 or Color4 specialization is returned. @see @ref matrix-vector-component-access, Math::swizzle(), Vector4::xyz(), Color4::rgb(), Vector4::xy(), Vector3::xy() */ -template inline constexpr typename Implementation::TypeForSize::Type swizzle(const T& vector) { +template constexpr typename Implementation::TypeForSize::Type swizzle(const T& vector) { return {Math::Implementation::Component::value(vector)...}; } diff --git a/src/Test/ResourceManagerTest.cpp b/src/Test/ResourceManagerTest.cpp index 46176d91a..a99956e6b 100644 --- a/src/Test/ResourceManagerTest.cpp +++ b/src/Test/ResourceManagerTest.cpp @@ -50,8 +50,8 @@ class Data { public: static std::size_t count; - inline Data() { ++count; } - inline ~Data() { --count; } + Data() { ++count; } + ~Data() { --count; } }; typedef Magnum::ResourceManager ResourceManager; diff --git a/src/Texture.h b/src/Texture.h index ae63121ac..139dc7950 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -224,10 +224,10 @@ template class Texture: public AbstractTexture { * Creates one OpenGL texture. * @see @fn_gl{GenTextures} */ - inline explicit Texture(Target target = DataHelper::target()): AbstractTexture(static_cast(target)) {} + explicit Texture(Target target = DataHelper::target()): AbstractTexture(static_cast(target)) {} /** @brief %Texture target */ - inline constexpr Target target() const { return static_cast(_target); } + constexpr Target target() const { return static_cast(_target); } #ifndef MAGNUM_TARGET_GLES /** @@ -241,7 +241,7 @@ template class Texture: public AbstractTexture { * with @def_gl{TEXTURE_WIDTH}, @def_gl{TEXTURE_HEIGHT} or @def_gl{TEXTURE_DEPTH}. * @requires_gl %Texture image queries are not available in OpenGL ES. */ - inline typename DimensionTraits::VectorType imageSize(Int level) { + typename DimensionTraits::VectorType imageSize(Int level) { return DataHelper::imageSize(this, _target, level); } #endif @@ -264,7 +264,7 @@ template class Texture: public AbstractTexture { * with @def_gl{TEXTURE_WRAP_S}, @def_gl{TEXTURE_WRAP_T}, * @def_gl{TEXTURE_WRAP_R} */ - inline Texture* setWrapping(const Array& wrapping) { + Texture* setWrapping(const Array& wrapping) { DataHelper::setWrapping(this, wrapping); return this; } @@ -291,7 +291,7 @@ template class Texture: public AbstractTexture { * @requires_gl42 %Extension @extension{ARB,texture_storage} * @requires_gles30 %Extension @es_extension{EXT,texture_storage} */ - inline Texture* setStorage(Int levels, TextureFormat internalFormat, const typename DimensionTraits::VectorType& size) { + Texture* setStorage(Int levels, TextureFormat internalFormat, const typename DimensionTraits::VectorType& size) { DataHelper::setStorage(this, _target, levels, internalFormat, size); return this; } @@ -319,7 +319,7 @@ template class Texture: public AbstractTexture { * then @fn_gl{GetTexImage}, @fn_gl_extension{GetTextureImage,EXT,direct_state_access} * or @fn_gl_extension{GetnTexImage,ARB,robustness} */ - inline void image(Int level, Image* image) { + void image(Int level, Image* image) { AbstractTexture::image(_target, level, image); } @@ -332,7 +332,7 @@ template class Texture: public AbstractTexture { * See image(Int, Image*) for more information. * @requires_gl %Texture image queries are not available in OpenGL ES. */ - inline void image(Int level, BufferImage* image, Buffer::Usage usage) { + void image(Int level, BufferImage* image, Buffer::Usage usage) { AbstractTexture::image(_target, level, image, usage); } #endif @@ -359,7 +359,7 @@ template class Texture: public AbstractTexture { * @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/ * @fn_gl_extension{TextureImage3D,EXT,direct_state_access} */ - template inline Texture* setImage(Int level, TextureFormat internalFormat, Image* image) { + template Texture* setImage(Int level, TextureFormat internalFormat, Image* image) { DataHelper::setImage(this, _target, level, internalFormat, image); return this; } @@ -389,7 +389,7 @@ template class Texture: public AbstractTexture { * @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}/ * @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access} */ - template inline Texture* setSubImage(Int level, const typename DimensionTraits::VectorType& offset, Image* image) { + template Texture* setSubImage(Int level, const typename DimensionTraits::VectorType& offset, Image* image) { DataHelper::setSubImage(this, _target, level, offset, image); return this; } @@ -404,31 +404,31 @@ template class Texture: public AbstractTexture { * is not available, this function does nothing. * @see invalidateImage(), @fn_gl{InvalidateTexSubImage} */ - inline void invalidateSubImage(Int level, const typename DimensionTraits::VectorType& offset, const typename DimensionTraits::VectorType& size) { + void invalidateSubImage(Int level, const typename DimensionTraits::VectorType& offset, const typename DimensionTraits::VectorType& size) { DataHelper::invalidateSubImage(this, level, offset, size); } /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - inline Texture* setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap = Sampler::Mipmap::Base) { + Texture* setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap = Sampler::Mipmap::Base) { AbstractTexture::setMinificationFilter(filter, mipmap); return this; } - inline Texture* setMagnificationFilter(Sampler::Filter filter) { + Texture* setMagnificationFilter(Sampler::Filter filter) { AbstractTexture::setMagnificationFilter(filter); return this; } #ifndef MAGNUM_TARGET_GLES3 - inline Texture* setBorderColor(const Color4<>& color) { + Texture* setBorderColor(const Color4<>& color) { AbstractTexture::setBorderColor(color); return this; } - inline Texture* setMaxAnisotropy(Float anisotropy) { + Texture* setMaxAnisotropy(Float anisotropy) { AbstractTexture::setMaxAnisotropy(anisotropy); return this; } #endif - inline Texture* generateMipmap() { + Texture* generateMipmap() { AbstractTexture::generateMipmap(); return this; } diff --git a/src/Timeline.h b/src/Timeline.h index e9869311b..ac67fb5f8 100644 --- a/src/Timeline.h +++ b/src/Timeline.h @@ -89,10 +89,10 @@ class MAGNUM_EXPORT Timeline { * Creates stopped timeline. * @see start() */ - inline explicit Timeline(): _minimalFrameTime(0), _previousFrameDuration(0), running(false) {} + explicit Timeline(): _minimalFrameTime(0), _previousFrameDuration(0), running(false) {} /** @brief Minimal frame time (in seconds) */ - inline Float minimalFrameTime() const { return _minimalFrameTime; } + Float minimalFrameTime() const { return _minimalFrameTime; } /** * @brief Set minimal frame time @@ -101,7 +101,7 @@ class MAGNUM_EXPORT Timeline { * Default value is 0. * @see nextFrame() */ - inline Timeline* setMinimalFrameTime(Float seconds) { + Timeline* setMinimalFrameTime(Float seconds) { _minimalFrameTime = seconds; return this; } @@ -144,7 +144,7 @@ class MAGNUM_EXPORT Timeline { * * If the timeline is stopped, the function returns `0.0f`. */ - inline Float previousFrameDuration() const { return _previousFrameDuration; } + Float previousFrameDuration() const { return _previousFrameDuration; } private: std::chrono::high_resolution_clock::time_point _startTime;