Browse Source

Reducing pointer chasings, part 3a: less pointer passing in root namespace.

Passing pointer as function parameter will now mean that it is possible
to pass `nullptr`. Some code examples now look like the parameter is
copied instead of referenced, which is misleading. Updated the
documentation to reflect that more clearly.
pull/277/head
Vladimír Vondruš 13 years ago
parent
commit
e19154be5e
  1. 18
      src/AbstractFramebuffer.cpp
  2. 2
      src/AbstractFramebuffer.h
  3. 14
      src/AbstractShaderProgram.cpp
  4. 2
      src/AbstractShaderProgram.h
  5. 42
      src/AbstractTexture.cpp
  6. 2
      src/AbstractTexture.h
  7. 20
      src/Buffer.cpp
  8. 10
      src/Buffer.h
  9. 2
      src/BufferImage.h
  10. 20
      src/BufferTexture.cpp
  11. 25
      src/BufferTexture.h
  12. 22
      src/Context.cpp
  13. 2
      src/Context.h
  14. 4
      src/CubeMapTexture.h
  15. 4
      src/DebugMarker.cpp
  16. 2
      src/DebugMarker.h
  17. 6
      src/DefaultFramebuffer.cpp
  18. 4
      src/DefaultFramebuffer.h
  19. 34
      src/Framebuffer.cpp
  20. 46
      src/Framebuffer.h
  21. 26
      src/Mesh.cpp
  22. 69
      src/Mesh.h
  23. 12
      src/Renderbuffer.cpp
  24. 2
      src/Renderbuffer.h
  25. 10
      src/Renderer.cpp
  26. 2
      src/Renderer.h
  27. 8
      src/Resource.h
  28. 15
      src/ResourceManager.h
  29. 2
      src/Sampler.cpp
  30. 2
      src/Test/ResourceManagerTest.cpp

18
src/AbstractFramebuffer.cpp

