diff --git a/src/AbstractFramebuffer.cpp b/src/AbstractFramebuffer.cpp index 4feffb268..7edcd23d6 100644 --- a/src/AbstractFramebuffer.cpp +++ b/src/AbstractFramebuffer.cpp @@ -53,7 +53,7 @@ void AbstractFramebuffer::bind(FramebufferTarget target) { } void AbstractFramebuffer::bindInternal(FramebufferTarget target) { - Implementation::FramebufferState* state = Context::current()->state()->framebuffer; + Implementation::FramebufferState* state = Context::current()->state().framebuffer; /* If already bound, done, otherwise update tracked state */ if(target == FramebufferTarget::Read) { @@ -71,7 +71,7 @@ void AbstractFramebuffer::bindInternal(FramebufferTarget target) { } FramebufferTarget AbstractFramebuffer::bindInternal() { - Implementation::FramebufferState* state = Context::current()->state()->framebuffer; + Implementation::FramebufferState* state = Context::current()->state().framebuffer; /* Return target to which the framebuffer is already bound */ if(state->readBinding == _id && state->drawBinding == _id) @@ -112,14 +112,14 @@ AbstractFramebuffer& AbstractFramebuffer::setViewport(const Rectanglei& rectangl _viewport = rectangle; /* Update the viewport if the framebuffer is currently bound */ - if(Context::current()->state()->framebuffer->drawBinding == _id) + if(Context::current()->state().framebuffer->drawBinding == _id) setViewportInternal(); return *this; } void AbstractFramebuffer::setViewportInternal() { - Implementation::FramebufferState* state = Context::current()->state()->framebuffer; + Implementation::FramebufferState* state = Context::current()->state().framebuffer; CORRADE_INTERNAL_ASSERT(state->drawBinding == _id); @@ -165,7 +165,7 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Buf if(image.size() != size) image.setData(size, image.format(), image.type(), nullptr, usage); - image.buffer()->bind(Buffer::Target::PixelPack); + image.buffer().bind(Buffer::Target::PixelPack); /** @todo De-duplicate buffer size computation */ readImplementation(offset, size, image.format(), image.type(), image.pixelSize()*size.product(), nullptr); } @@ -194,9 +194,9 @@ void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attach #endif } -void AbstractFramebuffer::initializeContextBasedFunctionality(Context* context) { +void AbstractFramebuffer::initializeContextBasedFunctionality(Context& context) { #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "AbstractFramebuffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; checkStatusImplementation = &AbstractFramebuffer::checkStatusImplementationDSA; @@ -234,9 +234,9 @@ void AbstractFramebuffer::initializeContextBasedFunctionality(Context* context) #ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) + if(context.isExtensionSupported()) #else - if(context->isExtensionSupported()) + if(context.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES diff --git a/src/AbstractFramebuffer.h b/src/AbstractFramebuffer.h index 8e8df7f9f..2f7308dfc 100644 --- a/src/AbstractFramebuffer.h +++ b/src/AbstractFramebuffer.h @@ -297,7 +297,7 @@ class MAGNUM_EXPORT AbstractFramebuffer { Rectanglei _viewport; private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); GLenum MAGNUM_LOCAL checkStatusImplementationDefault(FramebufferTarget target); #ifndef MAGNUM_TARGET_GLES diff --git a/src/AbstractShaderProgram.cpp b/src/AbstractShaderProgram.cpp index 6e892d7e8..5e581074e 100644 --- a/src/AbstractShaderProgram.cpp +++ b/src/AbstractShaderProgram.cpp @@ -77,7 +77,7 @@ AbstractShaderProgram::UniformMatrix4x3dvImplementation AbstractShaderProgram::u #endif Int AbstractShaderProgram::maxSupportedVertexAttributeCount() { - GLint& value = Context::current()->state()->shaderProgram->maxSupportedVertexAttributeCount; + GLint& value = Context::current()->state().shaderProgram->maxSupportedVertexAttributeCount; /* Get the value, if not already cached */ if(value == 0) @@ -94,7 +94,7 @@ AbstractShaderProgram::AbstractShaderProgram(AbstractShaderProgram&& other) noex AbstractShaderProgram::~AbstractShaderProgram() { /* Remove current usage from the state */ - GLuint& current = Context::current()->state()->shaderProgram->current; + GLuint& current = Context::current()->state().shaderProgram->current; if(current == _id) current = 0; if(_id) glDeleteProgram(_id); @@ -125,7 +125,7 @@ std::pair AbstractShaderProgram::validate() { void AbstractShaderProgram::use() { /* Use only if the program isn't already in use */ - GLuint& current = Context::current()->state()->shaderProgram->current; + GLuint& current = Context::current()->state().shaderProgram->current; if(current != _id) glUseProgram(current = _id); } @@ -189,12 +189,12 @@ Int AbstractShaderProgram::uniformLocation(const std::string& name) { return location; } -void AbstractShaderProgram::initializeContextBasedFunctionality(Context* context) { +void AbstractShaderProgram::initializeContextBasedFunctionality(Context& context) { /** @todo OpenGL ES 2 has extension @es_extension{EXT,separate_shader_objects} for this */ #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported() || - context->isExtensionSupported()) { - Debug() << "AbstractShaderProgram: using" << (context->isExtensionSupported() ? + if(context.isExtensionSupported() || + context.isExtensionSupported()) { + Debug() << "AbstractShaderProgram: using" << (context.isExtensionSupported() ? Extensions::GL::ARB::separate_shader_objects::string() : Extensions::GL::EXT::direct_state_access::string()) << "features"; uniform1fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniform2fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index 8f3b0262d..a3b1e5cd2 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -774,7 +774,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { #endif private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); typedef void(AbstractShaderProgram::*Uniform1fvImplementation)(GLint, GLsizei, const GLfloat*); typedef void(AbstractShaderProgram::*Uniform2fvImplementation)(GLint, GLsizei, const Math::Vector<2, GLfloat>*); diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp index 6eaf638ac..1f2f7b345 100644 --- a/src/AbstractTexture.cpp +++ b/src/AbstractTexture.cpp @@ -81,7 +81,7 @@ AbstractTexture::InvalidateImageImplementation AbstractTexture::invalidateImageI AbstractTexture::InvalidateSubImageImplementation AbstractTexture::invalidateSubImageImplementation = &AbstractTexture::invalidateSubImageImplementationNoOp; Int AbstractTexture::maxSupportedLayerCount() { - return Context::current()->state()->texture->maxSupportedLayerCount; + return Context::current()->state().texture->maxSupportedLayerCount; } void AbstractTexture::destroy() { @@ -89,7 +89,7 @@ void AbstractTexture::destroy() { if(!_id) return; /* Remove all bindings */ - for(GLuint& binding: Context::current()->state()->texture->bindings) + for(GLuint& binding: Context::current()->state().texture->bindings) if(binding == _id) binding = 0; glDeleteTextures(1, &_id); @@ -120,7 +120,7 @@ AbstractTexture& AbstractTexture::operator=(AbstractTexture&& other) { } void AbstractTexture::bind(Int layer) { - Implementation::TextureState* const textureState = Context::current()->state()->texture; + Implementation::TextureState* const textureState = Context::current()->state().texture; /* If already bound in given layer, nothing to do */ if(textureState->bindings[layer] == _id) return; @@ -129,7 +129,7 @@ void AbstractTexture::bind(Int layer) { } void AbstractTexture::bindImplementationDefault(GLint layer) { - Implementation::TextureState* const textureState = Context::current()->state()->texture; + Implementation::TextureState* const textureState = Context::current()->state().texture; /* Change to given layer, if not already there */ if(textureState->currentLayer != layer) @@ -141,7 +141,7 @@ void AbstractTexture::bindImplementationDefault(GLint layer) { #ifndef MAGNUM_TARGET_GLES void AbstractTexture::bindImplementationDSA(GLint layer) { - glBindMultiTextureEXT(GL_TEXTURE0 + layer, _target, (Context::current()->state()->texture->bindings[layer] = _id)); + glBindMultiTextureEXT(GL_TEXTURE0 + layer, _target, (Context::current()->state().texture->bindings[layer] = _id)); } #endif @@ -176,7 +176,7 @@ void AbstractTexture::mipmapImplementationDSA() { #endif void AbstractTexture::bindInternal() { - Implementation::TextureState* const textureState = Context::current()->state()->texture; + Implementation::TextureState* const textureState = Context::current()->state().texture; /* If the texture is already bound in current layer, nothing to do */ if(textureState->bindings[textureState->currentLayer] == _id) @@ -192,8 +192,8 @@ void AbstractTexture::bindInternal() { glBindTexture(_target, (textureState->bindings[internalLayer] = _id)); } -void AbstractTexture::initializeContextBasedFunctionality(Context* context) { - Implementation::TextureState* const textureState = context->state()->texture; +void AbstractTexture::initializeContextBasedFunctionality(Context& context) { + Implementation::TextureState* const textureState = context.state().texture; GLint& value = textureState->maxSupportedLayerCount; /* Get the value and resize bindings array */ @@ -201,7 +201,7 @@ void AbstractTexture::initializeContextBasedFunctionality(Context* context) { textureState->bindings.resize(value); #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "AbstractTexture: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; bindImplementation = &AbstractTexture::bindImplementationDSA; @@ -219,24 +219,24 @@ void AbstractTexture::initializeContextBasedFunctionality(Context* context) { subImage3DImplementation = &AbstractTexture::subImageImplementationDSA; } - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "AbstractTexture: using" << Extensions::GL::ARB::invalidate_subdata::string() << "features"; invalidateImageImplementation = &AbstractTexture::invalidateImageImplementationARB; invalidateSubImageImplementation = &AbstractTexture::invalidateSubImageImplementationARB; } - if(context->isExtensionSupported() && - !context->isExtensionSupported()) { + if(context.isExtensionSupported() && + !context.isExtensionSupported()) { Debug() << "AbstractTexture: using" << Extensions::GL::ARB::robustness::string() << "features"; getImageImplementation = &AbstractTexture::getImageImplementationRobustness; } - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "AbstractTexture: using" << Extensions::GL::ARB::texture_storage::string() << "features"; - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { storage1DImplementation = &AbstractTexture::storageImplementationDSA; storage2DImplementation = &AbstractTexture::storageImplementationDSA; storage3DImplementation = &AbstractTexture::storageImplementationDSA; @@ -981,7 +981,7 @@ template void AbstractTexture::image(GLenum target, GLin if(image.size() != size) image.setData(size, image.format(), image.type(), nullptr, usage); - image.buffer()->bind(Buffer::Target::PixelPack); + image.buffer().bind(Buffer::Target::PixelPack); (this->*getImageImplementation)(target, level, image.format(), image.type(), dataSize, nullptr); } @@ -1022,7 +1022,7 @@ void AbstractTexture::DataHelper<1>::setImage(AbstractTexture* const texture, co } void AbstractTexture::DataHelper<1>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) { - image.buffer()->bind(Buffer::Target::PixelUnpack); + image.buffer().bind(Buffer::Target::PixelUnpack); (texture->*image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); } @@ -1032,7 +1032,7 @@ void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture* const texture, } void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) { - image.buffer()->bind(Buffer::Target::PixelUnpack); + image.buffer().bind(Buffer::Target::PixelUnpack); (texture->*subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); } #endif @@ -1046,7 +1046,7 @@ void AbstractTexture::DataHelper<2>::setImage(AbstractTexture* const texture, co #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) { - image.buffer()->bind(Buffer::Target::PixelUnpack); + image.buffer().bind(Buffer::Target::PixelUnpack); (texture->*image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); } #endif @@ -1060,7 +1060,7 @@ void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture* const texture, #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector2i& offset, BufferImage2D& image) { - image.buffer()->bind(Buffer::Target::PixelUnpack); + image.buffer().bind(Buffer::Target::PixelUnpack); (texture->*subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); } #endif @@ -1074,7 +1074,7 @@ void AbstractTexture::DataHelper<3>::setImage(AbstractTexture* const texture, co #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) { - image.buffer()->bind(Buffer::Target::PixelUnpack); + image.buffer().bind(Buffer::Target::PixelUnpack); (texture->*image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); } #endif @@ -1088,7 +1088,7 @@ void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture* const texture, #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector3i& offset, BufferImage3D& image) { - image.buffer()->bind(Buffer::Target::PixelUnpack); + image.buffer().bind(Buffer::Target::PixelUnpack); (texture->*subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); } #endif diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 9f34b50f5..687f0def9 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -281,7 +281,7 @@ class MAGNUM_EXPORT AbstractTexture { GLenum _target; private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); typedef void(AbstractTexture::*BindImplementation)(GLint); void MAGNUM_LOCAL bindImplementationDefault(GLint layer); diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 7957e2461..5e50750a6 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -51,9 +51,9 @@ Buffer::MapRangeImplementation Buffer::mapRangeImplementation = &Buffer::mapRang Buffer::FlushMappedRangeImplementation Buffer::flushMappedRangeImplementation = &Buffer::flushMappedRangeImplementationDefault; Buffer::UnmapImplementation Buffer::unmapImplementation = &Buffer::unmapImplementationDefault; -void Buffer::initializeContextBasedFunctionality(Context* context) { +void Buffer::initializeContextBasedFunctionality(Context& context) { #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "Buffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; copyImplementation = &Buffer::copyImplementationDSA; @@ -67,7 +67,7 @@ void Buffer::initializeContextBasedFunctionality(Context* context) { unmapImplementation = &Buffer::unmapImplementationDSA; } - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "Buffer: using" << Extensions::GL::ARB::invalidate_subdata::string() << "features"; invalidateImplementation = &Buffer::invalidateImplementationARB; @@ -87,7 +87,7 @@ Buffer::Buffer(Buffer::Target targetHint): _targetHint(targetHint) } Buffer::~Buffer() { - GLuint* bindings = Context::current()->state()->buffer->bindings; + GLuint* bindings = Context::current()->state().buffer->bindings; /* Remove all current bindings from the state */ for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i) @@ -97,7 +97,7 @@ Buffer::~Buffer() { } void Buffer::bind(Target target, GLuint id) { - GLuint& bound = Context::current()->state()->buffer->bindings[Implementation::BufferState::indexForTarget(target)]; + GLuint& bound = Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(target)]; /* Already bound, nothing to do */ if(bound == id) return; @@ -108,7 +108,7 @@ void Buffer::bind(Target target, GLuint id) { } Buffer::Target Buffer::bindInternal(Target hint) { - GLuint* bindings = Context::current()->state()->buffer->bindings; + GLuint* bindings = Context::current()->state().buffer->bindings; GLuint& hintBinding = bindings[Implementation::BufferState::indexForTarget(hint)]; /* Shortcut - if already bound to hint, return */ @@ -161,13 +161,13 @@ void Buffer::unmapSub() { #endif #ifndef MAGNUM_TARGET_GLES2 -void Buffer::copyImplementationDefault(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { - glCopyBufferSubData(static_cast(read->bindInternal(Target::CopyRead)), static_cast(write->bindInternal(Target::CopyWrite)), readOffset, writeOffset, size); +void Buffer::copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { + glCopyBufferSubData(static_cast(read.bindInternal(Target::CopyRead)), static_cast(write.bindInternal(Target::CopyWrite)), readOffset, writeOffset, size); } #ifndef MAGNUM_TARGET_GLES -void Buffer::copyImplementationDSA(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { - glNamedCopyBufferSubDataEXT(read->_id, write->_id, readOffset, writeOffset, size); +void Buffer::copyImplementationDSA(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { + glNamedCopyBufferSubDataEXT(read._id, write._id, readOffset, writeOffset, size); } #endif #endif diff --git a/src/Buffer.h b/src/Buffer.h index 4076fa8ea..73163292e 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -459,7 +459,7 @@ class MAGNUM_EXPORT Buffer { * @requires_gl31 %Extension @extension{ARB,copy_buffer} * @requires_gles30 %Buffer copying is not available in OpenGL ES 2.0. */ - 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 @@ -826,16 +826,16 @@ class MAGNUM_EXPORT Buffer { #endif private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); static void bind(Target hint, GLuint id); Target MAGNUM_LOCAL bindInternal(Target hint); #ifndef MAGNUM_TARGET_GLES2 - typedef void(*CopyImplementation)(Buffer*, Buffer*, GLintptr, GLintptr, GLsizeiptr); - static void MAGNUM_LOCAL copyImplementationDefault(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void(*CopyImplementation)(Buffer&, Buffer&, GLintptr, GLintptr, GLsizeiptr); + static void MAGNUM_LOCAL copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #ifndef MAGNUM_TARGET_GLES - static void MAGNUM_LOCAL copyImplementationDSA(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + static void MAGNUM_LOCAL copyImplementationDSA(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #endif static CopyImplementation copyImplementation; #endif diff --git a/src/BufferImage.h b/src/BufferImage.h index 24dfc3a6e..634a02b76 100644 --- a/src/BufferImage.h +++ b/src/BufferImage.h @@ -66,7 +66,7 @@ template class MAGNUM_EXPORT BufferImage: public Abstrac typename DimensionTraits::VectorType size() const { return _size; } /** @brief %Image buffer */ - Buffer* buffer() { return &_buffer; } + Buffer& buffer() { return _buffer; } /** * @brief Set image data diff --git a/src/BufferTexture.cpp b/src/BufferTexture.cpp index 55231f970..7ff447fa4 100644 --- a/src/BufferTexture.cpp +++ b/src/BufferTexture.cpp @@ -34,8 +34,8 @@ namespace Magnum { BufferTexture::SetBufferImplementation BufferTexture::setBufferImplementation = &BufferTexture::setBufferImplementationDefault; BufferTexture::SetBufferRangeImplementation BufferTexture::setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDefault; -void BufferTexture::initializeContextBasedFunctionality(Context* context) { - if(context->isExtensionSupported()) { +void BufferTexture::initializeContextBasedFunctionality(Context& context) { + if(context.isExtensionSupported()) { Debug() << "BufferTexture: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; setBufferImplementation = &BufferTexture::setBufferImplementationDSA; @@ -43,22 +43,22 @@ void BufferTexture::initializeContextBasedFunctionality(Context* context) { } } -void BufferTexture::setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer) { +void BufferTexture::setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer) { bindInternal(); - glTexBuffer(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id()); + glTexBuffer(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id()); } -void BufferTexture::setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer) { - glTextureBufferEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id()); +void BufferTexture::setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer) { + glTextureBufferEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id()); } -void BufferTexture::setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { +void BufferTexture::setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size) { bindInternal(); - glTexBufferRange(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id(), offset, size); + glTexBufferRange(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id(), offset, size); } -void BufferTexture::setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { - glTextureBufferRangeEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id(), offset, size); +void BufferTexture::setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size) { + glTextureBufferRangeEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id(), offset, size); } } diff --git a/src/BufferTexture.h b/src/BufferTexture.h index 086d2a959..4bb1dacdc 100644 --- a/src/BufferTexture.h +++ b/src/BufferTexture.h @@ -164,12 +164,13 @@ using setBuffer(), you can fill the buffer at any time using data setting functions in Buffer itself. Note that the buffer is not managed (e.g. deleted on destruction) by the -texture, so you have to manage it on your own. On the other hand it allows you -to use one buffer for more textures or store more than one data in it. +texture, so you have to manage it on your own and ensure that it is available +for whole texture lifetime. On the other hand it allows you to use one buffer +for more textures or store more than one data in it. Example usage: @code -Buffer* buffer; +Buffer buffer; BufferTexture texture; texture.setBuffer(BufferTextureFormat::RGB32F, buffer); @@ -221,7 +222,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} */ - void setBuffer(BufferTextureFormat internalFormat, Buffer* buffer) { + void setBuffer(BufferTextureFormat internalFormat, Buffer& buffer) { (this->*setBufferImplementation)(internalFormat, buffer); } @@ -239,21 +240,21 @@ 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} */ - 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); } private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); - typedef void(BufferTexture::*SetBufferImplementation)(BufferTextureFormat, Buffer*); - void MAGNUM_LOCAL setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer); - void MAGNUM_LOCAL setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer); + typedef void(BufferTexture::*SetBufferImplementation)(BufferTextureFormat, Buffer&); + void MAGNUM_LOCAL setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer); + void MAGNUM_LOCAL setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer); static SetBufferImplementation setBufferImplementation; - typedef void(BufferTexture::*SetBufferRangeImplementation)(BufferTextureFormat, Buffer*, GLintptr, GLsizeiptr); - void MAGNUM_LOCAL setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); - void MAGNUM_LOCAL setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); + typedef void(BufferTexture::*SetBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr); + void MAGNUM_LOCAL setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); + void MAGNUM_LOCAL setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); static SetBufferRangeImplementation setBufferRangeImplementation; }; diff --git a/src/Context.cpp b/src/Context.cpp index d84d5fbbe..9fa4e2563 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -407,19 +407,19 @@ Context::Context() { _state = new Implementation::State; /* Initialize functionality based on current OpenGL version and extensions */ - AbstractFramebuffer::initializeContextBasedFunctionality(this); - AbstractShaderProgram::initializeContextBasedFunctionality(this); - AbstractTexture::initializeContextBasedFunctionality(this); - Buffer::initializeContextBasedFunctionality(this); + AbstractFramebuffer::initializeContextBasedFunctionality(*this); + AbstractShaderProgram::initializeContextBasedFunctionality(*this); + AbstractTexture::initializeContextBasedFunctionality(*this); + Buffer::initializeContextBasedFunctionality(*this); #ifndef MAGNUM_TARGET_GLES - BufferTexture::initializeContextBasedFunctionality(this); + BufferTexture::initializeContextBasedFunctionality(*this); #endif - DebugMarker::initializeContextBasedFunctionality(this); - DefaultFramebuffer::initializeContextBasedFunctionality(this); - Framebuffer::initializeContextBasedFunctionality(this); - Mesh::initializeContextBasedFunctionality(this); - Renderbuffer::initializeContextBasedFunctionality(this); - Renderer::initializeContextBasedFunctionality(this); + DebugMarker::initializeContextBasedFunctionality(*this); + DefaultFramebuffer::initializeContextBasedFunctionality(*this); + Framebuffer::initializeContextBasedFunctionality(*this); + Mesh::initializeContextBasedFunctionality(*this); + Renderbuffer::initializeContextBasedFunctionality(*this); + Renderer::initializeContextBasedFunctionality(*this); } Context::~Context() { diff --git a/src/Context.h b/src/Context.h index 358707c15..018f8ffcf 100644 --- a/src/Context.h +++ b/src/Context.h @@ -355,7 +355,7 @@ class MAGNUM_EXPORT Context { } #ifndef DOXYGEN_GENERATING_OUTPUT - Implementation::State* state() { return _state; } + Implementation::State& state() { return *_state; } #endif private: diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index 352223448..4f6478e18 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -61,8 +61,8 @@ CubeMapTexture texture; texture.setMagnificationFilter(Sampler::Filter::Linear) // ... .setStorage(Math::log2(256)+1, TextureFormat::RGBA8, {256, 256}) - .setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, {}, &positiveX) - .setSubImage(CubeMapTexture::Coordinate::NegativeX, 0, {}, &negativeX) + .setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, {}, positiveX) + .setSubImage(CubeMapTexture::Coordinate::NegativeX, 0, {}, negativeX) // ... @endcode diff --git a/src/DebugMarker.cpp b/src/DebugMarker.cpp index 44b2e6919..47049c742 100644 --- a/src/DebugMarker.cpp +++ b/src/DebugMarker.cpp @@ -33,10 +33,10 @@ namespace Magnum { DebugMarker::MarkImplementation DebugMarker::markImplementation = &DebugMarker::markImplementationDefault; -void DebugMarker::initializeContextBasedFunctionality(Context* context) { +void DebugMarker::initializeContextBasedFunctionality(Context& context) { /** @todo Re-enable when extension wrangler is available for ES */ #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "DebugMarker: using" << Extensions::GL::GREMEDY::string_marker::string() << "features"; markImplementation = &DebugMarker::markImplementationDebugger; diff --git a/src/DebugMarker.h b/src/DebugMarker.h index 04bf3625a..2c32e18a7 100644 --- a/src/DebugMarker.h +++ b/src/DebugMarker.h @@ -58,7 +58,7 @@ class MAGNUM_EXPORT DebugMarker { } private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); typedef void(*MarkImplementation)(const std::string&); static MAGNUM_LOCAL void markImplementationDefault(const std::string& string); diff --git a/src/DefaultFramebuffer.cpp b/src/DefaultFramebuffer.cpp index cc6e7789e..02fabecdd 100644 --- a/src/DefaultFramebuffer.cpp +++ b/src/DefaultFramebuffer.cpp @@ -78,8 +78,8 @@ void DefaultFramebuffer::invalidate(std::initializer_liststate()->framebuffer; +void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) { + Implementation::FramebufferState* state = context.state().framebuffer; /* Initial framebuffer size */ GLint viewport[4]; @@ -88,7 +88,7 @@ void DefaultFramebuffer::initializeContextBasedFunctionality(Context* context) { /* Fake initial glViewport() call for ApiTrace */ #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) + if(context.isExtensionSupported()) glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); #endif } diff --git a/src/DefaultFramebuffer.h b/src/DefaultFramebuffer.h index c860e5d3e..e04fc75d1 100644 --- a/src/DefaultFramebuffer.h +++ b/src/DefaultFramebuffer.h @@ -58,7 +58,7 @@ any drawing in your @ref Platform::GlutApplication::drawEvent() "drawEvent()" implementation, for example: @code void drawEvent() { - defaultFramebuffer.clear(AbstractFramebuffer::Clear::Color|AbstractFramebuffer::Clear::Depth); + defaultFramebuffer.clear(FramebufferClear::Color|FramebufferClear::Depth); // ... } @@ -410,7 +410,7 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer { #endif private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); }; /** @brief Default framebuffer instance */ diff --git a/src/Framebuffer.cpp b/src/Framebuffer.cpp index fcadfd546..5458066fe 100644 --- a/src/Framebuffer.cpp +++ b/src/Framebuffer.cpp @@ -60,7 +60,7 @@ Framebuffer::Framebuffer(const Rectanglei& viewport) { Framebuffer::~Framebuffer() { /* If bound, remove itself from state */ - Implementation::FramebufferState* state = Context::current()->state()->framebuffer; + Implementation::FramebufferState* state = Context::current()->state().framebuffer; if(state->readBinding == _id) state->readBinding = 0; if(state->drawBinding == _id) state->drawBinding = 0; @@ -107,15 +107,15 @@ void Framebuffer::invalidate(std::initializer_list attac delete[] _attachments; } -Framebuffer& Framebuffer::attachTexture2D(BufferAttachment attachment, Texture2D* texture, Int mipLevel) { +Framebuffer& Framebuffer::attachTexture2D(BufferAttachment attachment, Texture2D& texture, Int mipLevel) { /** @todo Check for texture target compatibility */ - (this->*texture2DImplementation)(attachment, GLenum(texture->target()), texture->id(), mipLevel); + (this->*texture2DImplementation)(attachment, GLenum(texture.target()), texture.id(), mipLevel); return *this; } -void Framebuffer::initializeContextBasedFunctionality(Context* context) { +void Framebuffer::initializeContextBasedFunctionality(Context& context) { #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "Framebuffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; renderbufferImplementation = &Framebuffer::renderbufferImplementationDSA; @@ -128,21 +128,21 @@ void Framebuffer::initializeContextBasedFunctionality(Context* context) { #endif } -void Framebuffer::renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer* renderbuffer) { - glFramebufferRenderbuffer(GLenum(bindInternal()), GLenum(attachment), GL_RENDERBUFFER, renderbuffer->id()); +void Framebuffer::renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer) { + glFramebufferRenderbuffer(GLenum(bindInternal()), GLenum(attachment), GL_RENDERBUFFER, renderbuffer.id()); } #ifndef MAGNUM_TARGET_GLES -void Framebuffer::renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer* renderbuffer) { - glNamedFramebufferRenderbufferEXT(_id, GLenum(attachment), GL_RENDERBUFFER, renderbuffer->id()); +void Framebuffer::renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer) { + glNamedFramebufferRenderbufferEXT(_id, GLenum(attachment), GL_RENDERBUFFER, renderbuffer.id()); } -void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, Texture1D* texture, GLint mipLevel) { - glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), static_cast(texture->target()), texture->id(), mipLevel); +void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, Texture1D& texture, GLint mipLevel) { + glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), static_cast(texture.target()), texture.id(), mipLevel); } -void Framebuffer::texture1DImplementationDSA(BufferAttachment attachment, Texture1D* texture, GLint mipLevel) { - glNamedFramebufferTexture1DEXT(_id, GLenum(attachment), GLenum(texture->target()), texture->id(), mipLevel); +void Framebuffer::texture1DImplementationDSA(BufferAttachment attachment, Texture1D& texture, GLint mipLevel) { + glNamedFramebufferTexture1DEXT(_id, GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel); } #endif @@ -156,11 +156,11 @@ void Framebuffer::texture2DImplementationDSA(BufferAttachment attachment, GLenum } #endif -void Framebuffer::texture3DImplementationDefault(BufferAttachment attachment, Texture3D* texture, GLint mipLevel, GLint layer) { +void Framebuffer::texture3DImplementationDefault(BufferAttachment attachment, Texture3D& texture, GLint mipLevel, GLint layer) { /** @todo Check for texture target compatibility */ /** @todo Get some extension wrangler for glFramebufferTexture3D() (extension only) */ #ifndef MAGNUM_TARGET_GLES - glFramebufferTexture3D(GLenum(bindInternal()), GLenum(attachment), static_cast(texture->target()), texture->id(), mipLevel, layer); + glFramebufferTexture3D(GLenum(bindInternal()), GLenum(attachment), static_cast(texture.target()), texture.id(), mipLevel, layer); #else static_cast(attachment); static_cast(texture); @@ -170,8 +170,8 @@ void Framebuffer::texture3DImplementationDefault(BufferAttachment attachment, Te } #ifndef MAGNUM_TARGET_GLES -void Framebuffer::texture3DImplementationDSA(BufferAttachment attachment, Texture3D* texture, GLint mipLevel, GLint layer) { - glNamedFramebufferTexture3DEXT(_id, GLenum(attachment), GLenum(texture->target()), texture->id(), mipLevel, layer); +void Framebuffer::texture3DImplementationDSA(BufferAttachment attachment, Texture3D& texture, GLint mipLevel, GLint layer) { + glNamedFramebufferTexture3DEXT(_id, GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel, layer); } #endif diff --git a/src/Framebuffer.h b/src/Framebuffer.h index 8e1c84768..2276426ce 100644 --- a/src/Framebuffer.h +++ b/src/Framebuffer.h @@ -55,9 +55,9 @@ Renderbuffer depthStencil; // configure the textures and allocate texture memory... -framebuffer.attachTexture2D(Framebuffer::ColorAttachment(0), &color); -framebuffer.attachTexture2D(Framebuffer::ColorAttachment(1), &normal); -framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::DepthStencil, &depthStencil); +framebuffer.attachTexture2D(Framebuffer::ColorAttachment(0), color); +framebuffer.attachTexture2D(Framebuffer::ColorAttachment(1), normal); +framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::DepthStencil, depthStencil); @endcode Then you need to map outputs of your shader to color attachments in the @@ -73,13 +73,13 @@ off-screen framebuffer, then bind the default and render the textures on screen: @code void drawEvent() { - defaultFramebuffer.clear(DefaultFramebuffer::Clear::Color) - framebuffer.clear(Framebuffer::Clear::Color|Framebuffer::Clear::Depth|Framebuffer::Clear::Stencil); + defaultFramebuffer.clear(FramebufferClear::Color) + framebuffer.clear(FramebufferClear::Color|FramebufferClear::Depth|FramebufferClear::Stencil); - framebuffer.bind(Framebuffer::Target::Draw); + framebuffer.bind(FramebufferTarget::Draw); // ... - defaultFramebuffer.bind(DefaultFramebuffer::Target::Draw); + defaultFramebuffer.bind(Framebuffer::Target::Draw); // ... } @endcode @@ -405,7 +405,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @see @fn_gl{BindFramebuffer}, @fn_gl{FramebufferRenderbuffer} or * @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access} */ - Framebuffer& attachRenderbuffer(BufferAttachment attachment, Renderbuffer* renderbuffer) { + Framebuffer& attachRenderbuffer(BufferAttachment attachment, Renderbuffer& renderbuffer) { (this->*renderbufferImplementation)(attachment, renderbuffer); return *this; } @@ -425,7 +425,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. */ - Framebuffer& attachTexture1D(BufferAttachment attachment, Texture1D* texture, Int level) { + Framebuffer& attachTexture1D(BufferAttachment attachment, Texture1D& texture, Int level) { (this->*texture1DImplementation)(attachment, texture, level); return *this; } @@ -444,7 +444,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @see attachCubeMapTexture(), @fn_gl{BindFramebuffer}, @fn_gl{FramebufferTexture} * or @fn_gl_extension{NamedFramebufferTexture2D,EXT,direct_state_access} */ - Framebuffer& attachTexture2D(BufferAttachment attachment, Texture2D* texture, Int level); + Framebuffer& attachTexture2D(BufferAttachment attachment, Texture2D& texture, Int level); /** * @brief Attach cube map texture to given buffer @@ -460,8 +460,8 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @see attachTexture2D(), @fn_gl{BindFramebuffer}, @fn_gl{FramebufferTexture} * or @fn_gl_extension{NamedFramebufferTexture2D,EXT,direct_state_access} */ - Framebuffer& attachCubeMapTexture(BufferAttachment attachment, CubeMapTexture* texture, CubeMapTexture::Coordinate coordinate, Int level) { - (this->*texture2DImplementation)(attachment, GLenum(coordinate), texture->id(), level); + Framebuffer& attachCubeMapTexture(BufferAttachment attachment, CubeMapTexture& texture, CubeMapTexture::Coordinate coordinate, Int level) { + (this->*texture2DImplementation)(attachment, GLenum(coordinate), texture.id(), level); return *this; } @@ -480,7 +480,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { * @fn_gl_extension{NamedFramebufferTexture3D,EXT,direct_state_access} * @requires_es_extension %Extension @es_extension{OES,texture_3D} */ - 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; @@ -495,19 +495,19 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { #endif private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); - typedef void(Framebuffer::*RenderbufferImplementation)(BufferAttachment, Renderbuffer*); - void MAGNUM_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer* renderbuffer); + typedef void(Framebuffer::*RenderbufferImplementation)(BufferAttachment, Renderbuffer&); + void MAGNUM_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer* renderbuffer); + void MAGNUM_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer); #endif static RenderbufferImplementation renderbufferImplementation; #ifndef MAGNUM_TARGET_GLES - typedef void(Framebuffer::*Texture1DImplementation)(BufferAttachment, Texture1D*, GLint); - void MAGNUM_LOCAL texture1DImplementationDefault(BufferAttachment attachment, Texture1D* texture, GLint level); - void MAGNUM_LOCAL texture1DImplementationDSA(BufferAttachment attachment, Texture1D* texture, GLint level); + typedef void(Framebuffer::*Texture1DImplementation)(BufferAttachment, Texture1D&, GLint); + void MAGNUM_LOCAL texture1DImplementationDefault(BufferAttachment attachment, Texture1D& texture, GLint level); + void MAGNUM_LOCAL texture1DImplementationDSA(BufferAttachment attachment, Texture1D& texture, GLint level); static Texture1DImplementation texture1DImplementation; #endif @@ -518,10 +518,10 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer { #endif static MAGNUM_LOCAL Texture2DImplementation texture2DImplementation; - typedef void(Framebuffer::*Texture3DImplementation)(BufferAttachment, Texture3D*, GLint, GLint); - void MAGNUM_LOCAL texture3DImplementationDefault(BufferAttachment attachment, Texture3D* texture, GLint level, GLint layer); + typedef void(Framebuffer::*Texture3DImplementation)(BufferAttachment, Texture3D&, GLint, GLint); + void MAGNUM_LOCAL texture3DImplementationDefault(BufferAttachment attachment, Texture3D& texture, GLint level, GLint layer); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL texture3DImplementationDSA(BufferAttachment attachment, Texture3D* texture, GLint level, GLint layer); + void MAGNUM_LOCAL texture3DImplementationDSA(BufferAttachment attachment, Texture3D& texture, GLint level, GLint layer); #endif static Texture3DImplementation texture3DImplementation; }; diff --git a/src/Mesh.cpp b/src/Mesh.cpp index d8d519a57..e5b394a3b 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -69,7 +69,7 @@ Mesh::Mesh(Primitive primitive): _primitive(primitive), _vertexCount(0), _indexC Mesh::~Mesh() { /* Remove current vao from the state */ - GLuint& current = Context::current()->state()->mesh->currentVAO; + GLuint& current = Context::current()->state().mesh->currentVAO; if(current == vao) current = 0; (this->*destroyImplementation)(); @@ -117,10 +117,10 @@ Mesh& Mesh::operator=(Mesh&& other) { return *this; } -Mesh& Mesh::setIndexBuffer(Buffer* buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end) { +Mesh& Mesh::setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end) { #ifdef CORRADE_TARGET_NACL - CORRADE_ASSERT(buffer->targetHint() == Buffer::Target::ElementArray, - "Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::ElementArray << "but got" << buffer->targetHint(), this); + CORRADE_ASSERT(buffer.targetHint() == Buffer::Target::ElementArray, + "Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::ElementArray << "but got" << buffer.targetHint(), this); #endif indexOffset = offset; @@ -162,7 +162,7 @@ void Mesh::draw() { void Mesh::bindVAO(GLuint vao) { /** @todo Get some extension wrangler instead to avoid linker errors to glBindVertexArray() on ES2 */ #ifndef MAGNUM_TARGET_GLES2 - GLuint& current = Context::current()->state()->mesh->currentVAO; + GLuint& current = Context::current()->state().mesh->currentVAO; if(current != vao) glBindVertexArray(current = vao); #else static_cast(vao); @@ -191,16 +191,16 @@ void Mesh::vertexAttribPointer(const LongAttribute& attribute) { #endif #endif -void Mesh::initializeContextBasedFunctionality(Context* context) { +void Mesh::initializeContextBasedFunctionality(Context& context) { /** @todo VAOs are in ES 3.0 and as extension in ES 2.0, enable them when some extension wrangler is available */ #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "Mesh: using" << Extensions::GL::APPLE::vertex_array_object::string() << "features"; createImplementation = &Mesh::createImplementationVAO; destroyImplementation = &Mesh::destroyImplementationVAO; - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "Mesh: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; attributePointerImplementation = &Mesh::attributePointerImplementationDSA; @@ -299,18 +299,18 @@ void Mesh::attributePointerImplementationDSA(const LongAttribute& attribute) { #endif #endif -void Mesh::bindIndexBufferImplementationDefault(Buffer* buffer) { - indexBuffer = buffer; +void Mesh::bindIndexBufferImplementationDefault(Buffer& buffer) { + indexBuffer = &buffer; } -void Mesh::bindIndexBufferImplementationVAO(Buffer* buffer) { +void Mesh::bindIndexBufferImplementationVAO(Buffer& buffer) { bindVAO(vao); /* Reset ElementArray binding to force explicit glBindBuffer call later */ /** @todo Do this cleaner way */ - Context::current()->state()->buffer->bindings[Implementation::BufferState::indexForTarget(Buffer::Target::ElementArray)] = 0; + Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(Buffer::Target::ElementArray)] = 0; - buffer->bind(Buffer::Target::ElementArray); + buffer.bind(Buffer::Target::ElementArray); } void Mesh::bindImplementationDefault() { diff --git a/src/Mesh.h b/src/Mesh.h index bc37733f1..5afadf688 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -57,9 +57,10 @@ conveniently compress the indices, fill the index buffer and configure the mesh instead of calling setIndexCount() and setIndexBuffer() manually. Note that neither vertex buffers nor index buffer is managed (e.g. deleted on -destruction) by the mesh, so you have to manage them on your own. On the other -hand it allows you to use one buffer for more meshes (each mesh for example -configured for different shader) or store data for more meshes in one buffer. +destruction) by the mesh, so you have to manage them on your own and ensure +that they are available for whole mesh lifetime. On the other hand it allows +you to use one buffer for more meshes (each mesh for example configured for +different shader) or store data for more meshes in one buffer. If the mesh has non-zero index count, it is treated as indexed mesh, otherwise it is treated as non-indexed mesh. If both index and vertex count is zero, the @@ -77,8 +78,8 @@ class MyShader: public AbstractShaderProgram { // ... }; -Mesh mesh; Buffer vertexBuffer; +Mesh mesh; // Fill vertex buffer with position data static constexpr Vector3 positions[30] = { @@ -97,8 +98,8 @@ mesh.setPrimitive(Mesh::Primitive::Triangles) @code // Non-indexed primitive with positions and normals Trade::MeshData3D plane = Primitives::Plane::solid(); -Mesh mesh; Buffer vertexBuffer; +Mesh mesh; // Fill vertex buffer with interleaved position and normal data MeshTools::interleave(mesh, buffer, Buffer::Usage::StaticDraw, @@ -177,23 +178,23 @@ class MyShader: public AbstractShaderProgram { // ... }; -Mesh* mesh; +Mesh mesh; // Fill position buffer with positions specified as two-component XY (i.e., // no Z component, which is meant to be always 0) -Buffer* positionBuffer; +Buffer positionBuffer; Vector2 positions[30] = { // ... }; // Specify layout of positions buffer -- only two components, unspecified Z // component will be automatically set to 0 -mesh->addVertexBuffer(positionBuffer, 0, +mesh.addVertexBuffer(positionBuffer, 0, MyShader::Position(MyShader::Position::Components::Two)); // Fill color buffer with colors specified as four-byte BGRA (e.g. directly // from TGA file) -Buffer* colorBuffer; +Buffer colorBuffer; GLubyte colors[4*30] = { // ... }; @@ -201,7 +202,7 @@ colorBuffer.setData(colors, Buffer::Usage::StaticDraw); // Specify layout of color buffer -- BGRA, each component unsigned byte and we // want to normalize them from [0, 255] to [0.0f, 1.0f] -mesh->addVertexBuffer(colorBuffer, 0, MyShader::Color( +mesh.addVertexBuffer(colorBuffer, 0, MyShader::Color( MyShader::Color::Components::BGRA, MyShader::Color::DataType::UnsignedByte, MyShader::Color::DataOption::Normalized)); @@ -425,8 +426,8 @@ class MAGNUM_EXPORT Mesh { * but it accepts only position and normal, so you have to skip the * texture coordinate array: * @code - * Mesh mesh; * Buffer buffer; + * Mesh mesh; * mesh.addVertexBuffer(buffer, * 35, // offset of the data * Shaders::PhongShader::Position(), // position array @@ -457,7 +458,7 @@ class MAGNUM_EXPORT Mesh { * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} * if @extension{APPLE,vertex_array_object} is available */ - template Mesh& addVertexBuffer(Buffer* buffer, GLintptr offset, const T&... attributes); + template Mesh& addVertexBuffer(Buffer& buffer, GLintptr offset, const T&... attributes); /** * @brief Add buffer with interleaved vertex attributes for use with given shader @@ -478,8 +479,8 @@ class MAGNUM_EXPORT Mesh { * position and normal, so you have to skip weight and texture * coordinate in each vertex: * @code - * Mesh mesh; * Buffer buffer; + * Mesh mesh; * mesh.addInterleavedVertexBuffer(buffer, * 35, // skip other data * sizeof(Float), // skip vertex weight @@ -517,7 +518,7 @@ class MAGNUM_EXPORT Mesh { * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} * if @extension{APPLE,vertex_array_object} is available */ - template inline Mesh& addInterleavedVertexBuffer(Buffer* buffer, GLintptr offset, const T&... attributes) { + template inline Mesh& addInterleavedVertexBuffer(Buffer& buffer, GLintptr offset, const T&... attributes) { addInterleavedVertexBufferInternal(buffer, offset, strideOfInterleaved(attributes...), attributes...); return *this; } @@ -528,7 +529,7 @@ class MAGNUM_EXPORT Mesh { * * See addInterleavedVertexBuffer() for more information. */ - template inline Mesh& addVertexBufferStride(Buffer* buffer, GLintptr offset, GLsizei stride, const AbstractShaderProgram::Attribute& attribute) { + template inline Mesh& addVertexBufferStride(Buffer& buffer, GLintptr offset, GLsizei stride, const AbstractShaderProgram::Attribute& attribute) { addInterleavedVertexBufferInternal(buffer, offset, stride, attribute); return *this; } @@ -553,7 +554,7 @@ class MAGNUM_EXPORT Mesh { * @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if * @extension{APPLE,vertex_array_object} is available) */ - Mesh& setIndexBuffer(Buffer* buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end); + Mesh& setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end); /** * @brief Set index buffer @@ -568,7 +569,7 @@ class MAGNUM_EXPORT Mesh { * @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if * @extension{APPLE,vertex_array_object} is available) */ - Mesh& setIndexBuffer(Buffer* buffer, GLintptr offset, IndexType type) { + Mesh& setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type) { return setIndexBuffer(buffer, offset, type, 0, 0); } @@ -620,20 +621,20 @@ class MAGNUM_EXPORT Mesh { #endif #endif - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); /* Adding non-interleaved vertex attributes */ - template inline void addVertexBufferInternal(Buffer* buffer, GLintptr offset, const AbstractShaderProgram::Attribute& attribute, const U&... attributes) { + template inline void addVertexBufferInternal(Buffer& buffer, GLintptr offset, const AbstractShaderProgram::Attribute& attribute, const U&... attributes) { addVertexAttribute(buffer, attribute, offset, 0); /* Add size of this attribute array to offset for next attribute */ addVertexBufferInternal(buffer, offset+attribute.dataSize()*_vertexCount, attributes...); } - template inline void addVertexBufferInternal(Buffer* buffer, GLintptr offset, GLintptr gap, const T&... attributes) { + template inline void addVertexBufferInternal(Buffer& buffer, GLintptr offset, GLintptr gap, const T&... attributes) { /* Add the gap to offset for next attribute */ addVertexBufferInternal(buffer, offset+gap, attributes...); } - inline void addVertexBufferInternal(Buffer*, GLintptr) {} + inline void addVertexBufferInternal(Buffer&, GLintptr) {} /* Computing stride of interleaved vertex attributes */ template inline static GLsizei strideOfInterleaved(const AbstractShaderProgram::Attribute& attribute, const U&... attributes) { @@ -645,22 +646,22 @@ class MAGNUM_EXPORT Mesh { inline static GLsizei strideOfInterleaved() { return 0; } /* Adding interleaved vertex attributes */ - template inline void addInterleavedVertexBufferInternal(Buffer* buffer, GLintptr offset, GLsizei stride, const AbstractShaderProgram::Attribute& attribute, const U&... attributes) { + template inline void addInterleavedVertexBufferInternal(Buffer& buffer, GLintptr offset, GLsizei stride, const AbstractShaderProgram::Attribute& attribute, const U&... attributes) { addVertexAttribute(buffer, attribute, offset, stride); /* Add size of this attribute to offset for next attribute */ addInterleavedVertexBufferInternal(buffer, offset+attribute.dataSize(), stride, attributes...); } - template inline void addInterleavedVertexBufferInternal(Buffer* buffer, GLintptr offset, GLsizei stride, GLintptr gap, const T&... attributes) { + template inline void addInterleavedVertexBufferInternal(Buffer& buffer, GLintptr offset, GLsizei stride, GLintptr gap, const T&... attributes) { /* Add the gap to offset for next attribute */ addInterleavedVertexBufferInternal(buffer, offset+gap, stride, attributes...); } - inline void addInterleavedVertexBufferInternal(Buffer*, GLsizei, GLintptr) {} + inline void addInterleavedVertexBufferInternal(Buffer&, GLsizei, GLintptr) {} - template inline void addVertexAttribute(typename std::enable_if::Type, Float>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { + template inline void addVertexAttribute(typename std::enable_if::Type, Float>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { for(UnsignedInt i = 0; i != Implementation::Attribute::vectorCount(); ++i) (this->*attributePointerImplementation)(Attribute{ - buffer, + &buffer, location+i, static_cast(attribute.components()), static_cast(attribute.dataType()), @@ -671,9 +672,9 @@ class MAGNUM_EXPORT Mesh { } #ifndef MAGNUM_TARGET_GLES2 - template inline void addVertexAttribute(typename std::enable_if::Type>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { + template inline void addVertexAttribute(typename std::enable_if::Type>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { (this->*attributeIPointerImplementation)(IntegerAttribute{ - buffer, + &buffer, location, static_cast(attribute.components()), static_cast(attribute.dataType()), @@ -683,10 +684,10 @@ class MAGNUM_EXPORT Mesh { } #ifndef MAGNUM_TARGET_GLES - template inline void addVertexAttribute(typename std::enable_if::Type, Double>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { + template inline void addVertexAttribute(typename std::enable_if::Type, Double>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { for(UnsignedInt i = 0; i != Implementation::Attribute::vectorCount(); ++i) (this->*attributeLPointerImplementation)(LongAttribute{ - buffer, + &buffer, location+i, static_cast(attribute.components()), static_cast(attribute.dataType()), @@ -743,9 +744,9 @@ class MAGNUM_EXPORT Mesh { #endif #endif - typedef void(Mesh::*BindIndexBufferImplementation)(Buffer*); - void MAGNUM_LOCAL bindIndexBufferImplementationDefault(Buffer* buffer); - void MAGNUM_LOCAL bindIndexBufferImplementationVAO(Buffer* buffer); + typedef void(Mesh::*BindIndexBufferImplementation)(Buffer&); + void MAGNUM_LOCAL bindIndexBufferImplementationDefault(Buffer& buffer); + void MAGNUM_LOCAL bindIndexBufferImplementationVAO(Buffer& buffer); static MAGNUM_LOCAL BindIndexBufferImplementation bindIndexBufferImplementation; typedef void(Mesh::*BindImplementation)(); @@ -783,7 +784,7 @@ 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) { +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); diff --git a/src/Renderbuffer.cpp b/src/Renderbuffer.cpp index 36237aa0b..82562a66d 100644 --- a/src/Renderbuffer.cpp +++ b/src/Renderbuffer.cpp @@ -42,14 +42,14 @@ Renderbuffer::StorageMultisampleImplementation Renderbuffer::storageMultisampleI Renderbuffer::~Renderbuffer() { /* If bound, remove itself from state */ - GLuint& binding = Context::current()->state()->framebuffer->renderbufferBinding; + GLuint& binding = Context::current()->state().framebuffer->renderbufferBinding; if(binding == _id) binding = 0; glDeleteRenderbuffers(1, &_id); } void Renderbuffer::bind() { - GLuint& binding = Context::current()->state()->framebuffer->renderbufferBinding; + GLuint& binding = Context::current()->state().framebuffer->renderbufferBinding; if(binding == _id) return; @@ -57,20 +57,20 @@ void Renderbuffer::bind() { glBindRenderbuffer(GL_RENDERBUFFER, _id); } -void Renderbuffer::initializeContextBasedFunctionality(Context* context) { +void Renderbuffer::initializeContextBasedFunctionality(Context& context) { #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "Renderbuffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; storageImplementation = &Renderbuffer::storageImplementationDSA; storageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationDSA; } #elif !defined(MAGNUM_TARGET_GLES3) - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "Renderbuffer: using" << Extensions::GL::ANGLE::framebuffer_multisample::string() << "features"; storageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationANGLE; - } else if (context->isExtensionSupported()) { + } else if (context.isExtensionSupported()) { Debug() << "Renderbuffer: using" << Extensions::GL::NV::framebuffer_multisample::string() << "features"; storageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationNV; diff --git a/src/Renderbuffer.h b/src/Renderbuffer.h index b4b425386..6e30d85d5 100644 --- a/src/Renderbuffer.h +++ b/src/Renderbuffer.h @@ -114,7 +114,7 @@ class MAGNUM_EXPORT Renderbuffer { } private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); typedef void(Renderbuffer::*StorageImplementation)(RenderbufferFormat, const Vector2i&); void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size); diff --git a/src/Renderer.cpp b/src/Renderer.cpp index d823af8d8..77db22f6c 100644 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -164,7 +164,7 @@ void Renderer::setLogicOperation(const LogicOperation operation) { #ifndef MAGNUM_TARGET_GLES3 Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() { - ResetNotificationStrategy& strategy = Context::current()->state()->renderer->resetNotificationStrategy; + ResetNotificationStrategy& strategy = Context::current()->state().renderer->resetNotificationStrategy; if(strategy == ResetNotificationStrategy()) { #ifndef MAGNUM_TARGET_GLES @@ -178,9 +178,9 @@ Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() { } #endif -void Renderer::initializeContextBasedFunctionality(Context* context) { +void Renderer::initializeContextBasedFunctionality(Context& context) { #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) { + if(context.isExtensionSupported()) { Debug() << "Renderer: using" << Extensions::GL::ARB::ES2_compatibility::string() << "features"; clearDepthfImplementation = &Renderer::clearDepthfImplementationES; @@ -189,9 +189,9 @@ void Renderer::initializeContextBasedFunctionality(Context* context) { #ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES - if(context->isExtensionSupported()) + if(context.isExtensionSupported()) #else - if(context->isExtensionSupported()) + if(context.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Renderer.h b/src/Renderer.h index e6cbc7609..cbef32112 100644 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -1026,7 +1026,7 @@ class MAGNUM_EXPORT Renderer { /*@}*/ private: - static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); + static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context); typedef void(*ClearDepthfImplementation)(GLfloat); #ifndef MAGNUM_TARGET_GLES diff --git a/src/Resource.h b/src/Resource.h index 888f2b6dd..be5619d45 100644 --- a/src/Resource.h +++ b/src/Resource.h @@ -178,15 +178,15 @@ class Resource { } /** - * @brief %Resource data + * @brief Reference to resource data * * The resource must be loaded before accessing it. Use boolean * conversion operator or state() for testing whether it is loaded. */ - operator U*() { + operator U&() { acquire(); - CORRADE_ASSERT(data, "Resource: accessing not loaded data with key" << key(), nullptr); - return static_cast(data); + CORRADE_ASSERT(data, "Resource: accessing not loaded data with key" << key(), *static_cast(data)); + return *static_cast(data); } /** @overload */ diff --git a/src/ResourceManager.h b/src/ResourceManager.h index 7bb276b23..a1d4df745 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -225,8 +225,12 @@ cube->draw(); template implementation file. */ template class ResourceManager: private Implementation::ResourceManagerData... { public: - /** @brief Global instance */ - static ResourceManager* instance(); + /** + * @brief Global instance + * + * Assumes that the instance exists. + */ + static ResourceManager& instance(); /** * @brief Constructor @@ -391,6 +395,7 @@ template class ResourceManager: private Implementation::Resource /** * @brief Set loader for given type of resources + * @param loader Loader or `nullptr` if unsetting previous loader. * @return Reference to self (for method chaining) * * See AbstractResourceLoader documentation for more information. @@ -580,9 +585,9 @@ template inline ResourceManagerData::Data::~Data() { } -template ResourceManager* ResourceManager::instance() { - CORRADE_ASSERT(internalInstance(), "ResourceManager::instance(): no instance exists", nullptr); - return internalInstance(); +template ResourceManager& ResourceManager::instance() { + CORRADE_ASSERT(internalInstance(), "ResourceManager::instance(): no instance exists", *internalInstance()); + return *internalInstance(); } template ResourceManager::ResourceManager() { diff --git a/src/Sampler.cpp b/src/Sampler.cpp index 648822415..2d65ffe11 100644 --- a/src/Sampler.cpp +++ b/src/Sampler.cpp @@ -47,7 +47,7 @@ static_assert((filter_or(Nearest, Base) == GL_NEAREST) && #ifndef MAGNUM_TARGET_GLES3 Float Sampler::maxSupportedAnisotropy() { - GLfloat& value = Context::current()->state()->texture->maxSupportedAnisotropy; + GLfloat& value = Context::current()->state().texture->maxSupportedAnisotropy; /** @todo Re-enable when extension header is available */ #ifndef MAGNUM_TARGET_GLES diff --git a/src/Test/ResourceManagerTest.cpp b/src/Test/ResourceManagerTest.cpp index 1e977c70e..c6d38cf02 100644 --- a/src/Test/ResourceManagerTest.cpp +++ b/src/Test/ResourceManagerTest.cpp @@ -262,7 +262,7 @@ void ResourceManagerTest::clearWhileReferenced() { void ResourceManagerTest::loader() { class IntResourceLoader: public AbstractResourceLoader { public: - IntResourceLoader(): resource(ResourceManager::instance()->get("data")) {} + IntResourceLoader(): resource(ResourceManager::instance().get("data")) {} void load() { set("hello", new Int(773), ResourceDataState::Final, ResourcePolicy::Resident);