@ -53,7 +53,7 @@ void AbstractFramebuffer::bind(FramebufferTarget target) {
} }
void AbstractFramebuffer::bindInternal(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 already bound, done, otherwise update tracked state */
if(target == FramebufferTarget::Read) { if(target == FramebufferTarget::Read) {
@ -71,7 +71,7 @@ void AbstractFramebuffer::bindInternal(FramebufferTarget target) {
} }
FramebufferTarget AbstractFramebuffer::bindInternal() { 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 */ /* Return target to which the framebuffer is already bound */
if(state->readBinding == _id && state->drawBinding == _id) if(state->readBinding == _id && state->drawBinding == _id)
@ -112,14 +112,14 @@ AbstractFramebuffer& AbstractFramebuffer::setViewport(const Rectanglei& rectangl
_viewport = rectangle; _viewport = rectangle;
/* Update the viewport if the framebuffer is currently bound */ /* Update the viewport if the framebuffer is currently bound */
if(Context::current()->state()->framebuffer->drawBinding == _id) if(Context::current()->state().framebuffer->drawBinding == _id)
setViewportInternal(); setViewportInternal();
return *this; return *this;
} }
void AbstractFramebuffer::setViewportInternal() { void AbstractFramebuffer::setViewportInternal() {
Implementation::FramebufferState* state = Context::current()->state()->framebuffer; Implementation::FramebufferState* state = Context::current()->state().framebuffer;
CORRADE_INTERNAL_ASSERT(state->drawBinding == _id); CORRADE_INTERNAL_ASSERT(state->drawBinding == _id);
@ -165,7 +165,7 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Buf
if(image.size() != size) if(image.size() != size)
image.setData(size, image.format(), image.type(), nullptr, usage); 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 */ /** @todo De-duplicate buffer size computation */
readImplementation(offset, size, image.format(), image.type(), image.pixelSize()*size.product(), nullptr); readImplementation(offset, size, image.format(), image.type(), image.pixelSize()*size.product(), nullptr);
} }
@ -194,9 +194,9 @@ void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attach
#endif #endif
} }
void AbstractFramebuffer::initializeContextBasedFunctionality(Context* context) { void AbstractFramebuffer::initializeContextBasedFunctionality(Context& context) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
Debug() << "AbstractFramebuffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; Debug() << "AbstractFramebuffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features";
checkStatusImplementation = &AbstractFramebuffer::checkStatusImplementationDSA; checkStatusImplementation = &AbstractFramebuffer::checkStatusImplementationDSA;
@ -234,9 +234,9 @@ void AbstractFramebuffer::initializeContextBasedFunctionality(Context* context)
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::ARB::robustness>()) if(context.isExtensionSupported<Extensions::GL::ARB::robustness>())
#else #else
if(context->isExtensionSupported<Extensions::GL::EXT::robustness>()) if(context.isExtensionSupported<Extensions::GL::EXT::robustness>())
#endif #endif
{ {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

2
src/AbstractFramebuffer.h

@ -297,7 +297,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
Rectanglei _viewport; Rectanglei _viewport;
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
GLenum MAGNUM_LOCAL checkStatusImplementationDefault(FramebufferTarget target); GLenum MAGNUM_LOCAL checkStatusImplementationDefault(FramebufferTarget target);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

14
src/AbstractShaderProgram.cpp

@ -77,7 +77,7 @@ AbstractShaderProgram::UniformMatrix4x3dvImplementation AbstractShaderProgram::u
#endif #endif
Int AbstractShaderProgram::maxSupportedVertexAttributeCount() { Int AbstractShaderProgram::maxSupportedVertexAttributeCount() {
GLint& value = Context::current()->state()->shaderProgram->maxSupportedVertexAttributeCount; GLint& value = Context::current()->state().shaderProgram->maxSupportedVertexAttributeCount;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -94,7 +94,7 @@ AbstractShaderProgram::AbstractShaderProgram(AbstractShaderProgram&& other) noex
AbstractShaderProgram::~AbstractShaderProgram() { AbstractShaderProgram::~AbstractShaderProgram() {
/* Remove current usage from the state */ /* 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(current == _id) current = 0;
if(_id) glDeleteProgram(_id); if(_id) glDeleteProgram(_id);
@ -125,7 +125,7 @@ std::pair<bool, std::string> AbstractShaderProgram::validate() {
void AbstractShaderProgram::use() { void AbstractShaderProgram::use() {
/* Use only if the program isn't already in 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); if(current != _id) glUseProgram(current = _id);
} }
@ -189,12 +189,12 @@ Int AbstractShaderProgram::uniformLocation(const std::string& name) {
return location; 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 */ /** @todo OpenGL ES 2 has extension @es_extension{EXT,separate_shader_objects} for this */
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::ARB::separate_shader_objects>() || if(context.isExtensionSupported<Extensions::GL::ARB::separate_shader_objects>() ||
context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
Debug() << "AbstractShaderProgram: using" << (context->isExtensionSupported<Extensions::GL::ARB::separate_shader_objects>() ? Debug() << "AbstractShaderProgram: using" << (context.isExtensionSupported<Extensions::GL::ARB::separate_shader_objects>() ?
Extensions::GL::ARB::separate_shader_objects::string() : Extensions::GL::EXT::direct_state_access::string()) << "features"; Extensions::GL::ARB::separate_shader_objects::string() : Extensions::GL::EXT::direct_state_access::string()) << "features";
uniform1fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniform1fvImplementation = &AbstractShaderProgram::uniformImplementationDSA;
uniform2fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniform2fvImplementation = &AbstractShaderProgram::uniformImplementationDSA;

2
src/AbstractShaderProgram.h

@ -774,7 +774,7 @@ class MAGNUM_EXPORT AbstractShaderProgram {
#endif #endif
private: 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::*Uniform1fvImplementation)(GLint, GLsizei, const GLfloat*);
typedef void(AbstractShaderProgram::*Uniform2fvImplementation)(GLint, GLsizei, const Math::Vector<2, GLfloat>*); typedef void(AbstractShaderProgram::*Uniform2fvImplementation)(GLint, GLsizei, const Math::Vector<2, GLfloat>*);

42
src/AbstractTexture.cpp

@ -81,7 +81,7 @@ AbstractTexture::InvalidateImageImplementation AbstractTexture::invalidateImageI
AbstractTexture::InvalidateSubImageImplementation AbstractTexture::invalidateSubImageImplementation = &AbstractTexture::invalidateSubImageImplementationNoOp; AbstractTexture::InvalidateSubImageImplementation AbstractTexture::invalidateSubImageImplementation = &AbstractTexture::invalidateSubImageImplementationNoOp;
Int AbstractTexture::maxSupportedLayerCount() { Int AbstractTexture::maxSupportedLayerCount() {
return Context::current()->state()->texture->maxSupportedLayerCount; return Context::current()->state().texture->maxSupportedLayerCount;
} }
void AbstractTexture::destroy() { void AbstractTexture::destroy() {
@ -89,7 +89,7 @@ void AbstractTexture::destroy() {
if(!_id) return; if(!_id) return;
/* Remove all bindings */ /* Remove all bindings */
for(GLuint& binding: Context::current()->state()->texture->bindings) for(GLuint& binding: Context::current()->state().texture->bindings)
if(binding == _id) binding = 0; if(binding == _id) binding = 0;
glDeleteTextures(1, &_id); glDeleteTextures(1, &_id);
@ -120,7 +120,7 @@ AbstractTexture& AbstractTexture::operator=(AbstractTexture&& other) {
} }
void AbstractTexture::bind(Int layer) { 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 already bound in given layer, nothing to do */
if(textureState->bindings[layer] == _id) return; if(textureState->bindings[layer] == _id) return;
@ -129,7 +129,7 @@ void AbstractTexture::bind(Int layer) {
} }
void AbstractTexture::bindImplementationDefault(GLint 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 */ /* Change to given layer, if not already there */
if(textureState->currentLayer != layer) if(textureState->currentLayer != layer)
@ -141,7 +141,7 @@ void AbstractTexture::bindImplementationDefault(GLint layer) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::bindImplementationDSA(GLint layer) { 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 #endif
@ -176,7 +176,7 @@ void AbstractTexture::mipmapImplementationDSA() {
#endif #endif
void AbstractTexture::bindInternal() { 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 the texture is already bound in current layer, nothing to do */
if(textureState->bindings[textureState->currentLayer] == _id) if(textureState->bindings[textureState->currentLayer] == _id)
@ -192,8 +192,8 @@ void AbstractTexture::bindInternal() {
glBindTexture(_target, (textureState->bindings[internalLayer] = _id)); glBindTexture(_target, (textureState->bindings[internalLayer] = _id));
} }
void AbstractTexture::initializeContextBasedFunctionality(Context* context) { void AbstractTexture::initializeContextBasedFunctionality(Context& context) {
Implementation::TextureState* const textureState = context->state()->texture; Implementation::TextureState* const textureState = context.state().texture;
GLint& value = textureState->maxSupportedLayerCount; GLint& value = textureState->maxSupportedLayerCount;
/* Get the value and resize bindings array */ /* Get the value and resize bindings array */
@ -201,7 +201,7 @@ void AbstractTexture::initializeContextBasedFunctionality(Context* context) {
textureState->bindings.resize(value); textureState->bindings.resize(value);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
Debug() << "AbstractTexture: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; Debug() << "AbstractTexture: using" << Extensions::GL::EXT::direct_state_access::string() << "features";
bindImplementation = &AbstractTexture::bindImplementationDSA; bindImplementation = &AbstractTexture::bindImplementationDSA;
@ -219,24 +219,24 @@ void AbstractTexture::initializeContextBasedFunctionality(Context* context) {
subImage3DImplementation = &AbstractTexture::subImageImplementationDSA; subImage3DImplementation = &AbstractTexture::subImageImplementationDSA;
} }
if(context->isExtensionSupported<Extensions::GL::ARB::invalidate_subdata>()) { if(context.isExtensionSupported<Extensions::GL::ARB::invalidate_subdata>()) {
Debug() << "AbstractTexture: using" << Extensions::GL::ARB::invalidate_subdata::string() << "features"; Debug() << "AbstractTexture: using" << Extensions::GL::ARB::invalidate_subdata::string() << "features";
invalidateImageImplementation = &AbstractTexture::invalidateImageImplementationARB; invalidateImageImplementation = &AbstractTexture::invalidateImageImplementationARB;
invalidateSubImageImplementation = &AbstractTexture::invalidateSubImageImplementationARB; invalidateSubImageImplementation = &AbstractTexture::invalidateSubImageImplementationARB;
} }
if(context->isExtensionSupported<Extensions::GL::ARB::robustness>() && if(context.isExtensionSupported<Extensions::GL::ARB::robustness>() &&
!context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { !context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
Debug() << "AbstractTexture: using" << Extensions::GL::ARB::robustness::string() << "features"; Debug() << "AbstractTexture: using" << Extensions::GL::ARB::robustness::string() << "features";
getImageImplementation = &AbstractTexture::getImageImplementationRobustness; getImageImplementation = &AbstractTexture::getImageImplementationRobustness;
} }
if(context->isExtensionSupported<Extensions::GL::ARB::texture_storage>()) { if(context.isExtensionSupported<Extensions::GL::ARB::texture_storage>()) {
Debug() << "AbstractTexture: using" << Extensions::GL::ARB::texture_storage::string() << "features"; Debug() << "AbstractTexture: using" << Extensions::GL::ARB::texture_storage::string() << "features";
if(context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
storage1DImplementation = &AbstractTexture::storageImplementationDSA; storage1DImplementation = &AbstractTexture::storageImplementationDSA;
storage2DImplementation = &AbstractTexture::storageImplementationDSA; storage2DImplementation = &AbstractTexture::storageImplementationDSA;
storage3DImplementation = &AbstractTexture::storageImplementationDSA; storage3DImplementation = &AbstractTexture::storageImplementationDSA;
@ -981,7 +981,7 @@ template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLin
if(image.size() != size) if(image.size() != size)
image.setData(size, image.format(), image.type(), nullptr, usage); 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); (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) { 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); (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) { 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); (texture->*subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif
@ -1046,7 +1046,7 @@ void AbstractTexture::DataHelper<2>::setImage(AbstractTexture* const texture, co
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) { 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); (texture->*image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif
@ -1060,7 +1060,7 @@ void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture* const texture,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector2i& offset, BufferImage2D& image) { 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); (texture->*subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif
@ -1074,7 +1074,7 @@ void AbstractTexture::DataHelper<3>::setImage(AbstractTexture* const texture, co
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) { 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); (texture->*image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif
@ -1088,7 +1088,7 @@ void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture* const texture,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector3i& offset, BufferImage3D& image) { 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); (texture->*subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif

2
src/AbstractTexture.h

@ -281,7 +281,7 @@ class MAGNUM_EXPORT AbstractTexture {
GLenum _target; GLenum _target;
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
typedef void(AbstractTexture::*BindImplementation)(GLint); typedef void(AbstractTexture::*BindImplementation)(GLint);
void MAGNUM_LOCAL bindImplementationDefault(GLint layer); void MAGNUM_LOCAL bindImplementationDefault(GLint layer);

20
src/Buffer.cpp

@ -51,9 +51,9 @@ Buffer::MapRangeImplementation Buffer::mapRangeImplementation = &Buffer::mapRang
Buffer::FlushMappedRangeImplementation Buffer::flushMappedRangeImplementation = &Buffer::flushMappedRangeImplementationDefault; Buffer::FlushMappedRangeImplementation Buffer::flushMappedRangeImplementation = &Buffer::flushMappedRangeImplementationDefault;
Buffer::UnmapImplementation Buffer::unmapImplementation = &Buffer::unmapImplementationDefault; Buffer::UnmapImplementation Buffer::unmapImplementation = &Buffer::unmapImplementationDefault;
void Buffer::initializeContextBasedFunctionality(Context* context) { void Buffer::initializeContextBasedFunctionality(Context& context) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
Debug() << "Buffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; Debug() << "Buffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features";
copyImplementation = &Buffer::copyImplementationDSA; copyImplementation = &Buffer::copyImplementationDSA;
@ -67,7 +67,7 @@ void Buffer::initializeContextBasedFunctionality(Context* context) {
unmapImplementation = &Buffer::unmapImplementationDSA; unmapImplementation = &Buffer::unmapImplementationDSA;
} }
if(context->isExtensionSupported<Extensions::GL::ARB::invalidate_subdata>()) { if(context.isExtensionSupported<Extensions::GL::ARB::invalidate_subdata>()) {
Debug() << "Buffer: using" << Extensions::GL::ARB::invalidate_subdata::string() << "features"; Debug() << "Buffer: using" << Extensions::GL::ARB::invalidate_subdata::string() << "features";
invalidateImplementation = &Buffer::invalidateImplementationARB; invalidateImplementation = &Buffer::invalidateImplementationARB;
@ -87,7 +87,7 @@ Buffer::Buffer(Buffer::Target targetHint): _targetHint(targetHint)
} }
Buffer::~Buffer() { Buffer::~Buffer() {
GLuint* bindings = Context::current()->state()->buffer->bindings; GLuint* bindings = Context::current()->state().buffer->bindings;
/* Remove all current bindings from the state */ /* Remove all current bindings from the state */
for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i) for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i)
@ -97,7 +97,7 @@ Buffer::~Buffer() {
} }
void Buffer::bind(Target target, GLuint id) { 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 */ /* Already bound, nothing to do */
if(bound == id) return; if(bound == id) return;
@ -108,7 +108,7 @@ void Buffer::bind(Target target, GLuint id) {
} }
Buffer::Target Buffer::bindInternal(Target hint) { 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)]; GLuint& hintBinding = bindings[Implementation::BufferState::indexForTarget(hint)];
/* Shortcut - if already bound to hint, return */ /* Shortcut - if already bound to hint, return */
@ -161,13 +161,13 @@ void Buffer::unmapSub() {
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void Buffer::copyImplementationDefault(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { void Buffer::copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
glCopyBufferSubData(static_cast<GLenum>(read->bindInternal(Target::CopyRead)), static_cast<GLenum>(write->bindInternal(Target::CopyWrite)), readOffset, writeOffset, size); glCopyBufferSubData(static_cast<GLenum>(read.bindInternal(Target::CopyRead)), static_cast<GLenum>(write.bindInternal(Target::CopyWrite)), readOffset, writeOffset, size);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void Buffer::copyImplementationDSA(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { void Buffer::copyImplementationDSA(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
glNamedCopyBufferSubDataEXT(read->_id, write->_id, readOffset, writeOffset, size); glNamedCopyBufferSubDataEXT(read._id, write._id, readOffset, writeOffset, size);
} }
#endif #endif
#endif #endif

10
src/Buffer.h

@ -459,7 +459,7 @@ class MAGNUM_EXPORT Buffer {
* @requires_gl31 %Extension @extension{ARB,copy_buffer} * @requires_gl31 %Extension @extension{ARB,copy_buffer}
* @requires_gles30 %Buffer copying is not available in OpenGL ES 2.0. * @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); copyImplementation(read, write, readOffset, writeOffset, size);
} }
#endif #endif
@ -826,16 +826,16 @@ class MAGNUM_EXPORT Buffer {
#endif #endif
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
static void bind(Target hint, GLuint id); static void bind(Target hint, GLuint id);
Target MAGNUM_LOCAL bindInternal(Target hint); Target MAGNUM_LOCAL bindInternal(Target hint);
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
typedef void(*CopyImplementation)(Buffer*, Buffer*, GLintptr, GLintptr, GLsizeiptr); typedef void(*CopyImplementation)(Buffer&, Buffer&, GLintptr, GLintptr, GLsizeiptr);
static void MAGNUM_LOCAL copyImplementationDefault(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); static void MAGNUM_LOCAL copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
#ifndef MAGNUM_TARGET_GLES #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 #endif
static CopyImplementation copyImplementation; static CopyImplementation copyImplementation;
#endif #endif

2
src/BufferImage.h

@ -66,7 +66,7 @@ template<UnsignedInt dimensions> class MAGNUM_EXPORT BufferImage: public Abstrac
typename DimensionTraits<Dimensions, Int>::VectorType size() const { return _size; } typename DimensionTraits<Dimensions, Int>::VectorType size() const { return _size; }
/** @brief %Image buffer */ /** @brief %Image buffer */
Buffer* buffer() { return &_buffer; } Buffer& buffer() { return _buffer; }
/** /**
* @brief Set image data * @brief Set image data

20
src/BufferTexture.cpp

@ -34,8 +34,8 @@ namespace Magnum {
BufferTexture::SetBufferImplementation BufferTexture::setBufferImplementation = &BufferTexture::setBufferImplementationDefault; BufferTexture::SetBufferImplementation BufferTexture::setBufferImplementation = &BufferTexture::setBufferImplementationDefault;
BufferTexture::SetBufferRangeImplementation BufferTexture::setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDefault; BufferTexture::SetBufferRangeImplementation BufferTexture::setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDefault;
void BufferTexture::initializeContextBasedFunctionality(Context* context) { void BufferTexture::initializeContextBasedFunctionality(Context& context) {
if(context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
Debug() << "BufferTexture: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; Debug() << "BufferTexture: using" << Extensions::GL::EXT::direct_state_access::string() << "features";
setBufferImplementation = &BufferTexture::setBufferImplementationDSA; 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(); bindInternal();
glTexBuffer(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id()); glTexBuffer(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id());
} }
void BufferTexture::setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer) { void BufferTexture::setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer) {
glTextureBufferEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id()); 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(); 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) { void BufferTexture::setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size) {
glTextureBufferRangeEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id(), offset, size); glTextureBufferRangeEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id(), offset, size);
} }
} }

25
src/BufferTexture.h

@ -164,12 +164,13 @@ using setBuffer(), you can fill the buffer at any time using data setting
functions in Buffer itself. functions in Buffer itself.
Note that the buffer is not managed (e.g. deleted on destruction) by the 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 texture, so you have to manage it on your own and ensure that it is available
to use one buffer for more textures or store more than one data in it. 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: Example usage:
@code @code
Buffer* buffer; Buffer buffer;
BufferTexture texture; BufferTexture texture;
texture.setBuffer(BufferTextureFormat::RGB32F, buffer); 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} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer}
* or @fn_gl_extension{TextureBuffer,EXT,direct_state_access} * 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); (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} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBufferRange}
* or @fn_gl_extension{TextureBufferRange,EXT,direct_state_access} * 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); (this->*setBufferRangeImplementation)(internalFormat, buffer, offset, size);
} }
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
typedef void(BufferTexture::*SetBufferImplementation)(BufferTextureFormat, Buffer*); typedef void(BufferTexture::*SetBufferImplementation)(BufferTextureFormat, Buffer&);
void MAGNUM_LOCAL setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer); void MAGNUM_LOCAL setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer);
void MAGNUM_LOCAL setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer); void MAGNUM_LOCAL setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer);
static SetBufferImplementation setBufferImplementation; static SetBufferImplementation setBufferImplementation;
typedef void(BufferTexture::*SetBufferRangeImplementation)(BufferTextureFormat, Buffer*, GLintptr, GLsizeiptr); typedef void(BufferTexture::*SetBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr);
void MAGNUM_LOCAL setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); void MAGNUM_LOCAL setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size);
void MAGNUM_LOCAL setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); void MAGNUM_LOCAL setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size);
static SetBufferRangeImplementation setBufferRangeImplementation; static SetBufferRangeImplementation setBufferRangeImplementation;
}; };

22
src/Context.cpp

@ -407,19 +407,19 @@ Context::Context() {
_state = new Implementation::State; _state = new Implementation::State;
/* Initialize functionality based on current OpenGL version and extensions */ /* Initialize functionality based on current OpenGL version and extensions */
AbstractFramebuffer::initializeContextBasedFunctionality(this); AbstractFramebuffer::initializeContextBasedFunctionality(*this);
AbstractShaderProgram::initializeContextBasedFunctionality(this); AbstractShaderProgram::initializeContextBasedFunctionality(*this);
AbstractTexture::initializeContextBasedFunctionality(this); AbstractTexture::initializeContextBasedFunctionality(*this);
Buffer::initializeContextBasedFunctionality(this); Buffer::initializeContextBasedFunctionality(*this);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
BufferTexture::initializeContextBasedFunctionality(this); BufferTexture::initializeContextBasedFunctionality(*this);
#endif #endif
DebugMarker::initializeContextBasedFunctionality(this); DebugMarker::initializeContextBasedFunctionality(*this);
DefaultFramebuffer::initializeContextBasedFunctionality(this); DefaultFramebuffer::initializeContextBasedFunctionality(*this);
Framebuffer::initializeContextBasedFunctionality(this); Framebuffer::initializeContextBasedFunctionality(*this);
Mesh::initializeContextBasedFunctionality(this); Mesh::initializeContextBasedFunctionality(*this);
Renderbuffer::initializeContextBasedFunctionality(this); Renderbuffer::initializeContextBasedFunctionality(*this);
Renderer::initializeContextBasedFunctionality(this); Renderer::initializeContextBasedFunctionality(*this);
} }
Context::~Context() { Context::~Context() {

2
src/Context.h

@ -355,7 +355,7 @@ class MAGNUM_EXPORT Context {
} }
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
Implementation::State* state() { return _state; } Implementation::State& state() { return *_state; }
#endif #endif
private: private:

4
src/CubeMapTexture.h

@ -61,8 +61,8 @@ CubeMapTexture texture;
texture.setMagnificationFilter(Sampler::Filter::Linear) texture.setMagnificationFilter(Sampler::Filter::Linear)
// ... // ...
.setStorage(Math::log2(256)+1, TextureFormat::RGBA8, {256, 256}) .setStorage(Math::log2(256)+1, TextureFormat::RGBA8, {256, 256})
.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, {}, &positiveX) .setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, {}, positiveX)
.setSubImage(CubeMapTexture::Coordinate::NegativeX, 0, {}, &negativeX) .setSubImage(CubeMapTexture::Coordinate::NegativeX, 0, {}, negativeX)
// ... // ...
@endcode @endcode

4
src/DebugMarker.cpp

@ -33,10 +33,10 @@ namespace Magnum {
DebugMarker::MarkImplementation DebugMarker::markImplementation = &DebugMarker::markImplementationDefault; 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 */ /** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::GREMEDY::string_marker>()) { if(context.isExtensionSupported<Extensions::GL::GREMEDY::string_marker>()) {
Debug() << "DebugMarker: using" << Extensions::GL::GREMEDY::string_marker::string() << "features"; Debug() << "DebugMarker: using" << Extensions::GL::GREMEDY::string_marker::string() << "features";
markImplementation = &DebugMarker::markImplementationDebugger; markImplementation = &DebugMarker::markImplementationDebugger;

2
src/DebugMarker.h

@ -58,7 +58,7 @@ class MAGNUM_EXPORT DebugMarker {
} }
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
typedef void(*MarkImplementation)(const std::string&); typedef void(*MarkImplementation)(const std::string&);
static MAGNUM_LOCAL void markImplementationDefault(const std::string& string); static MAGNUM_LOCAL void markImplementationDefault(const std::string& string);

6
src/DefaultFramebuffer.cpp

@ -78,8 +78,8 @@ void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment
delete[] _attachments; delete[] _attachments;
} }
void DefaultFramebuffer::initializeContextBasedFunctionality(Context* context) { void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) {
Implementation::FramebufferState* state = context->state()->framebuffer; Implementation::FramebufferState* state = context.state().framebuffer;
/* Initial framebuffer size */ /* Initial framebuffer size */
GLint viewport[4]; GLint viewport[4];
@ -88,7 +88,7 @@ void DefaultFramebuffer::initializeContextBasedFunctionality(Context* context) {
/* Fake initial glViewport() call for ApiTrace */ /* Fake initial glViewport() call for ApiTrace */
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::GREMEDY::string_marker>()) if(context.isExtensionSupported<Extensions::GL::GREMEDY::string_marker>())
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
#endif #endif
} }

4
src/DefaultFramebuffer.h

@ -58,7 +58,7 @@ any drawing in your @ref Platform::GlutApplication::drawEvent() "drawEvent()"
implementation, for example: implementation, for example:
@code @code
void drawEvent() { 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 #endif
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
}; };
/** @brief Default framebuffer instance */ /** @brief Default framebuffer instance */

34
src/Framebuffer.cpp

@ -60,7 +60,7 @@ Framebuffer::Framebuffer(const Rectanglei& viewport) {
Framebuffer::~Framebuffer() { Framebuffer::~Framebuffer() {
/* If bound, remove itself from state */ /* 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->readBinding == _id) state->readBinding = 0;
if(state->drawBinding == _id) state->drawBinding = 0; if(state->drawBinding == _id) state->drawBinding = 0;
@ -107,15 +107,15 @@ void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attac
delete[] _attachments; 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 */ /** @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; return *this;
} }
void Framebuffer::initializeContextBasedFunctionality(Context* context) { void Framebuffer::initializeContextBasedFunctionality(Context& context) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
Debug() << "Framebuffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; Debug() << "Framebuffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features";
renderbufferImplementation = &Framebuffer::renderbufferImplementationDSA; renderbufferImplementation = &Framebuffer::renderbufferImplementationDSA;
@ -128,21 +128,21 @@ void Framebuffer::initializeContextBasedFunctionality(Context* context) {
#endif #endif
} }
void Framebuffer::renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer* renderbuffer) { void Framebuffer::renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer) {
glFramebufferRenderbuffer(GLenum(bindInternal()), GLenum(attachment), GL_RENDERBUFFER, renderbuffer->id()); glFramebufferRenderbuffer(GLenum(bindInternal()), GLenum(attachment), GL_RENDERBUFFER, renderbuffer.id());
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void Framebuffer::renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer* renderbuffer) { void Framebuffer::renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer) {
glNamedFramebufferRenderbufferEXT(_id, GLenum(attachment), GL_RENDERBUFFER, renderbuffer->id()); glNamedFramebufferRenderbufferEXT(_id, GLenum(attachment), GL_RENDERBUFFER, renderbuffer.id());
} }
void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, Texture1D* texture, GLint mipLevel) { void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, Texture1D& texture, GLint mipLevel) {
glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), static_cast<GLenum>(texture->target()), texture->id(), mipLevel); glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), static_cast<GLenum>(texture.target()), texture.id(), mipLevel);
} }
void Framebuffer::texture1DImplementationDSA(BufferAttachment attachment, Texture1D* texture, GLint mipLevel) { void Framebuffer::texture1DImplementationDSA(BufferAttachment attachment, Texture1D& texture, GLint mipLevel) {
glNamedFramebufferTexture1DEXT(_id, GLenum(attachment), GLenum(texture->target()), texture->id(), mipLevel); glNamedFramebufferTexture1DEXT(_id, GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel);
} }
#endif #endif
@ -156,11 +156,11 @@ void Framebuffer::texture2DImplementationDSA(BufferAttachment attachment, GLenum
} }
#endif #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 Check for texture target compatibility */
/** @todo Get some extension wrangler for glFramebufferTexture3D() (extension only) */ /** @todo Get some extension wrangler for glFramebufferTexture3D() (extension only) */
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glFramebufferTexture3D(GLenum(bindInternal()), GLenum(attachment), static_cast<GLenum>(texture->target()), texture->id(), mipLevel, layer); glFramebufferTexture3D(GLenum(bindInternal()), GLenum(attachment), static_cast<GLenum>(texture.target()), texture.id(), mipLevel, layer);
#else #else
static_cast<void>(attachment); static_cast<void>(attachment);
static_cast<void>(texture); static_cast<void>(texture);
@ -170,8 +170,8 @@ void Framebuffer::texture3DImplementationDefault(BufferAttachment attachment, Te
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void Framebuffer::texture3DImplementationDSA(BufferAttachment attachment, Texture3D* texture, GLint mipLevel, GLint layer) { void Framebuffer::texture3DImplementationDSA(BufferAttachment attachment, Texture3D& texture, GLint mipLevel, GLint layer) {
glNamedFramebufferTexture3DEXT(_id, GLenum(attachment), GLenum(texture->target()), texture->id(), mipLevel, layer); glNamedFramebufferTexture3DEXT(_id, GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel, layer);
} }
#endif #endif

46
src/Framebuffer.h

@ -55,9 +55,9 @@ Renderbuffer depthStencil;
// configure the textures and allocate texture memory... // configure the textures and allocate texture memory...
framebuffer.attachTexture2D(Framebuffer::ColorAttachment(0), &color); framebuffer.attachTexture2D(Framebuffer::ColorAttachment(0), color);
framebuffer.attachTexture2D(Framebuffer::ColorAttachment(1), &normal); framebuffer.attachTexture2D(Framebuffer::ColorAttachment(1), normal);
framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::DepthStencil, &depthStencil); framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::DepthStencil, depthStencil);
@endcode @endcode
Then you need to map outputs of your shader to color attachments in the 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: screen:
@code @code
void drawEvent() { void drawEvent() {
defaultFramebuffer.clear(DefaultFramebuffer::Clear::Color) defaultFramebuffer.clear(FramebufferClear::Color)
framebuffer.clear(Framebuffer::Clear::Color|Framebuffer::Clear::Depth|Framebuffer::Clear::Stencil); 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 @endcode
@ -405,7 +405,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer {
* @see @fn_gl{BindFramebuffer}, @fn_gl{FramebufferRenderbuffer} or * @see @fn_gl{BindFramebuffer}, @fn_gl{FramebufferRenderbuffer} or
* @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access} * @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access}
*/ */
Framebuffer& attachRenderbuffer(BufferAttachment attachment, Renderbuffer* renderbuffer) { Framebuffer& attachRenderbuffer(BufferAttachment attachment, Renderbuffer& renderbuffer) {
(this->*renderbufferImplementation)(attachment, renderbuffer); (this->*renderbufferImplementation)(attachment, renderbuffer);
return *this; return *this;
} }
@ -425,7 +425,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer {
* @fn_gl_extension{NamedFramebufferTexture1D,EXT,direct_state_access} * @fn_gl_extension{NamedFramebufferTexture1D,EXT,direct_state_access}
* @requires_gl Only 2D and 3D textures are available in OpenGL ES. * @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); (this->*texture1DImplementation)(attachment, texture, level);
return *this; return *this;
} }
@ -444,7 +444,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer {
* @see attachCubeMapTexture(), @fn_gl{BindFramebuffer}, @fn_gl{FramebufferTexture} * @see attachCubeMapTexture(), @fn_gl{BindFramebuffer}, @fn_gl{FramebufferTexture}
* or @fn_gl_extension{NamedFramebufferTexture2D,EXT,direct_state_access} * 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 * @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} * @see attachTexture2D(), @fn_gl{BindFramebuffer}, @fn_gl{FramebufferTexture}
* or @fn_gl_extension{NamedFramebufferTexture2D,EXT,direct_state_access} * or @fn_gl_extension{NamedFramebufferTexture2D,EXT,direct_state_access}
*/ */
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); (this->*texture2DImplementation)(attachment, GLenum(coordinate), texture.id(), level);
return *this; return *this;
} }
@ -480,7 +480,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer {
* @fn_gl_extension{NamedFramebufferTexture3D,EXT,direct_state_access} * @fn_gl_extension{NamedFramebufferTexture3D,EXT,direct_state_access}
* @requires_es_extension %Extension @es_extension{OES,texture_3D} * @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 */ /** @todo Check for texture target compatibility */
(this->*texture3DImplementation)(attachment, texture, level, layer); (this->*texture3DImplementation)(attachment, texture, level, layer);
return *this; return *this;
@ -495,19 +495,19 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer {
#endif #endif
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
typedef void(Framebuffer::*RenderbufferImplementation)(BufferAttachment, Renderbuffer*); typedef void(Framebuffer::*RenderbufferImplementation)(BufferAttachment, Renderbuffer&);
void MAGNUM_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer* renderbuffer); void MAGNUM_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer* renderbuffer); void MAGNUM_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer);
#endif #endif
static RenderbufferImplementation renderbufferImplementation; static RenderbufferImplementation renderbufferImplementation;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
typedef void(Framebuffer::*Texture1DImplementation)(BufferAttachment, Texture1D*, GLint); typedef void(Framebuffer::*Texture1DImplementation)(BufferAttachment, Texture1D&, GLint);
void MAGNUM_LOCAL texture1DImplementationDefault(BufferAttachment attachment, Texture1D* texture, GLint level); void MAGNUM_LOCAL texture1DImplementationDefault(BufferAttachment attachment, Texture1D& texture, GLint level);
void MAGNUM_LOCAL texture1DImplementationDSA(BufferAttachment attachment, Texture1D* texture, GLint level); void MAGNUM_LOCAL texture1DImplementationDSA(BufferAttachment attachment, Texture1D& texture, GLint level);
static Texture1DImplementation texture1DImplementation; static Texture1DImplementation texture1DImplementation;
#endif #endif
@ -518,10 +518,10 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer {
#endif #endif
static MAGNUM_LOCAL Texture2DImplementation texture2DImplementation; static MAGNUM_LOCAL Texture2DImplementation texture2DImplementation;
typedef void(Framebuffer::*Texture3DImplementation)(BufferAttachment, Texture3D*, GLint, GLint); typedef void(Framebuffer::*Texture3DImplementation)(BufferAttachment, Texture3D&, GLint, GLint);
void MAGNUM_LOCAL texture3DImplementationDefault(BufferAttachment attachment, Texture3D* texture, GLint level, GLint layer); void MAGNUM_LOCAL texture3DImplementationDefault(BufferAttachment attachment, Texture3D& texture, GLint level, GLint layer);
#ifndef MAGNUM_TARGET_GLES #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 #endif
static Texture3DImplementation texture3DImplementation; static Texture3DImplementation texture3DImplementation;
}; };

26
src/Mesh.cpp

@ -69,7 +69,7 @@ Mesh::Mesh(Primitive primitive): _primitive(primitive), _vertexCount(0), _indexC
Mesh::~Mesh() { Mesh::~Mesh() {
/* Remove current vao from the state */ /* 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; if(current == vao) current = 0;
(this->*destroyImplementation)(); (this->*destroyImplementation)();
@ -117,10 +117,10 @@ Mesh& Mesh::operator=(Mesh&& other) {
return *this; 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 #ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(buffer->targetHint() == Buffer::Target::ElementArray, CORRADE_ASSERT(buffer.targetHint() == Buffer::Target::ElementArray,
"Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::ElementArray << "but got" << buffer->targetHint(), this); "Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::ElementArray << "but got" << buffer.targetHint(), this);
#endif #endif
indexOffset = offset; indexOffset = offset;
@ -162,7 +162,7 @@ void Mesh::draw() {
void Mesh::bindVAO(GLuint vao) { void Mesh::bindVAO(GLuint vao) {
/** @todo Get some extension wrangler instead to avoid linker errors to glBindVertexArray() on ES2 */ /** @todo Get some extension wrangler instead to avoid linker errors to glBindVertexArray() on ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
GLuint& current = Context::current()->state()->mesh->currentVAO; GLuint& current = Context::current()->state().mesh->currentVAO;
if(current != vao) glBindVertexArray(current = vao); if(current != vao) glBindVertexArray(current = vao);
#else #else
static_cast<void>(vao); static_cast<void>(vao);
@ -191,16 +191,16 @@ void Mesh::vertexAttribPointer(const LongAttribute& attribute) {
#endif #endif
#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 */ /** @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 #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::APPLE::vertex_array_object>()) { if(context.isExtensionSupported<Extensions::GL::APPLE::vertex_array_object>()) {
Debug() << "Mesh: using" << Extensions::GL::APPLE::vertex_array_object::string() << "features"; Debug() << "Mesh: using" << Extensions::GL::APPLE::vertex_array_object::string() << "features";
createImplementation = &Mesh::createImplementationVAO; createImplementation = &Mesh::createImplementationVAO;
destroyImplementation = &Mesh::destroyImplementationVAO; destroyImplementation = &Mesh::destroyImplementationVAO;
if(context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
Debug() << "Mesh: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; Debug() << "Mesh: using" << Extensions::GL::EXT::direct_state_access::string() << "features";
attributePointerImplementation = &Mesh::attributePointerImplementationDSA; attributePointerImplementation = &Mesh::attributePointerImplementationDSA;
@ -299,18 +299,18 @@ void Mesh::attributePointerImplementationDSA(const LongAttribute& attribute) {
#endif #endif
#endif #endif
void Mesh::bindIndexBufferImplementationDefault(Buffer* buffer) { void Mesh::bindIndexBufferImplementationDefault(Buffer& buffer) {
indexBuffer = buffer; indexBuffer = &buffer;
} }
void Mesh::bindIndexBufferImplementationVAO(Buffer* buffer) { void Mesh::bindIndexBufferImplementationVAO(Buffer& buffer) {
bindVAO(vao); bindVAO(vao);
/* Reset ElementArray binding to force explicit glBindBuffer call later */ /* Reset ElementArray binding to force explicit glBindBuffer call later */
/** @todo Do this cleaner way */ /** @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() { void Mesh::bindImplementationDefault() {

69
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. mesh instead of calling setIndexCount() and setIndexBuffer() manually.
Note that neither vertex buffers nor index buffer is managed (e.g. deleted on 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 destruction) by the mesh, so you have to manage them on your own and ensure
hand it allows you to use one buffer for more meshes (each mesh for example that they are available for whole mesh lifetime. On the other hand it allows
configured for different shader) or store data for more meshes in one buffer. 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 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 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; Buffer vertexBuffer;
Mesh mesh;
// Fill vertex buffer with position data // Fill vertex buffer with position data
static constexpr Vector3 positions[30] = { static constexpr Vector3 positions[30] = {
@ -97,8 +98,8 @@ mesh.setPrimitive(Mesh::Primitive::Triangles)
@code @code
// Non-indexed primitive with positions and normals // Non-indexed primitive with positions and normals
Trade::MeshData3D plane = Primitives::Plane::solid(); Trade::MeshData3D plane = Primitives::Plane::solid();
Mesh mesh;
Buffer vertexBuffer; Buffer vertexBuffer;
Mesh mesh;
// Fill vertex buffer with interleaved position and normal data // Fill vertex buffer with interleaved position and normal data
MeshTools::interleave(mesh, buffer, Buffer::Usage::StaticDraw, 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., // Fill position buffer with positions specified as two-component XY (i.e.,
// no Z component, which is meant to be always 0) // no Z component, which is meant to be always 0)
Buffer* positionBuffer; Buffer positionBuffer;
Vector2 positions[30] = { Vector2 positions[30] = {
// ... // ...
}; };
// Specify layout of positions buffer -- only two components, unspecified Z // Specify layout of positions buffer -- only two components, unspecified Z
// component will be automatically set to 0 // component will be automatically set to 0
mesh->addVertexBuffer(positionBuffer, 0, mesh.addVertexBuffer(positionBuffer, 0,
MyShader::Position(MyShader::Position::Components::Two)); MyShader::Position(MyShader::Position::Components::Two));
// Fill color buffer with colors specified as four-byte BGRA (e.g. directly // Fill color buffer with colors specified as four-byte BGRA (e.g. directly
// from TGA file) // from TGA file)
Buffer* colorBuffer; Buffer colorBuffer;
GLubyte colors[4*30] = { 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 // Specify layout of color buffer -- BGRA, each component unsigned byte and we
// want to normalize them from [0, 255] to [0.0f, 1.0f] // 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::Components::BGRA,
MyShader::Color::DataType::UnsignedByte, MyShader::Color::DataType::UnsignedByte,
MyShader::Color::DataOption::Normalized)); 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 * but it accepts only position and normal, so you have to skip the
* texture coordinate array: * texture coordinate array:
* @code * @code
* Mesh mesh;
* Buffer buffer; * Buffer buffer;
* Mesh mesh;
* mesh.addVertexBuffer(buffer, * mesh.addVertexBuffer(buffer,
* 35, // offset of the data * 35, // offset of the data
* Shaders::PhongShader::Position(), // position array * Shaders::PhongShader::Position(), // position array
@ -457,7 +458,7 @@ class MAGNUM_EXPORT Mesh {
* @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access}
* if @extension{APPLE,vertex_array_object} is available * if @extension{APPLE,vertex_array_object} is available
*/ */
template<class ...T> Mesh& addVertexBuffer(Buffer* buffer, GLintptr offset, const T&... attributes); template<class ...T> Mesh& addVertexBuffer(Buffer& buffer, GLintptr offset, const T&... attributes);
/** /**
* @brief Add buffer with interleaved vertex attributes for use with given shader * @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 * position and normal, so you have to skip weight and texture
* coordinate in each vertex: * coordinate in each vertex:
* @code * @code
* Mesh mesh;
* Buffer buffer; * Buffer buffer;
* Mesh mesh;
* mesh.addInterleavedVertexBuffer(buffer, * mesh.addInterleavedVertexBuffer(buffer,
* 35, // skip other data * 35, // skip other data
* sizeof(Float), // skip vertex weight * sizeof(Float), // skip vertex weight
@ -517,7 +518,7 @@ class MAGNUM_EXPORT Mesh {
* @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access}
* if @extension{APPLE,vertex_array_object} is available * if @extension{APPLE,vertex_array_object} is available
*/ */
template<class ...T> inline Mesh& addInterleavedVertexBuffer(Buffer* buffer, GLintptr offset, const T&... attributes) { template<class ...T> inline Mesh& addInterleavedVertexBuffer(Buffer& buffer, GLintptr offset, const T&... attributes) {
addInterleavedVertexBufferInternal(buffer, offset, strideOfInterleaved(attributes...), attributes...); addInterleavedVertexBufferInternal(buffer, offset, strideOfInterleaved(attributes...), attributes...);
return *this; return *this;
} }
@ -528,7 +529,7 @@ class MAGNUM_EXPORT Mesh {
* *
* See addInterleavedVertexBuffer() for more information. * See addInterleavedVertexBuffer() for more information.
*/ */
template<UnsignedInt location, class T> inline Mesh& addVertexBufferStride(Buffer* buffer, GLintptr offset, GLsizei stride, const AbstractShaderProgram::Attribute<location, T>& attribute) { template<UnsignedInt location, class T> inline Mesh& addVertexBufferStride(Buffer& buffer, GLintptr offset, GLsizei stride, const AbstractShaderProgram::Attribute<location, T>& attribute) {
addInterleavedVertexBufferInternal(buffer, offset, stride, attribute); addInterleavedVertexBufferInternal(buffer, offset, stride, attribute);
return *this; return *this;
} }
@ -553,7 +554,7 @@ class MAGNUM_EXPORT Mesh {
* @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if * @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if
* @extension{APPLE,vertex_array_object} is available) * @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 * @brief Set index buffer
@ -568,7 +569,7 @@ class MAGNUM_EXPORT Mesh {
* @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if * @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if
* @extension{APPLE,vertex_array_object} is available) * @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); return setIndexBuffer(buffer, offset, type, 0, 0);
} }
@ -620,20 +621,20 @@ class MAGNUM_EXPORT Mesh {
#endif #endif
#endif #endif
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
/* Adding non-interleaved vertex attributes */ /* Adding non-interleaved vertex attributes */
template<UnsignedInt location, class T, class ...U> inline void addVertexBufferInternal(Buffer* buffer, GLintptr offset, const AbstractShaderProgram::Attribute<location, T>& attribute, const U&... attributes) { template<UnsignedInt location, class T, class ...U> inline void addVertexBufferInternal(Buffer& buffer, GLintptr offset, const AbstractShaderProgram::Attribute<location, T>& attribute, const U&... attributes) {
addVertexAttribute(buffer, attribute, offset, 0); addVertexAttribute(buffer, attribute, offset, 0);
/* Add size of this attribute array to offset for next attribute */ /* Add size of this attribute array to offset for next attribute */
addVertexBufferInternal(buffer, offset+attribute.dataSize()*_vertexCount, attributes...); addVertexBufferInternal(buffer, offset+attribute.dataSize()*_vertexCount, attributes...);
} }
template<class ...T> inline void addVertexBufferInternal(Buffer* buffer, GLintptr offset, GLintptr gap, const T&... attributes) { template<class ...T> inline void addVertexBufferInternal(Buffer& buffer, GLintptr offset, GLintptr gap, const T&... attributes) {
/* Add the gap to offset for next attribute */ /* Add the gap to offset for next attribute */
addVertexBufferInternal(buffer, offset+gap, attributes...); addVertexBufferInternal(buffer, offset+gap, attributes...);
} }
inline void addVertexBufferInternal(Buffer*, GLintptr) {} inline void addVertexBufferInternal(Buffer&, GLintptr) {}
/* Computing stride of interleaved vertex attributes */ /* Computing stride of interleaved vertex attributes */
template<UnsignedInt location, class T, class ...U> inline static GLsizei strideOfInterleaved(const AbstractShaderProgram::Attribute<location, T>& attribute, const U&... attributes) { template<UnsignedInt location, class T, class ...U> inline static GLsizei strideOfInterleaved(const AbstractShaderProgram::Attribute<location, T>& attribute, const U&... attributes) {
@ -645,22 +646,22 @@ class MAGNUM_EXPORT Mesh {
inline static GLsizei strideOfInterleaved() { return 0; } inline static GLsizei strideOfInterleaved() { return 0; }
/* Adding interleaved vertex attributes */ /* Adding interleaved vertex attributes */
template<UnsignedInt location, class T, class ...U> inline void addInterleavedVertexBufferInternal(Buffer* buffer, GLintptr offset, GLsizei stride, const AbstractShaderProgram::Attribute<location, T>& attribute, const U&... attributes) { template<UnsignedInt location, class T, class ...U> inline void addInterleavedVertexBufferInternal(Buffer& buffer, GLintptr offset, GLsizei stride, const AbstractShaderProgram::Attribute<location, T>& attribute, const U&... attributes) {
addVertexAttribute(buffer, attribute, offset, stride); addVertexAttribute(buffer, attribute, offset, stride);
/* Add size of this attribute to offset for next attribute */ /* Add size of this attribute to offset for next attribute */
addInterleavedVertexBufferInternal(buffer, offset+attribute.dataSize(), stride, attributes...); addInterleavedVertexBufferInternal(buffer, offset+attribute.dataSize(), stride, attributes...);
} }
template<class ...T> inline void addInterleavedVertexBufferInternal(Buffer* buffer, GLintptr offset, GLsizei stride, GLintptr gap, const T&... attributes) { template<class ...T> inline void addInterleavedVertexBufferInternal(Buffer& buffer, GLintptr offset, GLsizei stride, GLintptr gap, const T&... attributes) {
/* Add the gap to offset for next attribute */ /* Add the gap to offset for next attribute */
addInterleavedVertexBufferInternal(buffer, offset+gap, stride, attributes...); addInterleavedVertexBufferInternal(buffer, offset+gap, stride, attributes...);
} }
inline void addInterleavedVertexBufferInternal(Buffer*, GLsizei, GLintptr) {} inline void addInterleavedVertexBufferInternal(Buffer&, GLsizei, GLintptr) {}
template<UnsignedInt location, class T> inline void addVertexAttribute(typename std::enable_if<std::is_same<typename Implementation::Attribute<T>::Type, Float>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute<location, T>& attribute, GLintptr offset, GLsizei stride) { template<UnsignedInt location, class T> inline void addVertexAttribute(typename std::enable_if<std::is_same<typename Implementation::Attribute<T>::Type, Float>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute<location, T>& attribute, GLintptr offset, GLsizei stride) {
for(UnsignedInt i = 0; i != Implementation::Attribute<T>::vectorCount(); ++i) for(UnsignedInt i = 0; i != Implementation::Attribute<T>::vectorCount(); ++i)
(this->*attributePointerImplementation)(Attribute{ (this->*attributePointerImplementation)(Attribute{
buffer, &buffer,
location+i, location+i,
static_cast<GLint>(attribute.components()), static_cast<GLint>(attribute.components()),
static_cast<GLenum>(attribute.dataType()), static_cast<GLenum>(attribute.dataType()),
@ -671,9 +672,9 @@ class MAGNUM_EXPORT Mesh {
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
template<UnsignedInt location, class T> inline void addVertexAttribute(typename std::enable_if<std::is_integral<typename Implementation::Attribute<T>::Type>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute<location, T>& attribute, GLintptr offset, GLsizei stride) { template<UnsignedInt location, class T> inline void addVertexAttribute(typename std::enable_if<std::is_integral<typename Implementation::Attribute<T>::Type>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute<location, T>& attribute, GLintptr offset, GLsizei stride) {
(this->*attributeIPointerImplementation)(IntegerAttribute{ (this->*attributeIPointerImplementation)(IntegerAttribute{
buffer, &buffer,
location, location,
static_cast<GLint>(attribute.components()), static_cast<GLint>(attribute.components()),
static_cast<GLenum>(attribute.dataType()), static_cast<GLenum>(attribute.dataType()),
@ -683,10 +684,10 @@ class MAGNUM_EXPORT Mesh {
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template<UnsignedInt location, class T> inline void addVertexAttribute(typename std::enable_if<std::is_same<typename Implementation::Attribute<T>::Type, Double>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute<location, T>& attribute, GLintptr offset, GLsizei stride) { template<UnsignedInt location, class T> inline void addVertexAttribute(typename std::enable_if<std::is_same<typename Implementation::Attribute<T>::Type, Double>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute<location, T>& attribute, GLintptr offset, GLsizei stride) {
for(UnsignedInt i = 0; i != Implementation::Attribute<T>::vectorCount(); ++i) for(UnsignedInt i = 0; i != Implementation::Attribute<T>::vectorCount(); ++i)
(this->*attributeLPointerImplementation)(LongAttribute{ (this->*attributeLPointerImplementation)(LongAttribute{
buffer, &buffer,
location+i, location+i,
static_cast<GLint>(attribute.components()), static_cast<GLint>(attribute.components()),
static_cast<GLenum>(attribute.dataType()), static_cast<GLenum>(attribute.dataType()),
@ -743,9 +744,9 @@ class MAGNUM_EXPORT Mesh {
#endif #endif
#endif #endif
typedef void(Mesh::*BindIndexBufferImplementation)(Buffer*); typedef void(Mesh::*BindIndexBufferImplementation)(Buffer&);
void MAGNUM_LOCAL bindIndexBufferImplementationDefault(Buffer* buffer); void MAGNUM_LOCAL bindIndexBufferImplementationDefault(Buffer& buffer);
void MAGNUM_LOCAL bindIndexBufferImplementationVAO(Buffer* buffer); void MAGNUM_LOCAL bindIndexBufferImplementationVAO(Buffer& buffer);
static MAGNUM_LOCAL BindIndexBufferImplementation bindIndexBufferImplementation; static MAGNUM_LOCAL BindIndexBufferImplementation bindIndexBufferImplementation;
typedef void(Mesh::*BindImplementation)(); typedef void(Mesh::*BindImplementation)();
@ -783,7 +784,7 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::Primitive value);
/** @debugoperator{Magnum::Mesh} */ /** @debugoperator{Magnum::Mesh} */
Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value); Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value);
template<class ...T> inline Mesh& Mesh::addVertexBuffer(Buffer* buffer, GLintptr offset, const T&... attributes) { template<class ...T> inline Mesh& Mesh::addVertexBuffer(Buffer& buffer, GLintptr offset, const T&... attributes) {
CORRADE_ASSERT(sizeof...(attributes) == 1 || _vertexCount != 0, CORRADE_ASSERT(sizeof...(attributes) == 1 || _vertexCount != 0,
"Mesh::addVertexBuffer(): vertex count must be set before binding attributes", *this); "Mesh::addVertexBuffer(): vertex count must be set before binding attributes", *this);

12
src/Renderbuffer.cpp

@ -42,14 +42,14 @@ Renderbuffer::StorageMultisampleImplementation Renderbuffer::storageMultisampleI
Renderbuffer::~Renderbuffer() { Renderbuffer::~Renderbuffer() {
/* If bound, remove itself from state */ /* 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; if(binding == _id) binding = 0;
glDeleteRenderbuffers(1, &_id); glDeleteRenderbuffers(1, &_id);
} }
void Renderbuffer::bind() { void Renderbuffer::bind() {
GLuint& binding = Context::current()->state()->framebuffer->renderbufferBinding; GLuint& binding = Context::current()->state().framebuffer->renderbufferBinding;
if(binding == _id) return; if(binding == _id) return;
@ -57,20 +57,20 @@ void Renderbuffer::bind() {
glBindRenderbuffer(GL_RENDERBUFFER, _id); glBindRenderbuffer(GL_RENDERBUFFER, _id);
} }
void Renderbuffer::initializeContextBasedFunctionality(Context* context) { void Renderbuffer::initializeContextBasedFunctionality(Context& context) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
Debug() << "Renderbuffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; Debug() << "Renderbuffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features";
storageImplementation = &Renderbuffer::storageImplementationDSA; storageImplementation = &Renderbuffer::storageImplementationDSA;
storageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationDSA; storageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationDSA;
} }
#elif !defined(MAGNUM_TARGET_GLES3) #elif !defined(MAGNUM_TARGET_GLES3)
if(context->isExtensionSupported<Extensions::GL::ANGLE::framebuffer_multisample>()) { if(context.isExtensionSupported<Extensions::GL::ANGLE::framebuffer_multisample>()) {
Debug() << "Renderbuffer: using" << Extensions::GL::ANGLE::framebuffer_multisample::string() << "features"; Debug() << "Renderbuffer: using" << Extensions::GL::ANGLE::framebuffer_multisample::string() << "features";
storageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationANGLE; storageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationANGLE;
} else if (context->isExtensionSupported<Extensions::GL::NV::framebuffer_multisample>()) { } else if (context.isExtensionSupported<Extensions::GL::NV::framebuffer_multisample>()) {
Debug() << "Renderbuffer: using" << Extensions::GL::NV::framebuffer_multisample::string() << "features"; Debug() << "Renderbuffer: using" << Extensions::GL::NV::framebuffer_multisample::string() << "features";
storageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationNV; storageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationNV;

2
src/Renderbuffer.h

@ -114,7 +114,7 @@ class MAGNUM_EXPORT Renderbuffer {
} }
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
typedef void(Renderbuffer::*StorageImplementation)(RenderbufferFormat, const Vector2i&); typedef void(Renderbuffer::*StorageImplementation)(RenderbufferFormat, const Vector2i&);
void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size); void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size);

10
src/Renderer.cpp

@ -164,7 +164,7 @@ void Renderer::setLogicOperation(const LogicOperation operation) {
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() { Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() {
ResetNotificationStrategy& strategy = Context::current()->state()->renderer->resetNotificationStrategy; ResetNotificationStrategy& strategy = Context::current()->state().renderer->resetNotificationStrategy;
if(strategy == ResetNotificationStrategy()) { if(strategy == ResetNotificationStrategy()) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -178,9 +178,9 @@ Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() {
} }
#endif #endif
void Renderer::initializeContextBasedFunctionality(Context* context) { void Renderer::initializeContextBasedFunctionality(Context& context) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::ARB::ES2_compatibility>()) { if(context.isExtensionSupported<Extensions::GL::ARB::ES2_compatibility>()) {
Debug() << "Renderer: using" << Extensions::GL::ARB::ES2_compatibility::string() << "features"; Debug() << "Renderer: using" << Extensions::GL::ARB::ES2_compatibility::string() << "features";
clearDepthfImplementation = &Renderer::clearDepthfImplementationES; clearDepthfImplementation = &Renderer::clearDepthfImplementationES;
@ -189,9 +189,9 @@ void Renderer::initializeContextBasedFunctionality(Context* context) {
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::ARB::robustness>()) if(context.isExtensionSupported<Extensions::GL::ARB::robustness>())
#else #else
if(context->isExtensionSupported<Extensions::GL::EXT::robustness>()) if(context.isExtensionSupported<Extensions::GL::EXT::robustness>())
#endif #endif
{ {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

2
src/Renderer.h

@ -1026,7 +1026,7 @@ class MAGNUM_EXPORT Renderer {
/*@}*/ /*@}*/
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
typedef void(*ClearDepthfImplementation)(GLfloat); typedef void(*ClearDepthfImplementation)(GLfloat);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

8
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 * The resource must be loaded before accessing it. Use boolean
* conversion operator or state() for testing whether it is loaded. * conversion operator or state() for testing whether it is loaded.
*/ */
operator U*() { operator U&() {
acquire(); acquire();
CORRADE_ASSERT(data, "Resource: accessing not loaded data with key" << key(), nullptr); CORRADE_ASSERT(data, "Resource: accessing not loaded data with key" << key(), *static_cast<U*>(data));
return static_cast<U*>(data); return *static_cast<U*>(data);
} }
/** @overload */ /** @overload */

15
src/ResourceManager.h

@ -225,8 +225,12 @@ cube->draw();
template implementation file. */ template implementation file. */
template<class... Types> class ResourceManager: private Implementation::ResourceManagerData<Types>... { template<class... Types> class ResourceManager: private Implementation::ResourceManagerData<Types>... {
public: public:
/** @brief Global instance */ /**
static ResourceManager<Types...>* instance(); * @brief Global instance
*
* Assumes that the instance exists.
*/
static ResourceManager<Types...>& instance();
/** /**
* @brief Constructor * @brief Constructor
@ -391,6 +395,7 @@ template<class... Types> class ResourceManager: private Implementation::Resource
/** /**
* @brief Set loader for given type of resources * @brief Set loader for given type of resources
* @param loader Loader or `nullptr` if unsetting previous loader.
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* See AbstractResourceLoader documentation for more information. * See AbstractResourceLoader documentation for more information.
@ -580,9 +585,9 @@ template<class T> inline ResourceManagerData<T>::Data::~Data() {
} }
template<class ...Types> ResourceManager<Types...>* ResourceManager<Types...>::instance() { template<class ...Types> ResourceManager<Types...>& ResourceManager<Types...>::instance() {
CORRADE_ASSERT(internalInstance(), "ResourceManager::instance(): no instance exists", nullptr); CORRADE_ASSERT(internalInstance(), "ResourceManager::instance(): no instance exists", *internalInstance());
return internalInstance(); return *internalInstance();
} }
template<class ...Types> ResourceManager<Types...>::ResourceManager() { template<class ...Types> ResourceManager<Types...>::ResourceManager() {

2
src/Sampler.cpp

@ -47,7 +47,7 @@ static_assert((filter_or(Nearest, Base) == GL_NEAREST) &&
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
Float Sampler::maxSupportedAnisotropy() { 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 */ /** @todo Re-enable when extension header is available */
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

2
src/Test/ResourceManagerTest.cpp

@ -262,7 +262,7 @@ void ResourceManagerTest::clearWhileReferenced() {
void ResourceManagerTest::loader() { void ResourceManagerTest::loader() {
class IntResourceLoader: public AbstractResourceLoader<Int> { class IntResourceLoader: public AbstractResourceLoader<Int> {
public: public:
IntResourceLoader(): resource(ResourceManager::instance()->get<Data>("data")) {} IntResourceLoader(): resource(ResourceManager::instance().get<Data>("data")) {}
void load() { void load() {
set("hello", new Int(773), ResourceDataState::Final, ResourcePolicy::Resident); set("hello", new Int(773), ResourceDataState::Final, ResourcePolicy::Resident);

Loading…
Cancel
Save