diff --git a/src/Magnum/GL/AbstractFramebuffer.cpp b/src/Magnum/GL/AbstractFramebuffer.cpp index 56c34196c..5d322c21b 100644 --- a/src/Magnum/GL/AbstractFramebuffer.cpp +++ b/src/Magnum/GL/AbstractFramebuffer.cpp @@ -119,70 +119,70 @@ void AbstractFramebuffer::bind() { void AbstractFramebuffer::bindInternal(FramebufferTarget target) { #ifndef MAGNUM_TARGET_GLES2 - bindImplementationDefault(target); + bindImplementationDefault(*this, target); #elif defined(MAGNUM_TARGET_WEBGL) static_cast(target); - bindImplementationSingle(); + bindImplementationSingle(*this); #else - (this->*Context::current().state().framebuffer.bindImplementation)(target); + Context::current().state().framebuffer.bindImplementation(*this, target); #endif } #ifdef MAGNUM_TARGET_GLES2 -void AbstractFramebuffer::bindImplementationSingle(FramebufferTarget) { +void AbstractFramebuffer::bindImplementationSingle(AbstractFramebuffer& self, FramebufferTarget) { Implementation::FramebufferState& state = Context::current().state().framebuffer; CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding); - if(state.readBinding == _id) return; + if(state.readBinding == self._id) return; - state.readBinding = state.drawBinding = _id; + state.readBinding = state.drawBinding = self._id; /* Binding the framebuffer finally creates it */ - _flags |= ObjectFlag::Created; - glBindFramebuffer(GL_FRAMEBUFFER, _id); + self._flags |= ObjectFlag::Created; + glBindFramebuffer(GL_FRAMEBUFFER, self._id); } #endif #ifndef MAGNUM_TARGET_GLES2 inline #endif -void AbstractFramebuffer::bindImplementationDefault(FramebufferTarget target) { +void AbstractFramebuffer::bindImplementationDefault(AbstractFramebuffer& self, FramebufferTarget target) { Implementation::FramebufferState& state = Context::current().state().framebuffer; if(target == FramebufferTarget::Read) { - if(state.readBinding == _id) return; - state.readBinding = _id; + if(state.readBinding == self._id) return; + state.readBinding = self._id; } else if(target == FramebufferTarget::Draw) { - if(state.drawBinding == _id) return; - state.drawBinding = _id; + if(state.drawBinding == self._id) return; + state.drawBinding = self._id; } else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ /* Binding the framebuffer finally creates it */ - _flags |= ObjectFlag::Created; - glBindFramebuffer(GLenum(target), _id); + self._flags |= ObjectFlag::Created; + glBindFramebuffer(GLenum(target), self._id); } FramebufferTarget AbstractFramebuffer::bindInternal() { #ifndef MAGNUM_TARGET_GLES2 - return bindImplementationDefault(); + return bindImplementationDefault(*this); #elif defined(MAGNUM_TARGET_WEBGL) - return bindImplementationSingle(); + return bindImplementationSingle(*this); #else - return (this->*Context::current().state().framebuffer.bindInternalImplementation)(); + return Context::current().state().framebuffer.bindInternalImplementation(*this); #endif } #ifdef MAGNUM_TARGET_GLES2 -FramebufferTarget AbstractFramebuffer::bindImplementationSingle() { +FramebufferTarget AbstractFramebuffer::bindImplementationSingle(AbstractFramebuffer& self) { Implementation::FramebufferState& state = Context::current().state().framebuffer; CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding); /* Bind the framebuffer, if not already */ - if(state.readBinding != _id) { - state.readBinding = state.drawBinding = _id; + if(state.readBinding != self._id) { + state.readBinding = state.drawBinding = self._id; /* Binding the framebuffer finally creates it */ - _flags |= ObjectFlag::Created; - glBindFramebuffer(GL_FRAMEBUFFER, _id); + self._flags |= ObjectFlag::Created; + glBindFramebuffer(GL_FRAMEBUFFER, self._id); } /* On ES2 w/o separate read/draw bindings the return value is used as a @@ -196,59 +196,59 @@ FramebufferTarget AbstractFramebuffer::bindImplementationSingle() { #ifndef MAGNUM_TARGET_GLES2 inline #endif -FramebufferTarget AbstractFramebuffer::bindImplementationDefault() { +FramebufferTarget AbstractFramebuffer::bindImplementationDefault(AbstractFramebuffer& self) { Implementation::FramebufferState& state = Context::current().state().framebuffer; /* Return target to which the framebuffer is already bound */ - if(state.readBinding == _id) + if(state.readBinding == self._id) return FramebufferTarget::Read; - if(state.drawBinding == _id) + if(state.drawBinding == self._id) return FramebufferTarget::Draw; /* Or bind it, if not already */ - state.readBinding = _id; + state.readBinding = self._id; /* Binding the framebuffer finally creates it */ - _flags |= ObjectFlag::Created; - glBindFramebuffer(GLenum(FramebufferTarget::Read), _id); + self._flags |= ObjectFlag::Created; + glBindFramebuffer(GLenum(FramebufferTarget::Read), self._id); return FramebufferTarget::Read; } PixelFormat AbstractFramebuffer::implementationColorReadFormat() { - return PixelFormat((this->*Context::current().state().framebuffer.implementationColorReadFormatTypeImplementation)(GL_IMPLEMENTATION_COLOR_READ_FORMAT)); + return PixelFormat(Context::current().state().framebuffer.implementationColorReadFormatTypeImplementation(*this, GL_IMPLEMENTATION_COLOR_READ_FORMAT)); } PixelType AbstractFramebuffer::implementationColorReadType() { - return PixelType((this->*Context::current().state().framebuffer.implementationColorReadFormatTypeImplementation)(GL_IMPLEMENTATION_COLOR_READ_TYPE)); + return PixelType(Context::current().state().framebuffer.implementationColorReadFormatTypeImplementation(*this, GL_IMPLEMENTATION_COLOR_READ_TYPE)); } -GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationGlobal(const GLenum what) { - bindInternal(FramebufferTarget::Read); +GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationGlobal(AbstractFramebuffer& self, const GLenum what) { + self.bindInternal(FramebufferTarget::Read); GLint formatType; glGetIntegerv(what, &formatType); return formatType; } #ifndef MAGNUM_TARGET_GLES -GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationFramebuffer(const GLenum what) { - const FramebufferTarget target = bindInternal(); +GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationFramebuffer(AbstractFramebuffer& self, const GLenum what) { + const FramebufferTarget target = self.bindInternal(); GLint formatType; glGetFramebufferParameteriv(GLenum(target), what, &formatType); return formatType; } -GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationFramebufferDSA(const GLenum what) { +GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationFramebufferDSA(AbstractFramebuffer& self, const GLenum what) { GLint formatType; - glGetNamedFramebufferParameteriv(_id, what, &formatType); + glGetNamedFramebufferParameteriv(self._id, what, &formatType); return formatType; } -GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationFramebufferDSAMesa(const GLenum what) { +GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationFramebufferDSAMesa(AbstractFramebuffer& self, const GLenum what) { /* Mesa needs the framebuffer bound for read even with DSA. See the "mesa-implementation-color-read-format-dsa-explicit-binding" workaround for details. */ - bindInternal(FramebufferTarget::Read); - return implementationColorReadFormatTypeImplementationFramebufferDSA(what); + self.bindInternal(FramebufferTarget::Read); + return implementationColorReadFormatTypeImplementationFramebufferDSA(self, what); } #endif @@ -335,17 +335,17 @@ AbstractFramebuffer& AbstractFramebuffer::clear(const FramebufferClearMask mask) #ifndef MAGNUM_TARGET_GLES2 AbstractFramebuffer& AbstractFramebuffer::clearDepth(const Float depth) { - (this->*Context::current().state().framebuffer.clearFImplementation)(GL_DEPTH, 0, &depth); + Context::current().state().framebuffer.clearFImplementation(*this, GL_DEPTH, 0, &depth); return *this; } AbstractFramebuffer& AbstractFramebuffer::clearStencil(const Int stencil) { - (this->*Context::current().state().framebuffer.clearIImplementation)(GL_STENCIL, 0, &stencil); + Context::current().state().framebuffer.clearIImplementation(*this, GL_STENCIL, 0, &stencil); return *this; } AbstractFramebuffer& AbstractFramebuffer::clearDepthStencil(const Float depth, const Int stencil) { - (this->*Context::current().state().framebuffer.clearFIImplementation)(GL_DEPTH_STENCIL, depth, stencil); + Context::current().state().framebuffer.clearFIImplementation(*this, GL_DEPTH_STENCIL, depth, stencil); return *this; } #endif @@ -497,14 +497,15 @@ void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, CubeMapTexture } #endif -void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum* const) {} +void AbstractFramebuffer::invalidateImplementationNoOp(AbstractFramebuffer&, GLsizei, const GLenum* const) {} -void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments) { +void AbstractFramebuffer::invalidateImplementationDefault(AbstractFramebuffer& self, const GLsizei count, const GLenum* const attachments) { #ifndef MAGNUM_TARGET_GLES2 - glInvalidateFramebuffer(GLenum(bindInternal()), count, attachments); + glInvalidateFramebuffer(GLenum(self.bindInternal()), count, attachments); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) - glDiscardFramebufferEXT(GLenum(bindInternal()), count, attachments); + glDiscardFramebufferEXT(GLenum(self.bindInternal()), count, attachments); #else + static_cast(self); static_cast(count); static_cast(attachments); CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ @@ -512,124 +513,124 @@ void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, c } #ifndef MAGNUM_TARGET_GLES -void AbstractFramebuffer::invalidateImplementationDSA(const GLsizei count, const GLenum* const attachments) { - glInvalidateNamedFramebufferData(_id, count, attachments); +void AbstractFramebuffer::invalidateImplementationDSA(AbstractFramebuffer& self, const GLsizei count, const GLenum* const attachments) { + glInvalidateNamedFramebufferData(self._id, count, attachments); } #endif #ifndef MAGNUM_TARGET_GLES2 -void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&) {} +void AbstractFramebuffer::invalidateImplementationNoOp(AbstractFramebuffer&, GLsizei, const GLenum*, const Range2Di&) {} -void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments, const Range2Di& rectangle) { - glInvalidateSubFramebuffer(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY()); +void AbstractFramebuffer::invalidateImplementationDefault(AbstractFramebuffer& self, const GLsizei count, const GLenum* const attachments, const Range2Di& rectangle) { + glInvalidateSubFramebuffer(GLenum(self.bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY()); } #ifndef MAGNUM_TARGET_GLES -void AbstractFramebuffer::invalidateImplementationDSA(const GLsizei count, const GLenum* const attachments, const Range2Di& rectangle) { - glInvalidateNamedFramebufferSubData(_id, count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY()); +void AbstractFramebuffer::invalidateImplementationDSA(AbstractFramebuffer& self, const GLsizei count, const GLenum* const attachments, const Range2Di& rectangle) { + glInvalidateNamedFramebufferSubData(self._id, count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY()); } #endif #endif -GLenum AbstractFramebuffer::checkStatusImplementationDefault(const FramebufferTarget target) { - bindInternal(target); +GLenum AbstractFramebuffer::checkStatusImplementationDefault(AbstractFramebuffer& self, const FramebufferTarget target) { + self.bindInternal(target); return glCheckFramebufferStatus(GLenum(target)); } #ifdef MAGNUM_TARGET_GLES2 -GLenum AbstractFramebuffer::checkStatusImplementationSingle(FramebufferTarget) { - bindInternal(FramebufferTarget{}); +GLenum AbstractFramebuffer::checkStatusImplementationSingle(AbstractFramebuffer& self, FramebufferTarget) { + self.bindInternal(FramebufferTarget{}); return glCheckFramebufferStatus(GL_FRAMEBUFFER); } #endif #ifndef MAGNUM_TARGET_GLES -GLenum AbstractFramebuffer::checkStatusImplementationDSA(const FramebufferTarget target) { - return glCheckNamedFramebufferStatus(_id, GLenum(target)); +GLenum AbstractFramebuffer::checkStatusImplementationDSA(AbstractFramebuffer& self, const FramebufferTarget target) { + return glCheckNamedFramebufferStatus(self._id, GLenum(target)); } #endif #ifndef MAGNUM_TARGET_GLES2 -void AbstractFramebuffer::clearImplementationDefault(const GLenum buffer, const GLint drawbuffer, const GLint* const value) { - bindInternal(FramebufferTarget::Draw); +void AbstractFramebuffer::clearImplementationDefault(AbstractFramebuffer& self, const GLenum buffer, const GLint drawbuffer, const GLint* const value) { + self.bindInternal(FramebufferTarget::Draw); glClearBufferiv(buffer, drawbuffer, value); } -void AbstractFramebuffer::clearImplementationDefault(const GLenum buffer, const GLint drawbuffer, const GLuint* const value) { - bindInternal(FramebufferTarget::Draw); +void AbstractFramebuffer::clearImplementationDefault(AbstractFramebuffer& self, const GLenum buffer, const GLint drawbuffer, const GLuint* const value) { + self.bindInternal(FramebufferTarget::Draw); glClearBufferuiv(buffer, drawbuffer, value); } -void AbstractFramebuffer::clearImplementationDefault(const GLenum buffer, const GLint drawbuffer, const GLfloat* const value) { - bindInternal(FramebufferTarget::Draw); +void AbstractFramebuffer::clearImplementationDefault(AbstractFramebuffer& self, const GLenum buffer, const GLint drawbuffer, const GLfloat* const value) { + self.bindInternal(FramebufferTarget::Draw); glClearBufferfv(buffer, drawbuffer, value); } -void AbstractFramebuffer::clearImplementationDefault(const GLenum buffer, const GLfloat depth, const GLint stencil) { - bindInternal(FramebufferTarget::Draw); +void AbstractFramebuffer::clearImplementationDefault(AbstractFramebuffer& self, const GLenum buffer, const GLfloat depth, const GLint stencil) { + self.bindInternal(FramebufferTarget::Draw); glClearBufferfi(buffer, 0, depth, stencil); } #ifndef MAGNUM_TARGET_GLES -void AbstractFramebuffer::clearImplementationDSA(const GLenum buffer, const GLint drawbuffer, const GLint* const value) { - glClearNamedFramebufferiv(_id, buffer, drawbuffer, value); +void AbstractFramebuffer::clearImplementationDSA(AbstractFramebuffer& self, const GLenum buffer, const GLint drawbuffer, const GLint* const value) { + glClearNamedFramebufferiv(self._id, buffer, drawbuffer, value); } -void AbstractFramebuffer::clearImplementationDSA(const GLenum buffer, const GLint drawbuffer, const GLuint* const value) { - glClearNamedFramebufferuiv(_id, buffer, drawbuffer, value); +void AbstractFramebuffer::clearImplementationDSA(AbstractFramebuffer& self, const GLenum buffer, const GLint drawbuffer, const GLuint* const value) { + glClearNamedFramebufferuiv(self._id, buffer, drawbuffer, value); } -void AbstractFramebuffer::clearImplementationDSA(const GLenum buffer, const GLint drawbuffer, const GLfloat* const value) { - glClearNamedFramebufferfv(_id, buffer, drawbuffer, value); +void AbstractFramebuffer::clearImplementationDSA(AbstractFramebuffer& self, const GLenum buffer, const GLint drawbuffer, const GLfloat* const value) { + glClearNamedFramebufferfv(self._id, buffer, drawbuffer, value); } -void AbstractFramebuffer::clearImplementationDSA(const GLenum buffer, const GLfloat depth, const GLint stencil) { - glClearNamedFramebufferfi(_id, buffer, 0, depth, stencil); +void AbstractFramebuffer::clearImplementationDSA(AbstractFramebuffer& self, const GLenum buffer, const GLfloat depth, const GLint stencil) { + glClearNamedFramebufferfi(self._id, buffer, 0, depth, stencil); } #endif #endif #ifndef MAGNUM_TARGET_GLES2 -void AbstractFramebuffer::drawBuffersImplementationDefault(GLsizei count, const GLenum* buffers) { - bindInternal(FramebufferTarget::Draw); +void AbstractFramebuffer::drawBuffersImplementationDefault(AbstractFramebuffer& self, GLsizei count, const GLenum* buffers) { + self.bindInternal(FramebufferTarget::Draw); glDrawBuffers(count, buffers); } #ifndef MAGNUM_TARGET_GLES -void AbstractFramebuffer::drawBuffersImplementationDSA(const GLsizei count, const GLenum* const buffers) { - glNamedFramebufferDrawBuffers(_id, count, buffers); +void AbstractFramebuffer::drawBuffersImplementationDSA(AbstractFramebuffer& self, const GLsizei count, const GLenum* const buffers) { + glNamedFramebufferDrawBuffers(self._id, count, buffers); } #endif #else -void AbstractFramebuffer::drawBuffersImplementationEXT(GLsizei count, const GLenum* buffers) { - bindInternal(FramebufferTarget::Draw); +void AbstractFramebuffer::drawBuffersImplementationEXT(AbstractFramebuffer& self, GLsizei count, const GLenum* buffers) { + self.bindInternal(FramebufferTarget::Draw); glDrawBuffersEXT(count, buffers); } #ifndef MAGNUM_TARGET_WEBGL -void AbstractFramebuffer::drawBuffersImplementationNV(GLsizei count, const GLenum* buffers) { - bindInternal(FramebufferTarget::Draw); +void AbstractFramebuffer::drawBuffersImplementationNV(AbstractFramebuffer& self, GLsizei count, const GLenum* buffers) { + self.bindInternal(FramebufferTarget::Draw); glDrawBuffersNV(count, buffers); } #endif #endif #ifndef MAGNUM_TARGET_GLES -void AbstractFramebuffer::drawBufferImplementationDefault(GLenum buffer) { - bindInternal(FramebufferTarget::Draw); +void AbstractFramebuffer::drawBufferImplementationDefault(AbstractFramebuffer& self, GLenum buffer) { + self.bindInternal(FramebufferTarget::Draw); glDrawBuffer(buffer); } -void AbstractFramebuffer::drawBufferImplementationDSA(const GLenum buffer) { - glNamedFramebufferDrawBuffer(_id, buffer); +void AbstractFramebuffer::drawBufferImplementationDSA(AbstractFramebuffer& self, const GLenum buffer) { + glNamedFramebufferDrawBuffer(self._id, buffer); } #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) -void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) { - bindInternal(FramebufferTarget::Read); +void AbstractFramebuffer::readBufferImplementationDefault(AbstractFramebuffer& self, GLenum buffer) { + self.bindInternal(FramebufferTarget::Read); #ifndef MAGNUM_TARGET_GLES2 glReadBuffer(buffer); @@ -640,8 +641,8 @@ void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) { #endif #ifndef MAGNUM_TARGET_GLES -void AbstractFramebuffer::readBufferImplementationDSA(const GLenum buffer) { - glNamedFramebufferReadBuffer(_id, buffer); +void AbstractFramebuffer::readBufferImplementationDSA(AbstractFramebuffer& self, const GLenum buffer) { + glNamedFramebufferReadBuffer(self._id, buffer); } #endif diff --git a/src/Magnum/GL/AbstractFramebuffer.h b/src/Magnum/GL/AbstractFramebuffer.h index eb7f817af..1028ab52b 100644 --- a/src/Magnum/GL/AbstractFramebuffer.h +++ b/src/Magnum/GL/AbstractFramebuffer.h @@ -797,63 +797,63 @@ class MAGNUM_GL_EXPORT AbstractFramebuffer { static void MAGNUM_GL_LOCAL blitImplementationNV(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter); #endif - void MAGNUM_GL_LOCAL bindImplementationDefault(FramebufferTarget target); - FramebufferTarget MAGNUM_GL_LOCAL bindImplementationDefault(); + static void MAGNUM_GL_LOCAL bindImplementationDefault(AbstractFramebuffer& self, FramebufferTarget target); + static FramebufferTarget MAGNUM_GL_LOCAL bindImplementationDefault(AbstractFramebuffer& self); #ifdef MAGNUM_TARGET_GLES2 - void MAGNUM_GL_LOCAL bindImplementationSingle(FramebufferTarget); - FramebufferTarget MAGNUM_GL_LOCAL bindImplementationSingle(); + static void MAGNUM_GL_LOCAL bindImplementationSingle(AbstractFramebuffer& self, FramebufferTarget); + static FramebufferTarget MAGNUM_GL_LOCAL bindImplementationSingle(AbstractFramebuffer& self); #endif - GLenum MAGNUM_GL_LOCAL implementationColorReadFormatTypeImplementationGlobal(GLenum what); + static GLenum MAGNUM_GL_LOCAL implementationColorReadFormatTypeImplementationGlobal(AbstractFramebuffer& self, GLenum what); #ifndef MAGNUM_TARGET_GLES - GLenum MAGNUM_GL_LOCAL implementationColorReadFormatTypeImplementationFramebuffer(GLenum what); - GLenum MAGNUM_GL_LOCAL implementationColorReadFormatTypeImplementationFramebufferDSA(GLenum what); - GLenum MAGNUM_GL_LOCAL implementationColorReadFormatTypeImplementationFramebufferDSAMesa(GLenum what); + static GLenum MAGNUM_GL_LOCAL implementationColorReadFormatTypeImplementationFramebuffer(AbstractFramebuffer& self, GLenum what); + static GLenum MAGNUM_GL_LOCAL implementationColorReadFormatTypeImplementationFramebufferDSA(AbstractFramebuffer& self, GLenum what); + static GLenum MAGNUM_GL_LOCAL implementationColorReadFormatTypeImplementationFramebufferDSAMesa(AbstractFramebuffer& self, GLenum what); #endif - GLenum MAGNUM_GL_LOCAL checkStatusImplementationDefault(FramebufferTarget target); + static GLenum MAGNUM_GL_LOCAL checkStatusImplementationDefault(AbstractFramebuffer& self, FramebufferTarget target); #ifdef MAGNUM_TARGET_GLES2 - GLenum MAGNUM_GL_LOCAL checkStatusImplementationSingle(FramebufferTarget); + static GLenum MAGNUM_GL_LOCAL checkStatusImplementationSingle(AbstractFramebuffer& self, FramebufferTarget); #endif #ifndef MAGNUM_TARGET_GLES - GLenum MAGNUM_GL_LOCAL checkStatusImplementationDSA(FramebufferTarget target); + static GLenum MAGNUM_GL_LOCAL checkStatusImplementationDSA(AbstractFramebuffer& self, FramebufferTarget target); #endif #ifndef MAGNUM_TARGET_GLES2 - void MAGNUM_GL_LOCAL clearImplementationDefault(GLenum buffer, GLint drawbuffer, const GLint* value); - void MAGNUM_GL_LOCAL clearImplementationDefault(GLenum buffer, GLint drawbuffer, const GLuint* value); - void MAGNUM_GL_LOCAL clearImplementationDefault(GLenum buffer, GLint drawbuffer, const GLfloat* value); - void MAGNUM_GL_LOCAL clearImplementationDefault(GLenum buffer, GLfloat depth, GLint stencil); + static void MAGNUM_GL_LOCAL clearImplementationDefault(AbstractFramebuffer& self, GLenum buffer, GLint drawbuffer, const GLint* value); + static void MAGNUM_GL_LOCAL clearImplementationDefault(AbstractFramebuffer& self, GLenum buffer, GLint drawbuffer, const GLuint* value); + static void MAGNUM_GL_LOCAL clearImplementationDefault(AbstractFramebuffer& self, GLenum buffer, GLint drawbuffer, const GLfloat* value); + static void MAGNUM_GL_LOCAL clearImplementationDefault(AbstractFramebuffer& self, GLenum buffer, GLfloat depth, GLint stencil); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL clearImplementationDSA(GLenum buffer, GLint drawbuffer, const GLint* value); - void MAGNUM_GL_LOCAL clearImplementationDSA(GLenum buffer, GLint drawbuffer, const GLuint* value); - void MAGNUM_GL_LOCAL clearImplementationDSA(GLenum buffer, GLint drawbuffer, const GLfloat* value); - void MAGNUM_GL_LOCAL clearImplementationDSA(GLenum buffer, GLfloat depth, GLint stencil); + static void MAGNUM_GL_LOCAL clearImplementationDSA(AbstractFramebuffer& self, GLenum buffer, GLint drawbuffer, const GLint* value); + static void MAGNUM_GL_LOCAL clearImplementationDSA(AbstractFramebuffer& self, GLenum buffer, GLint drawbuffer, const GLuint* value); + static void MAGNUM_GL_LOCAL clearImplementationDSA(AbstractFramebuffer& self, GLenum buffer, GLint drawbuffer, const GLfloat* value); + static void MAGNUM_GL_LOCAL clearImplementationDSA(AbstractFramebuffer& self, GLenum buffer, GLfloat depth, GLint stencil); #endif #endif #ifndef MAGNUM_TARGET_GLES2 - void MAGNUM_GL_LOCAL drawBuffersImplementationDefault(GLsizei count, const GLenum* buffers); + static void MAGNUM_GL_LOCAL drawBuffersImplementationDefault(AbstractFramebuffer& self, GLsizei count, const GLenum* buffers); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL drawBuffersImplementationDSA(GLsizei count, const GLenum* buffers); + static void MAGNUM_GL_LOCAL drawBuffersImplementationDSA(AbstractFramebuffer& self, GLsizei count, const GLenum* buffers); #endif #else - void MAGNUM_GL_LOCAL drawBuffersImplementationEXT(GLsizei count, const GLenum* buffers); + static void MAGNUM_GL_LOCAL drawBuffersImplementationEXT(AbstractFramebuffer& self, GLsizei count, const GLenum* buffers); #ifndef MAGNUM_TARGET_WEBGL - void MAGNUM_GL_LOCAL drawBuffersImplementationNV(GLsizei count, const GLenum* buffers); + static void MAGNUM_GL_LOCAL drawBuffersImplementationNV(AbstractFramebuffer& self, GLsizei count, const GLenum* buffers); #endif #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL drawBufferImplementationDefault(GLenum buffer); - void MAGNUM_GL_LOCAL drawBufferImplementationDSA(GLenum buffer); + static void MAGNUM_GL_LOCAL drawBufferImplementationDefault(AbstractFramebuffer& self, GLenum buffer); + static void MAGNUM_GL_LOCAL drawBufferImplementationDSA(AbstractFramebuffer& self, GLenum buffer); #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void MAGNUM_GL_LOCAL readBufferImplementationDefault(GLenum buffer); + static void MAGNUM_GL_LOCAL readBufferImplementationDefault(AbstractFramebuffer& self, GLenum buffer); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL readBufferImplementationDSA(GLenum buffer); + static void MAGNUM_GL_LOCAL readBufferImplementationDSA(AbstractFramebuffer& self, GLenum buffer); #endif static void MAGNUM_GL_LOCAL readImplementationDefault(const Range2Di& rectangle, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); @@ -879,17 +879,17 @@ class MAGNUM_GL_EXPORT AbstractFramebuffer { static void MAGNUM_GL_LOCAL copySub3DImplementationDSA(const Range2Di& rectangle, AbstractTexture& texture, Int level, const Vector3i& offset); #endif - void MAGNUM_GL_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*); - void MAGNUM_GL_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments); + static void MAGNUM_GL_LOCAL invalidateImplementationNoOp(AbstractFramebuffer& self, GLsizei, const GLenum*); + static void MAGNUM_GL_LOCAL invalidateImplementationDefault(AbstractFramebuffer& self, GLsizei count, const GLenum* attachments); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL invalidateImplementationDSA(GLsizei count, const GLenum* attachments); + static void MAGNUM_GL_LOCAL invalidateImplementationDSA(AbstractFramebuffer& self, GLsizei count, const GLenum* attachments); #endif #ifndef MAGNUM_TARGET_GLES2 - void MAGNUM_GL_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&); - void MAGNUM_GL_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments, const Range2Di& rectangle); + static void MAGNUM_GL_LOCAL invalidateImplementationNoOp(AbstractFramebuffer& self, GLsizei, const GLenum*, const Range2Di&); + static void MAGNUM_GL_LOCAL invalidateImplementationDefault(AbstractFramebuffer& self, GLsizei count, const GLenum* attachments, const Range2Di& rectangle); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL invalidateImplementationDSA(GLsizei count, const GLenum* attachments, const Range2Di& rectangle); + static void MAGNUM_GL_LOCAL invalidateImplementationDSA(AbstractFramebuffer& self, GLsizei count, const GLenum* attachments, const Range2Di& rectangle); #endif #endif }; diff --git a/src/Magnum/GL/AbstractQuery.cpp b/src/Magnum/GL/AbstractQuery.cpp index b363b4983..98098680a 100644 --- a/src/Magnum/GL/AbstractQuery.cpp +++ b/src/Magnum/GL/AbstractQuery.cpp @@ -40,7 +40,7 @@ namespace Magnum { namespace GL { AbstractQuery::AbstractQuery(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current().state().query.createImplementation)(); + Context::current().state().query.createImplementation(*this); } AbstractQuery::~AbstractQuery() { @@ -54,42 +54,42 @@ AbstractQuery::~AbstractQuery() { #endif } -void AbstractQuery::createImplementationDefault() { +void AbstractQuery::createImplementationDefault(AbstractQuery& self) { #ifndef MAGNUM_TARGET_GLES2 - glGenQueries(1, &_id); + glGenQueries(1, &self._id); #else - glGenQueriesEXT(1, &_id); + glGenQueriesEXT(1, &self._id); #endif } #ifndef MAGNUM_TARGET_GLES -void AbstractQuery::createImplementationDSA() { - glCreateQueries(_target, 1, &_id); - _flags |= ObjectFlag::Created; +void AbstractQuery::createImplementationDSA(AbstractQuery& self) { + glCreateQueries(self._target, 1, &self._id); + self._flags |= ObjectFlag::Created; } -void AbstractQuery::createImplementationDSAExceptXfbOverflow() { - if(_target == GL_TRANSFORM_FEEDBACK_OVERFLOW || _target == GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW) - createImplementationDefault(); +void AbstractQuery::createImplementationDSAExceptXfbOverflow(AbstractQuery& self) { + if(self._target == GL_TRANSFORM_FEEDBACK_OVERFLOW || self._target == GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW) + createImplementationDefault(self); else - createImplementationDSA(); + createImplementationDSA(self); } -void AbstractQuery::createImplementationDSAExceptPipelineStats() { - if(_target == GL_VERTICES_SUBMITTED || - _target == GL_PRIMITIVES_SUBMITTED || - _target == GL_VERTEX_SHADER_INVOCATIONS || - _target == GL_TESS_CONTROL_SHADER_PATCHES || - _target == GL_TESS_EVALUATION_SHADER_INVOCATIONS || - _target == GL_GEOMETRY_SHADER_INVOCATIONS || - _target == GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED || - _target == GL_FRAGMENT_SHADER_INVOCATIONS || - _target == GL_COMPUTE_SHADER_INVOCATIONS || - _target == GL_CLIPPING_INPUT_PRIMITIVES || - _target == GL_CLIPPING_OUTPUT_PRIMITIVES) - createImplementationDefault(); +void AbstractQuery::createImplementationDSAExceptPipelineStats(AbstractQuery& self) { + if(self._target == GL_VERTICES_SUBMITTED || + self._target == GL_PRIMITIVES_SUBMITTED || + self._target == GL_VERTEX_SHADER_INVOCATIONS || + self._target == GL_TESS_CONTROL_SHADER_PATCHES || + self._target == GL_TESS_EVALUATION_SHADER_INVOCATIONS || + self._target == GL_GEOMETRY_SHADER_INVOCATIONS || + self._target == GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED || + self._target == GL_FRAGMENT_SHADER_INVOCATIONS || + self._target == GL_COMPUTE_SHADER_INVOCATIONS || + self._target == GL_CLIPPING_INPUT_PRIMITIVES || + self._target == GL_CLIPPING_OUTPUT_PRIMITIVES) + createImplementationDefault(self); else - createImplementationDSA(); + createImplementationDSA(self); } #endif diff --git a/src/Magnum/GL/AbstractQuery.h b/src/Magnum/GL/AbstractQuery.h index 206b6b20a..6b7167445 100644 --- a/src/Magnum/GL/AbstractQuery.h +++ b/src/Magnum/GL/AbstractQuery.h @@ -182,11 +182,11 @@ class MAGNUM_GL_EXPORT AbstractQuery: public AbstractObject { GLenum _target; private: - void MAGNUM_GL_LOCAL createImplementationDefault(); + static void MAGNUM_GL_LOCAL createImplementationDefault(AbstractQuery& self); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL createImplementationDSA(); - void MAGNUM_GL_LOCAL createImplementationDSAExceptXfbOverflow(); - void MAGNUM_GL_LOCAL createImplementationDSAExceptPipelineStats(); + static void MAGNUM_GL_LOCAL createImplementationDSA(AbstractQuery& self); + static void MAGNUM_GL_LOCAL createImplementationDSAExceptXfbOverflow(AbstractQuery& self); + static void MAGNUM_GL_LOCAL createImplementationDSAExceptPipelineStats(AbstractQuery& self); #endif ObjectFlags _flags; diff --git a/src/Magnum/GL/AbstractShaderProgram.cpp b/src/Magnum/GL/AbstractShaderProgram.cpp index c47952e45..a1674b870 100644 --- a/src/Magnum/GL/AbstractShaderProgram.cpp +++ b/src/Magnum/GL/AbstractShaderProgram.cpp @@ -562,10 +562,10 @@ void AbstractShaderProgram::bindFragmentDataLocationIndexed(const UnsignedInt lo #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::setTransformFeedbackOutputs(const Containers::StringIterable& outputs, const TransformFeedbackBufferMode bufferMode) { - (this->*Context::current().state().shaderProgram.transformFeedbackVaryingsImplementation)(outputs, bufferMode); + Context::current().state().shaderProgram.transformFeedbackVaryingsImplementation(*this, outputs, bufferMode); } -void AbstractShaderProgram::transformFeedbackVaryingsImplementationDefault(const Containers::StringIterable& outputs, const TransformFeedbackBufferMode bufferMode) { +void AbstractShaderProgram::transformFeedbackVaryingsImplementationDefault(AbstractShaderProgram& self, const Containers::StringIterable& outputs, const TransformFeedbackBufferMode bufferMode) { Containers::ArrayView nameData; Containers::ArrayView names; Containers::ArrayTuple data{ @@ -577,11 +577,11 @@ void AbstractShaderProgram::transformFeedbackVaryingsImplementationDefault(const names[i] = nameData[i].data(); } - glTransformFeedbackVaryings(_id, outputs.size(), names, GLenum(bufferMode)); + glTransformFeedbackVaryings(self._id, outputs.size(), names, GLenum(bufferMode)); } #ifdef CORRADE_TARGET_WINDOWS -void AbstractShaderProgram::transformFeedbackVaryingsImplementationDanglingWorkaround(const Containers::StringIterable& outputs, const TransformFeedbackBufferMode bufferMode) { +void AbstractShaderProgram::transformFeedbackVaryingsImplementationDanglingWorkaround(AbstractShaderProgram& self, const Containers::StringIterable& outputs, const TransformFeedbackBufferMode bufferMode) { /* NVidia on Windows doesn't copy the names when calling glTransformFeedbackVaryings() so it then might fail at link time because the char* get dangling. We have to do the copy on the engine side and @@ -593,7 +593,7 @@ void AbstractShaderProgram::transformFeedbackVaryingsImplementationDanglingWorka in a member variable. */ Containers::ArrayView nameData; Containers::ArrayView names; - _transformFeedbackVaryingNames = Containers::ArrayTuple{ + self._transformFeedbackVaryingNames = Containers::ArrayTuple{ {NoInit, outputs.size(), nameData}, {NoInit, outputs.size(), names} }; @@ -602,7 +602,7 @@ void AbstractShaderProgram::transformFeedbackVaryingsImplementationDanglingWorka names[i] = nameData[i].data(); } - glTransformFeedbackVaryings(_id, outputs.size(), names, GLenum(bufferMode)); + glTransformFeedbackVaryings(self._id, outputs.size(), names, GLenum(bufferMode)); } #endif #endif diff --git a/src/Magnum/GL/AbstractShaderProgram.h b/src/Magnum/GL/AbstractShaderProgram.h index b9c927067..56eaa83dc 100644 --- a/src/Magnum/GL/AbstractShaderProgram.h +++ b/src/Magnum/GL/AbstractShaderProgram.h @@ -1877,11 +1877,11 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject { private: #ifndef MAGNUM_TARGET_GLES2 - void MAGNUM_GL_LOCAL transformFeedbackVaryingsImplementationDefault(const Containers::StringIterable& outputs, TransformFeedbackBufferMode bufferMode); + static void MAGNUM_GL_LOCAL transformFeedbackVaryingsImplementationDefault(AbstractShaderProgram& self, const Containers::StringIterable& outputs, TransformFeedbackBufferMode bufferMode); #ifdef CORRADE_TARGET_WINDOWS /* See the "nv-windows-dangling-transform-feedback-varying-names" workaround */ - void MAGNUM_GL_LOCAL transformFeedbackVaryingsImplementationDanglingWorkaround(const Containers::StringIterable& outputs, TransformFeedbackBufferMode bufferMode); + static void MAGNUM_GL_LOCAL transformFeedbackVaryingsImplementationDanglingWorkaround(AbstractShaderProgram& self, const Containers::StringIterable& outputs, TransformFeedbackBufferMode bufferMode); #endif #endif diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index dca054e07..e770f1f6c 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -214,18 +214,18 @@ Int AbstractTexture::compressedBlockDataSizeImplementationBitsWorkaround(const G #endif AbstractTexture::AbstractTexture(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current().state().texture.createImplementation)(); + Context::current().state().texture.createImplementation(*this); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } -void AbstractTexture::createImplementationDefault() { - glGenTextures(1, &_id); +void AbstractTexture::createImplementationDefault(AbstractTexture& self) { + glGenTextures(1, &self._id); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::createImplementationDSA() { - glCreateTextures(_target, 1, &_id); - _flags |= ObjectFlag::Created; +void AbstractTexture::createImplementationDSA(AbstractTexture& self) { + glCreateTextures(self._target, 1, &self._id); + self._flags |= ObjectFlag::Created; } #endif @@ -345,10 +345,10 @@ void AbstractTexture::bind(Int textureUnit) { /* Update state tracker, bind the texture to the unit */ textureState.bindings[textureUnit] = {_target, _id}; - (this->*textureState.bindImplementation)(textureUnit); + textureState.bindImplementation(*this, textureUnit); } -void AbstractTexture::bindImplementationDefault(GLint textureUnit) { +void AbstractTexture::bindImplementationDefault(AbstractTexture& self, GLint textureUnit) { Implementation::TextureState& textureState = Context::current().state().texture; /* Activate given texture unit if not already active, update state tracker */ @@ -356,32 +356,32 @@ void AbstractTexture::bindImplementationDefault(GLint textureUnit) { glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = textureUnit)); /* Binding the texture finally creates it */ - _flags |= ObjectFlag::Created; - glBindTexture(_target, _id); + self._flags |= ObjectFlag::Created; + glBindTexture(self._target, self._id); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::bindImplementationMulti(GLint textureUnit) { - createIfNotAlready(); - glBindTextures(textureUnit, 1, &_id); +void AbstractTexture::bindImplementationMulti(AbstractTexture& self, GLint textureUnit) { + self.createIfNotAlready(); + glBindTextures(textureUnit, 1, &self._id); } -void AbstractTexture::bindImplementationDSA(const GLint textureUnit) { - glBindTextureUnit(textureUnit, _id); +void AbstractTexture::bindImplementationDSA(AbstractTexture& self, const GLint textureUnit) { + glBindTextureUnit(textureUnit, self._id); } #ifdef CORRADE_TARGET_WINDOWS -void AbstractTexture::bindImplementationDSAIntelWindows(const GLint textureUnit) { +void AbstractTexture::bindImplementationDSAIntelWindows(AbstractTexture& self, const GLint textureUnit) { /* See the "intel-windows-half-baked-dsa-texture-bind" workaround */ - if(_target == GL_TEXTURE_CUBE_MAP) bindImplementationDefault(textureUnit); - else bindImplementationDSA(textureUnit); + if(self._target == GL_TEXTURE_CUBE_MAP) bindImplementationDefault(self, textureUnit); + else bindImplementationDSA(self, textureUnit); } #endif #ifdef CORRADE_TARGET_APPLE -void AbstractTexture::bindImplementationAppleBufferTextureWorkaround(const GLint textureUnit) { - bindImplementationDefault(textureUnit); - if(_target == GL_TEXTURE_BUFFER) +void AbstractTexture::bindImplementationAppleBufferTextureWorkaround(AbstractTexture& self, const GLint textureUnit) { + bindImplementationDefault(self, textureUnit); + if(self._target == GL_TEXTURE_BUFFER) Context::current().state().texture.bufferTextureBound.set(textureUnit, true); } #endif @@ -389,13 +389,13 @@ void AbstractTexture::bindImplementationAppleBufferTextureWorkaround(const GLint #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::setBaseLevel(Int level) { - (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_BASE_LEVEL, level); + Context::current().state().texture.parameteriImplementation(*this, GL_TEXTURE_BASE_LEVEL, level); } #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::setMaxLevel(Int level) { - (this->*Context::current().state().texture.parameteriImplementation)( + Context::current().state().texture.parameteriImplementation(*this, #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_MAX_LEVEL #else @@ -406,32 +406,32 @@ void AbstractTexture::setMaxLevel(Int level) { #endif void AbstractTexture::setMinificationFilter(SamplerFilter filter, SamplerMipmap mipmap) { - (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap)); + Context::current().state().texture.parameteriImplementation(*this, GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap)); } void AbstractTexture::setMagnificationFilter(const SamplerFilter filter) { - (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_MAG_FILTER, GLint(filter)); + Context::current().state().texture.parameteriImplementation(*this, GL_TEXTURE_MAG_FILTER, GLint(filter)); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::setMinLod(const Float lod) { - (this->*Context::current().state().texture.parameterfImplementation)(GL_TEXTURE_MIN_LOD, lod); + Context::current().state().texture.parameterfImplementation(*this, GL_TEXTURE_MIN_LOD, lod); } void AbstractTexture::setMaxLod(const Float lod) { - (this->*Context::current().state().texture.parameterfImplementation)(GL_TEXTURE_MAX_LOD, lod); + Context::current().state().texture.parameterfImplementation(*this, GL_TEXTURE_MAX_LOD, lod); } #endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::setLodBias(const Float bias) { - (this->*Context::current().state().texture.parameterfImplementation)(GL_TEXTURE_LOD_BIAS, bias); + Context::current().state().texture.parameterfImplementation(*this, GL_TEXTURE_LOD_BIAS, bias); } #endif #ifndef MAGNUM_TARGET_WEBGL void AbstractTexture::setBorderColor(const Color4& color) { - (this->*Context::current().state().texture.parameterfvImplementation)( + Context::current().state().texture.parameterfvImplementation(*this, #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_BORDER_COLOR, #else @@ -442,22 +442,22 @@ void AbstractTexture::setBorderColor(const Color4& color) { #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::setBorderColor(const Vector4ui& color) { - (this->*Context::current().state().texture.parameterIuivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data()); + Context::current().state().texture.parameterIuivImplementation(*this, GL_TEXTURE_BORDER_COLOR, color.data()); } void AbstractTexture::setBorderColor(const Vector4i& color) { - (this->*Context::current().state().texture.parameterIivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data()); + Context::current().state().texture.parameterIivImplementation(*this, GL_TEXTURE_BORDER_COLOR, color.data()); } #endif #endif void AbstractTexture::setMaxAnisotropy(const Float anisotropy) { - (this->*Context::current().state().texture.setMaxAnisotropyImplementation)(anisotropy); + Context::current().state().texture.setMaxAnisotropyImplementation(*this, anisotropy); } #ifndef MAGNUM_TARGET_WEBGL void AbstractTexture::setSrgbDecode(bool decode) { - (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SRGB_DECODE_EXT, + Context::current().state().texture.parameteriImplementation(*this, GL_TEXTURE_SRGB_DECODE_EXT, decode ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT); } #endif @@ -466,19 +466,19 @@ void AbstractTexture::setSrgbDecode(bool decode) { void AbstractTexture::setSwizzleInternal(const GLint r, const GLint g, const GLint b, const GLint a) { #ifndef MAGNUM_TARGET_GLES const GLint rgba[] = {r, g, b, a}; - (this->*Context::current().state().texture.parameterivImplementation)(GL_TEXTURE_SWIZZLE_RGBA, rgba); + Context::current().state().texture.parameterivImplementation(*this, GL_TEXTURE_SWIZZLE_RGBA, rgba); #else - (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SWIZZLE_R, r); - (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SWIZZLE_G, g); - (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SWIZZLE_B, b); - (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SWIZZLE_A, a); + Context::current().state().texture.parameteriImplementation(*this, GL_TEXTURE_SWIZZLE_R, r); + Context::current().state().texture.parameteriImplementation(*this, GL_TEXTURE_SWIZZLE_G, g); + Context::current().state().texture.parameteriImplementation(*this, GL_TEXTURE_SWIZZLE_B, b); + Context::current().state().texture.parameteriImplementation(*this, GL_TEXTURE_SWIZZLE_A, a); #endif } #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::setCompareMode(const SamplerCompareMode mode) { - (this->*Context::current().state().texture.parameteriImplementation)( + Context::current().state().texture.parameteriImplementation(*this, #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_COMPARE_MODE #else @@ -488,7 +488,7 @@ void AbstractTexture::setCompareMode(const SamplerCompareMode mode) { } void AbstractTexture::setCompareFunction(const SamplerCompareFunction function) { - (this->*Context::current().state().texture.parameteriImplementation)( + Context::current().state().texture.parameteriImplementation(*this, #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_COMPARE_FUNC #else @@ -500,26 +500,26 @@ void AbstractTexture::setCompareFunction(const SamplerCompareFunction function) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::setDepthStencilMode(const SamplerDepthStencilMode mode) { - (this->*Context::current().state().texture.parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode)); + Context::current().state().texture.parameteriImplementation(*this, GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode)); } #endif void AbstractTexture::invalidateImage(const Int level) { - (this->*Context::current().state().texture.invalidateImageImplementation)(level); + Context::current().state().texture.invalidateImageImplementation(*this, level); } void AbstractTexture::generateMipmap() { - (this->*Context::current().state().texture.mipmapImplementation)(); + Context::current().state().texture.mipmapImplementation(*this); } -void AbstractTexture::mipmapImplementationDefault() { - bindInternal(); - glGenerateMipmap(_target); +void AbstractTexture::mipmapImplementationDefault(AbstractTexture& self) { + self.bindInternal(); + glGenerateMipmap(self._target); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::mipmapImplementationDSA() { - glGenerateTextureMipmap(_id); +void AbstractTexture::mipmapImplementationDSA(AbstractTexture& self) { + glGenerateTextureMipmap(self._id); } #endif @@ -550,7 +550,7 @@ void AbstractTexture::bindInternal() { glBindTexture() in order to create it and have ObjectFlag::Created set (which is then asserted in createIfNotAlready()) */ textureState.bindings[internalTextureUnit] = {_target, _id}; - (this->*textureState.bindInternalImplementation)(internalTextureUnit); + textureState.bindInternalImplementation(*this, internalTextureUnit); } #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) @@ -1199,94 +1199,94 @@ PixelType pixelTypeForInternalFormat(const TextureFormat internalFormat) { } #endif -void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLint value) { - bindInternal(); - glTexParameteri(_target, parameter, value); +void AbstractTexture::parameterImplementationDefault(AbstractTexture& self, GLenum parameter, GLint value) { + self.bindInternal(); + glTexParameteri(self._target, parameter, value); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLint value) { - glTextureParameteri(_id, parameter, value); +void AbstractTexture::parameterImplementationDSA(AbstractTexture& self, const GLenum parameter, const GLint value) { + glTextureParameteri(self._id, parameter, value); } #endif -void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLfloat value) { - bindInternal(); - glTexParameterf(_target, parameter, value); +void AbstractTexture::parameterImplementationDefault(AbstractTexture& self, GLenum parameter, GLfloat value) { + self.bindInternal(); + glTexParameterf(self._target, parameter, value); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLfloat value) { - glTextureParameterf(_id, parameter, value); +void AbstractTexture::parameterImplementationDSA(AbstractTexture& self, const GLenum parameter, const GLfloat value) { + glTextureParameterf(self._id, parameter, value); } #endif #ifndef MAGNUM_TARGET_GLES2 -void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLint* values) { - bindInternal(); - glTexParameteriv(_target, parameter, values); +void AbstractTexture::parameterImplementationDefault(AbstractTexture& self, GLenum parameter, const GLint* values) { + self.bindInternal(); + glTexParameteriv(self._target, parameter, values); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLint* const values) { - glTextureParameteriv(_id, parameter, values); +void AbstractTexture::parameterImplementationDSA(AbstractTexture& self, const GLenum parameter, const GLint* const values) { + glTextureParameteriv(self._id, parameter, values); } #endif #endif -void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLfloat* values) { - bindInternal(); - glTexParameterfv(_target, parameter, values); +void AbstractTexture::parameterImplementationDefault(AbstractTexture& self, GLenum parameter, const GLfloat* values) { + self.bindInternal(); + glTexParameterfv(self._target, parameter, values); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLfloat* const values) { - glTextureParameterfv(_id, parameter, values); +void AbstractTexture::parameterImplementationDSA(AbstractTexture& self, const GLenum parameter, const GLfloat* const values) { + glTextureParameterfv(self._id, parameter, values); } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) -void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GLuint* values) { - bindInternal(); - glTexParameterIuiv(_target, parameter, values); +void AbstractTexture::parameterIImplementationDefault(AbstractTexture& self, GLenum parameter, const GLuint* values) { + self.bindInternal(); + glTexParameterIuiv(self._target, parameter, values); } #ifdef MAGNUM_TARGET_GLES -void AbstractTexture::parameterIImplementationEXT(GLenum parameter, const GLuint* values) { - bindInternal(); - glTexParameterIuivEXT(_target, parameter, values); +void AbstractTexture::parameterIImplementationEXT(AbstractTexture& self, GLenum parameter, const GLuint* values) { + self.bindInternal(); + glTexParameterIuivEXT(self._target, parameter, values); } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterIImplementationDSA(const GLenum parameter, const GLuint* const values) { - glTextureParameterIuiv(_id, parameter, values); +void AbstractTexture::parameterIImplementationDSA(AbstractTexture& self, const GLenum parameter, const GLuint* const values) { + glTextureParameterIuiv(self._id, parameter, values); } #endif -void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GLint* values) { - bindInternal(); - glTexParameterIiv(_target, parameter, values); +void AbstractTexture::parameterIImplementationDefault(AbstractTexture& self, GLenum parameter, const GLint* values) { + self.bindInternal(); + glTexParameterIiv(self._target, parameter, values); } #ifdef MAGNUM_TARGET_GLES -void AbstractTexture::parameterIImplementationEXT(GLenum parameter, const GLint* values) { - bindInternal(); - glTexParameterIivEXT(_target, parameter, values); +void AbstractTexture::parameterIImplementationEXT(AbstractTexture& self, GLenum parameter, const GLint* values) { + self.bindInternal(); + glTexParameterIivEXT(self._target, parameter, values); } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterIImplementationDSA(const GLenum parameter, const GLint* const values) { - glTextureParameterIiv(_id, parameter, values); +void AbstractTexture::parameterIImplementationDSA(AbstractTexture& self, const GLenum parameter, const GLint* const values) { + glTextureParameterIiv(self._id, parameter, values); } #endif #endif -void AbstractTexture::setMaxAnisotropyImplementationNoOp(GLfloat) {} +void AbstractTexture::setMaxAnisotropyImplementationNoOp(AbstractTexture&, GLfloat) {} -void AbstractTexture::setMaxAnisotropyImplementationArbOrExt(GLfloat anisotropy) { - (this->*Context::current().state().texture.parameterfImplementation)( +void AbstractTexture::setMaxAnisotropyImplementationArbOrExt(AbstractTexture& self, GLfloat anisotropy) { + Context::current().state().texture.parameterfImplementation(self, #ifndef MAGNUM_TARGET_GLES GL_TEXTURE_MAX_ANISOTROPY #else @@ -1296,40 +1296,40 @@ void AbstractTexture::setMaxAnisotropyImplementationArbOrExt(GLfloat anisotropy) } #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) -void AbstractTexture::getLevelParameterImplementationDefault(const GLint level, const GLenum parameter, GLint* const values) { - bindInternal(); - glGetTexLevelParameteriv(_target, level, parameter, values); +void AbstractTexture::getLevelParameterImplementationDefault(AbstractTexture& self, const GLint level, const GLenum parameter, GLint* const values) { + self.bindInternal(); + glGetTexLevelParameteriv(self._target, level, parameter, values); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::getLevelParameterImplementationDSA(const GLint level, const GLenum parameter, GLint* const values) { - glGetTextureLevelParameteriv(_id, level, parameter, values); +void AbstractTexture::getLevelParameterImplementationDSA(AbstractTexture& self, const GLint level, const GLenum parameter, GLint* const values) { + glGetTextureLevelParameteriv(self._id, level, parameter, values); } #endif #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { +void AbstractTexture::storageImplementationFallback(AbstractTexture& self, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { const PixelFormat format = pixelFormatForInternalFormat(internalFormat); const PixelType type = pixelTypeForInternalFormat(internalFormat); for(GLsizei level = 0; level != levels; ++level) - DataHelper<1>::setImage(*this, level, internalFormat, + DataHelper<1>::setImage(self, level, internalFormat, ImageView1D{format, type, Math::max(Math::Vector<1, GLsizei>(1), size >> level)}); } -void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { - bindInternal(); - glTexStorage1D(_target, levels, GLenum(internalFormat), size[0]); +void AbstractTexture::storageImplementationDefault(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { + self.bindInternal(); + glTexStorage1D(self._target, levels, GLenum(internalFormat), size[0]); } -void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { - glTextureStorage1D(_id, levels, GLenum(internalFormat), size[0]); +void AbstractTexture::storageImplementationDSA(AbstractTexture& self, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { + glTextureStorage1D(self._id, levels, GLenum(internalFormat), size[0]); } #endif #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) -void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { +void AbstractTexture::storageImplementationFallback(AbstractTexture& self, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { const PixelFormat format = pixelFormatForInternalFormat(internalFormat); const PixelType type = pixelTypeForInternalFormat(internalFormat); @@ -1344,17 +1344,17 @@ void AbstractTexture::storageImplementationFallback(const GLsizei levels, const /* Common code for classic types */ #ifndef MAGNUM_TARGET_GLES - if(_target == GL_TEXTURE_2D || _target == GL_TEXTURE_RECTANGLE) + if(self._target == GL_TEXTURE_2D || self._target == GL_TEXTURE_RECTANGLE) #else - if(_target == GL_TEXTURE_2D) + if(self._target == GL_TEXTURE_2D) #endif { for(GLsizei level = 0; level != levels; ++level) - DataHelper<2>::setImage(*this, level, finalInternalFormat, + DataHelper<2>::setImage(self, level, finalInternalFormat, ImageView2D{format, type, Math::max(Vector2i(1), size >> level)}); /* Cube map additionally needs to specify all faces */ - } else if(_target == GL_TEXTURE_CUBE_MAP) { + } else if(self._target == GL_TEXTURE_CUBE_MAP) { for(GLsizei level = 0; level != levels; ++level) { for(GLenum face: {GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, @@ -1362,15 +1362,15 @@ void AbstractTexture::storageImplementationFallback(const GLsizei levels, const GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z}) - DataHelper<2>::setImage(*this, face, level, finalInternalFormat, + DataHelper<2>::setImage(self, face, level, finalInternalFormat, ImageView2D{format, type, Math::max(Vector2i(1), size >> level)}); } #ifndef MAGNUM_TARGET_GLES /* Array texture is not scaled in "layer" dimension */ - } else if(_target == GL_TEXTURE_1D_ARRAY) { + } else if(self._target == GL_TEXTURE_1D_ARRAY) { for(GLsizei level = 0; level != levels; ++level) - DataHelper<2>::setImage(*this, level, internalFormat, + DataHelper<2>::setImage(self, level, internalFormat, ImageView2D{format, type, Vector2i{Math::max(1, size.x() >> level), size.y()}}); #endif @@ -1380,24 +1380,24 @@ void AbstractTexture::storageImplementationFallback(const GLsizei levels, const #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) -void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { - bindInternal(); +void AbstractTexture::storageImplementationDefault(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { + self.bindInternal(); #ifndef MAGNUM_TARGET_GLES2 - glTexStorage2D(_target, levels, GLenum(internalFormat), size.x(), size.y()); + glTexStorage2D(self._target, levels, GLenum(internalFormat), size.x(), size.y()); #else - glTexStorage2DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y()); + glTexStorage2DEXT(self._target, levels, GLenum(internalFormat), size.x(), size.y()); #endif } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { - glTextureStorage2D(_id, levels, GLenum(internalFormat), size.x(), size.y()); +void AbstractTexture::storageImplementationDSA(AbstractTexture& self, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { + glTextureStorage2D(self._id, levels, GLenum(internalFormat), size.x(), size.y()); } #endif #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) -void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { +void AbstractTexture::storageImplementationFallback(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { const PixelFormat format = pixelFormatForInternalFormat(internalFormat); const PixelType type = pixelTypeForInternalFormat(internalFormat); @@ -1412,17 +1412,17 @@ void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureForma /* Common code for classic type */ #ifndef MAGNUM_TARGET_GLES2 - if(_target == GL_TEXTURE_3D) + if(self._target == GL_TEXTURE_3D) #else - if(_target == GL_TEXTURE_3D_OES) + if(self._target == GL_TEXTURE_3D_OES) #endif for(GLsizei level = 0; level != levels; ++level) - DataHelper<3>::setImage(*this, level, finalInternalFormat, + DataHelper<3>::setImage(self, level, finalInternalFormat, ImageView3D{format, type, Math::max(Vector3i(1), size >> level)}); #ifndef MAGNUM_TARGET_GLES2 /* Array texture is not scaled in "layer" dimension */ - else if(_target == GL_TEXTURE_2D_ARRAY || _target == + else if(self._target == GL_TEXTURE_2D_ARRAY || self._target == #ifndef MAGNUM_TARGET_GLES GL_TEXTURE_CUBE_MAP_ARRAY #else @@ -1430,7 +1430,7 @@ void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureForma #endif ) { for(GLsizei level = 0; level != levels; ++level) - DataHelper<3>::setImage(*this, level, internalFormat, + DataHelper<3>::setImage(self, level, internalFormat, ImageView3D{format, type, Vector3i{Math::max(Vector2i{1}, size.xy() >> level), size.z()}}); } #endif @@ -1441,126 +1441,126 @@ void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureForma #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) -void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { - bindInternal(); +void AbstractTexture::storageImplementationDefault(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { + self.bindInternal(); #ifndef MAGNUM_TARGET_GLES2 - glTexStorage3D(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); + glTexStorage3D(self._target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); #else - glTexStorage3DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); + glTexStorage3DEXT(self._target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); #endif } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) { - glTextureStorage3D(_id, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); +void AbstractTexture::storageImplementationDSA(AbstractTexture& self, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) { + glTextureStorage3D(self._id, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageMultisampleImplementationFallback(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { - bindInternal(); - glTexImage2DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); +void AbstractTexture::storageMultisampleImplementationFallback(AbstractTexture& self, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { + self.bindInternal(); + glTexImage2DMultisample(self._target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) -void AbstractTexture::storageMultisampleImplementationDefault(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { - bindInternal(); - glTexStorage2DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); +void AbstractTexture::storageMultisampleImplementationDefault(AbstractTexture& self, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { + self.bindInternal(); + glTexStorage2DMultisample(self._target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageMultisampleImplementationDSA(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { - glTextureStorage2DMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); +void AbstractTexture::storageMultisampleImplementationDSA(AbstractTexture& self, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { + glTextureStorage2DMultisample(self._id, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); } -void AbstractTexture::storageMultisampleImplementationFallback(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { - bindInternal(); - glTexImage3DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); +void AbstractTexture::storageMultisampleImplementationFallback(AbstractTexture& self, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { + self.bindInternal(); + glTexImage3DMultisample(self._target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) -void AbstractTexture::storageMultisampleImplementationDefault(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { - bindInternal(); - glTexStorage3DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); +void AbstractTexture::storageMultisampleImplementationDefault(AbstractTexture& self, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { + self.bindInternal(); + glTexStorage3DMultisample(self._target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } #ifdef MAGNUM_TARGET_GLES -void AbstractTexture::storageMultisampleImplementationOES(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { - bindInternal(); - glTexStorage3DMultisampleOES(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); +void AbstractTexture::storageMultisampleImplementationOES(AbstractTexture& self, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { + self.bindInternal(); + glTexStorage3DMultisampleOES(self._target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } #endif #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageMultisampleImplementationDSA(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { - glTextureStorage3DMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); +void AbstractTexture::storageMultisampleImplementationDSA(AbstractTexture& self, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { + glTextureStorage3DMultisample(self._id, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::getImageImplementationDefault(const GLint level, const PixelFormat format, const PixelType type, const std::size_t, GLvoid* const data) { - bindInternal(); - glGetTexImage(_target, level, GLenum(format), GLenum(type), data); +void AbstractTexture::getImageImplementationDefault(AbstractTexture& self, const GLint level, const PixelFormat format, const PixelType type, const std::size_t, GLvoid* const data) { + self.bindInternal(); + glGetTexImage(self._target, level, GLenum(format), GLenum(type), data); } -void AbstractTexture::getCompressedImageImplementationDefault(const GLint level, std::size_t, GLvoid* const data) { - bindInternal(); - glGetCompressedTexImage(_target, level, data); +void AbstractTexture::getCompressedImageImplementationDefault(AbstractTexture& self, const GLint level, std::size_t, GLvoid* const data) { + self.bindInternal(); + glGetCompressedTexImage(self._target, level, data); } -void AbstractTexture::getImageImplementationDSA(const GLint level, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { - glGetTextureImage(_id, level, GLenum(format), GLenum(type), dataSize, data); +void AbstractTexture::getImageImplementationDSA(AbstractTexture& self, const GLint level, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { + glGetTextureImage(self._id, level, GLenum(format), GLenum(type), dataSize, data); } -void AbstractTexture::getCompressedImageImplementationDSA(const GLint level, const std::size_t dataSize, GLvoid* const data) { - glGetCompressedTextureImage(_id, level, dataSize, data); +void AbstractTexture::getCompressedImageImplementationDSA(AbstractTexture& self, const GLint level, const std::size_t dataSize, GLvoid* const data) { + glGetCompressedTextureImage(self._id, level, dataSize, data); } -void AbstractTexture::getImageImplementationRobustness(const GLint level, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { - bindInternal(); - glGetnTexImageARB(_target, level, GLenum(format), GLenum(type), dataSize, data); +void AbstractTexture::getImageImplementationRobustness(AbstractTexture& self, const GLint level, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { + self.bindInternal(); + glGetnTexImageARB(self._target, level, GLenum(format), GLenum(type), dataSize, data); } -void AbstractTexture::getCompressedImageImplementationRobustness(const GLint level, const std::size_t dataSize, GLvoid* const data) { - bindInternal(); - glGetnCompressedTexImageARB(_target, level, dataSize, data); +void AbstractTexture::getCompressedImageImplementationRobustness(AbstractTexture& self, const GLint level, const std::size_t dataSize, GLvoid* const data) { + self.bindInternal(); + glGetnCompressedTexImageARB(self._target, level, dataSize, data); } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data) { - bindInternal(); - glTexSubImage1D(_target, level, offset[0], size[0], GLenum(format), GLenum(type), data); +void AbstractTexture::subImageImplementationDefault(AbstractTexture& self, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data) { + self.bindInternal(); + glTexSubImage1D(self._target, level, offset[0], size[0], GLenum(format), GLenum(type), data); } -void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { - bindInternal(); - glCompressedTexSubImage1D(_target, level, offset[0], size[0], GLenum(format), dataSize, data); +void AbstractTexture::compressedSubImageImplementationDefault(AbstractTexture& self, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { + self.bindInternal(); + glCompressedTexSubImage1D(self._target, level, offset[0], size[0], GLenum(format), dataSize, data); } -void AbstractTexture::subImageImplementationDSA(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { - glTextureSubImage1D(_id, level, offset[0], size[0], GLenum(format), GLenum(type), data); +void AbstractTexture::subImageImplementationDSA(AbstractTexture& self, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { + glTextureSubImage1D(self._id, level, offset[0], size[0], GLenum(format), GLenum(type), data); } -void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { - glCompressedTextureSubImage1D(_id, level, offset[0], size[0], GLenum(format), dataSize, data); +void AbstractTexture::compressedSubImageImplementationDSA(AbstractTexture& self, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { + glCompressedTextureSubImage1D(self._id, level, offset[0], size[0], GLenum(format), dataSize, data); } #endif -void AbstractTexture::imageImplementationDefault(const GLenum target, const GLint level, const TextureFormat internalFormat, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) { - bindInternal(); +void AbstractTexture::imageImplementationDefault(AbstractTexture& self, const GLenum target, const GLint level, const TextureFormat internalFormat, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) { + self.bindInternal(); glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::imageImplementationSvga3DSliceBySlice(const GLenum target, const GLint level, const TextureFormat internalFormat, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage& storage) { +void AbstractTexture::imageImplementationSvga3DSliceBySlice(AbstractTexture& self, const GLenum target, const GLint level, const TextureFormat internalFormat, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage& storage) { /* Allocate and upload the first slice */ - imageImplementationDefault(target, level, internalFormat, size, format, type, data, storage); + imageImplementationDefault(self, target, level, internalFormat, size, format, type, data, storage); /* Upload the next slices slice by slice only if this is an array texture with more than one slice and we are copying from user memory (not from a @@ -1570,63 +1570,63 @@ void AbstractTexture::imageImplementationSvga3DSliceBySlice(const GLenum target, DSA cleanness is not worth it. */ /** @todo this will break when we support uploading from buffer offset (i.e. data != nullptr) */ if(target == GL_TEXTURE_1D_ARRAY && data && size.y() > 1) - subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(level, {0, 1}, {size.x(), size.y() - 1}, format, type, static_cast(data) + std::get<1>(storage.dataProperties(pixelFormatSize(format, type), {size, 1})).x(), storage); + subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(self, level, {0, 1}, {size.x(), size.y() - 1}, format, type, static_cast(data) + std::get<1>(storage.dataProperties(pixelFormatSize(format, type), {size, 1})).x(), storage); } #endif -void AbstractTexture::subImage2DImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) { - bindInternal(); - glTexSubImage2D(_target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data); +void AbstractTexture::subImage2DImplementationDefault(AbstractTexture& self, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) { + self.bindInternal(); + glTexSubImage2D(self._target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data); } /* Doxygen gets confused by the template parameter */ #if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_GLES) -template void AbstractTexture::subImageImplementationSvga3DSliceBySlice(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* const data, const PixelStorage& storage) { +template void AbstractTexture::subImageImplementationSvga3DSliceBySlice(AbstractTexture& self, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* const data, const PixelStorage& storage) { /* Upload the data slice by slice only if this is an array texture and we are copying from user memory (not from a buffer) */ - if(_target == GL_TEXTURE_1D_ARRAY && data) { + if(self._target == GL_TEXTURE_1D_ARRAY && data) { const std::size_t stride = std::get<1>(storage.dataProperties(pixelFormatSize(format, type), {size, 1})).x(); for(Int i = 0; i != size.y(); ++i) - (this->*original)(level, {offset.x(), offset.y() + i}, {size.x(), 1}, format, type, static_cast(data) + stride*i, storage); + original(self, level, {offset.x(), offset.y() + i}, {size.x(), 1}, format, type, static_cast(data) + stride*i, storage); /* Otherwise just pass-though to the default implementation */ - } else (this->*original)(level, offset, size, format, type, data, storage); + } else original(self, level, offset, size, format, type, data, storage); } -template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); -template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDSA>(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); +template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(AbstractTexture&, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); +template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDSA>(AbstractTexture&, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); #endif -void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { - bindInternal(); - glCompressedTexSubImage2D(_target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data); +void AbstractTexture::compressedSubImageImplementationDefault(AbstractTexture& self, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { + self.bindInternal(); + glCompressedTexSubImage2D(self._target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImage2DImplementationDSA(const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) { - glTextureSubImage2D(_id, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data); +void AbstractTexture::subImage2DImplementationDSA(AbstractTexture& self, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) { + glTextureSubImage2D(self._id, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data); } -void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { - glCompressedTextureSubImage2D(_id, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data); +void AbstractTexture::compressedSubImageImplementationDSA(AbstractTexture& self, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { + glCompressedTextureSubImage2D(self._id, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data); } #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) -void AbstractTexture::imageImplementationDefault(GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) { - bindInternal(); +void AbstractTexture::imageImplementationDefault(AbstractTexture& self, GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) { + self.bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glTexImage3D #else glTexImage3DOES #endif - (_target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data); + (self._target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data); } #ifndef MAGNUM_TARGET_WEBGL -void AbstractTexture::imageImplementationSvga3DSliceBySlice(GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage& storage) { +void AbstractTexture::imageImplementationSvga3DSliceBySlice(AbstractTexture& self, GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage& storage) { /* Allocate and upload the first slice */ - imageImplementationDefault(level, internalFormat, size, format, type, data, storage); + imageImplementationDefault(self, level, internalFormat, size, format, type, data, storage); /* Upload the next slices slice by slice only if this is an array texture with more than one slice or a 3D texture and we are copying from user @@ -1637,88 +1637,88 @@ void AbstractTexture::imageImplementationSvga3DSliceBySlice(GLint level, Texture /** @todo this will break when we support uploading from buffer offset (i.e. data != nullptr) */ if(( #ifndef MAGNUM_TARGET_GLES2 - _target == GL_TEXTURE_2D_ARRAY || _target == GL_TEXTURE_3D + self._target == GL_TEXTURE_2D_ARRAY || self._target == GL_TEXTURE_3D #else - _target == GL_TEXTURE_3D_OES + self._target == GL_TEXTURE_3D_OES #endif ) && data && size.z() > 1) { - subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(level, {0, 0, 1}, {size.xy(), size.z() - 1}, format, type, static_cast(data) + std::get<1>(storage.dataProperties(pixelFormatSize(format, type), size)).xy().product(), storage); + subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(self, level, {0, 0, 1}, {size.xy(), size.z() - 1}, format, type, static_cast(data) + std::get<1>(storage.dataProperties(pixelFormatSize(format, type), size)).xy().product(), storage); } } #endif -void AbstractTexture::subImage3DImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) { - bindInternal(); +void AbstractTexture::subImage3DImplementationDefault(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) { + self.bindInternal(); #ifndef MAGNUM_TARGET_GLES2 - glTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); + glTexSubImage3D(self._target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); #else - glTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); + glTexSubImage3DOES(self._target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); #endif } /* Doxygen gets confused by the template parameter */ #if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL) -template void AbstractTexture::subImageImplementationSvga3DSliceBySlice(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* const data, const PixelStorage& storage) { +template void AbstractTexture::subImageImplementationSvga3DSliceBySlice(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* const data, const PixelStorage& storage) { /* Upload the data slice by slice only if this is an array texture and we are copying from user memory (not from a buffer) */ if( #ifndef MAGNUM_TARGET_GLES2 - _target == GL_TEXTURE_2D_ARRAY || _target == GL_TEXTURE_3D + self._target == GL_TEXTURE_2D_ARRAY || self._target == GL_TEXTURE_3D #else - _target == GL_TEXTURE_3D_OES + self._target == GL_TEXTURE_3D_OES #endif ) { const std::size_t stride = std::get<1>(storage.dataProperties(pixelFormatSize(format, type), size)).xy().product(); for(Int i = 0; i != size.z(); ++i) - (this->*original)(level, {offset.xy(), offset.z() + i}, {size.xy(), 1}, format, type, static_cast(data) + stride*i, storage); + original(self, level, {offset.xy(), offset.z() + i}, {size.xy(), 1}, format, type, static_cast(data) + stride*i, storage); /* Otherwise just pass-though to the default implementation */ - } else (this->*original)(level, offset, size, format, type, data, storage); + } else original(self, level, offset, size, format, type, data, storage); } -template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); +template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(AbstractTexture&, GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); #ifndef MAGNUM_TARGET_GLES -template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDSA>(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); +template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDSA>(AbstractTexture&, GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); #endif #endif -void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { - bindInternal(); +void AbstractTexture::compressedSubImageImplementationDefault(AbstractTexture& self, const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { + self.bindInternal(); #ifndef MAGNUM_TARGET_GLES2 - glCompressedTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); + glCompressedTexSubImage3D(self._target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); #else - glCompressedTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); + glCompressedTexSubImage3DOES(self._target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); #endif } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImage3DImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) { - glTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); +void AbstractTexture::subImage3DImplementationDSA(AbstractTexture& self, const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) { + glTextureSubImage3D(self._id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); } -void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { - glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); +void AbstractTexture::compressedSubImageImplementationDSA(AbstractTexture& self, const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { + glCompressedTextureSubImage3D(self._id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); } #endif -void AbstractTexture::invalidateImageImplementationNoOp(GLint) {} +void AbstractTexture::invalidateImageImplementationNoOp(AbstractTexture&, GLint) {} #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::invalidateImageImplementationARB(GLint level) { - createIfNotAlready(); - glInvalidateTexImage(_id, level); +void AbstractTexture::invalidateImageImplementationARB(AbstractTexture& self, GLint level) { + self.createIfNotAlready(); + glInvalidateTexImage(self._id, level); } #endif -void AbstractTexture::invalidateSubImageImplementationNoOp(GLint, const Vector3i&, const Vector3i&) {} +void AbstractTexture::invalidateSubImageImplementationNoOp(AbstractTexture&, GLint, const Vector3i&, const Vector3i&) {} #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vector3i& offset, const Vector3i& size) { - createIfNotAlready(); - glInvalidateTexSubImage(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z()); +void AbstractTexture::invalidateSubImageImplementationARB(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size) { + self.createIfNotAlready(); + glInvalidateTexSubImage(self._id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z()); } #endif @@ -1735,7 +1735,7 @@ template void AbstractTexture::image(const GLint level, Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getImageImplementation)(level, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data); + Context::current().state().texture.getImageImplementation(*this, level, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data); image = Image{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data), flags}; } @@ -1754,7 +1754,7 @@ template void AbstractTexture::image(GLint level, const Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getImageImplementation)(level, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data()); + Context::current().state().texture.getImageImplementation(*this, level, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data()); } template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, const BasicMutableImageView<1>&); @@ -1773,7 +1773,7 @@ template void AbstractTexture::image(GLint level, Buffer image.buffer().bindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getImageImplementation)(level, image.format(), image.type(), dataSize, nullptr); + Context::current().state().texture.getImageImplementation(*this, level, image.format(), image.type(), dataSize, nullptr); } template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, BufferImage<1>&, BufferUsage); @@ -1788,13 +1788,13 @@ template void AbstractTexture::compressedImage(const GLi std::size_t dataSize; if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { GLint textureDataSize; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); + Context::current().state().texture.getLevelParameterivImplementation(*this, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); dataSize = textureDataSize; } else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); /* Internal texture format */ GLint format; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ Containers::Array data{image.release()}; @@ -1803,7 +1803,7 @@ template void AbstractTexture::compressedImage(const GLi Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCompressedImageImplementation)(level, data.size(), data); + Context::current().state().texture.getCompressedImageImplementation(*this, level, data.size(), data); image = CompressedImage{image.storage(), CompressedPixelFormat(format), size, std::move(data), flags}; } @@ -1825,7 +1825,7 @@ template void AbstractTexture::compressedImage(const GLi std::size_t dataSize; if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { GLint textureDataSize; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); + Context::current().state().texture.getLevelParameterivImplementation(*this, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); dataSize = textureDataSize; } else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); @@ -1834,7 +1834,7 @@ template void AbstractTexture::compressedImage(const GLi /* Internal texture format */ GLint format; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), "GL::AbstractTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); @@ -1842,7 +1842,7 @@ template void AbstractTexture::compressedImage(const GLi Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCompressedImageImplementation)(level, image.data().size(), image.data()); + Context::current().state().texture.getCompressedImageImplementation(*this, level, image.data().size(), image.data()); } template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, const BasicMutableCompressedImageView<1>&); @@ -1857,13 +1857,13 @@ template void AbstractTexture::compressedImage(const GLi std::size_t dataSize; if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { GLint textureDataSize; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); + Context::current().state().texture.getLevelParameterivImplementation(*this, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); dataSize = textureDataSize; } else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); /* Internal texture format */ GLint format; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ if(image.dataSize() < dataSize) @@ -1873,7 +1873,7 @@ template void AbstractTexture::compressedImage(const GLi image.buffer().bindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCompressedImageImplementation)(level, dataSize, nullptr); + Context::current().state().texture.getCompressedImageImplementation(*this, level, dataSize, nullptr); } template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedBufferImage<1>&, BufferUsage); @@ -1961,7 +1961,7 @@ template void AbstractTexture::compressedSubImage(const /* Internal texture format */ GLint format; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Calculate compressed subimage size. If the user-provided pixel storage doesn't tell us all properties about the compression, we need to ask GL @@ -1999,7 +1999,7 @@ template void AbstractTexture::compressedSubImage(const #ifndef CORRADE_NO_ASSERT /* Internal texture format */ GLint format; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), "GL::AbstractTexture::compressedSubImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); @@ -2037,7 +2037,7 @@ template void AbstractTexture::compressedSubImage(const /* Internal texture format */ GLint format; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Calculate compressed subimage size. If the user-provided pixel storage doesn't tell us all properties about the compression, we need to ask GL @@ -2088,7 +2088,7 @@ Vector3i AbstractTexture::DataHelper<3>::compressedBlockSize(const GLenum target #ifndef MAGNUM_TARGET_GLES Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, const GLint level) { Math::Vector<1, GLint> value; - (texture.*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); + Context::current().state().texture.getLevelParameterivImplementation(texture, level, GL_TEXTURE_WIDTH, &value[0]); return value; } #endif @@ -2098,8 +2098,8 @@ Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, con const Implementation::TextureState& state = Context::current().state().texture; Vector2i value; - (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); - (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]); + state.getLevelParameterivImplementation(texture, level, GL_TEXTURE_WIDTH, &value[0]); + state.getLevelParameterivImplementation(texture, level, GL_TEXTURE_HEIGHT, &value[1]); return value; } @@ -2107,36 +2107,36 @@ Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, con const Implementation::TextureState& state = Context::current().state().texture; Vector3i value; - (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); - (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]); - (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_DEPTH, &value[2]); + state.getLevelParameterivImplementation(texture, level, GL_TEXTURE_WIDTH, &value[0]); + state.getLevelParameterivImplementation(texture, level, GL_TEXTURE_HEIGHT, &value[1]); + state.getLevelParameterivImplementation(texture, level, GL_TEXTURE_DEPTH, &value[2]); return value; } #endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) { - (texture.*Context::current().state().texture.storage1DImplementation)(levels, internalFormat, size); + Context::current().state().texture.storage1DImplementation(texture, levels, internalFormat, size); } #endif void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { - (texture.*Context::current().state().texture.storage2DImplementation)(levels, internalFormat, size); + Context::current().state().texture.storage2DImplementation(texture, levels, internalFormat, size); } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) { - (texture.*Context::current().state().texture.storage3DImplementation)(levels, internalFormat, size); + Context::current().state().texture.storage3DImplementation(texture, levels, internalFormat, size); } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::DataHelper<2>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { - (texture.*Context::current().state().texture.storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); + Context::current().state().texture.storage2DMultisampleImplementation(texture, samples, internalFormat, size, fixedSampleLocations); } void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { - (texture.*Context::current().state().texture.storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); + Context::current().state().texture.storage3DMultisampleImplementation(texture, samples, internalFormat, size, fixedSampleLocations); } #endif @@ -2172,25 +2172,25 @@ void AbstractTexture::DataHelper<1>::setCompressedImage(AbstractTexture& texture void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const ImageView1D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.subImage1DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data()); + Context::current().state().texture.subImage1DImplementation(texture, level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data()); } void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const CompressedImageView1D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.compressedSubImage1DImplementation)(level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); + Context::current().state().texture.compressedSubImage1DImplementation(texture, level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); } void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr); + Context::current().state().texture.subImage1DImplementation(texture, level, offset, image.size(), image.format(), image.type(), nullptr); } void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, CompressedBufferImage1D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.compressedSubImage1DImplementation)(level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); + Context::current().state().texture.compressedSubImage1DImplementation(texture, level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); } #endif @@ -2199,7 +2199,7 @@ void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GL Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.image2DImplementation)(target, level, internalFormat, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() + Context::current().state().texture.image2DImplementation(texture, target, level, internalFormat, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -2236,7 +2236,7 @@ void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.subImage2DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() + Context::current().state().texture.subImage2DImplementation(texture, level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -2248,20 +2248,20 @@ void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& text Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.compressedSubImage2DImplementation)(level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); + Context::current().state().texture.compressedSubImage2DImplementation(texture, level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, BufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage()); + Context::current().state().texture.subImage2DImplementation(texture, level, offset, image.size(), image.format(), image.type(), nullptr, image.storage()); } void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, CompressedBufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.compressedSubImage2DImplementation)(level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); + Context::current().state().texture.compressedSubImage2DImplementation(texture, level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); } #endif @@ -2271,7 +2271,7 @@ void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GL Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.image3DImplementation)(level, internalFormat, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() + Context::current().state().texture.image3DImplementation(texture, level, internalFormat, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -2314,7 +2314,7 @@ void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.subImage3DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() + Context::current().state().texture.subImage3DImplementation(texture, level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -2326,7 +2326,7 @@ void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& text Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.compressedSubImage3DImplementation)(level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); + Context::current().state().texture.compressedSubImage3DImplementation(texture, level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); } #endif @@ -2334,53 +2334,53 @@ void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& text void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, BufferImage3D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage()); + Context::current().state().texture.subImage3DImplementation(texture, level, offset, image.size(), image.format(), image.type(), nullptr, image.storage()); } void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, CompressedBufferImage3D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture.compressedSubImage3DImplementation)(level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); + Context::current().state().texture.compressedSubImage3DImplementation(texture, level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); } #endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size) { - (texture.*Context::current().state().texture.invalidateSubImageImplementation)(level, {offset[0], 0, 0}, {size[0], 1, 1}); + Context::current().state().texture.invalidateSubImageImplementation(texture, level, {offset[0], 0, 0}, {size[0], 1, 1}); } #endif void AbstractTexture::DataHelper<2>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const Vector2i& size) { - (texture.*Context::current().state().texture.invalidateSubImageImplementation)(level, {offset, 0}, {size, 1}); + Context::current().state().texture.invalidateSubImageImplementation(texture, level, {offset, 0}, {size, 1}); } void AbstractTexture::DataHelper<3>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const Vector3i& size) { - (texture.*Context::current().state().texture.invalidateSubImageImplementation)(level, offset, size); + Context::current().state().texture.invalidateSubImageImplementation(texture, level, offset, size); } #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Math::Vector<1, SamplerWrapping>& wrapping) { - (texture.*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping[0])); + Context::current().state().texture.parameteriImplementation(texture, GL_TEXTURE_WRAP_S, GLint(wrapping[0])); } #endif void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Math::Vector2& wrapping) { const Implementation::TextureState& state = Context::current().state().texture; - (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); - (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y())); + state.parameteriImplementation(texture, GL_TEXTURE_WRAP_S, GLint(wrapping.x())); + state.parameteriImplementation(texture, GL_TEXTURE_WRAP_T, GLint(wrapping.y())); } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Math::Vector3& wrapping) { const Implementation::TextureState& state = Context::current().state().texture; - (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); - (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y())); + state.parameteriImplementation(texture, GL_TEXTURE_WRAP_S, GLint(wrapping.x())); + state.parameteriImplementation(texture, GL_TEXTURE_WRAP_T, GLint(wrapping.y())); #ifndef MAGNUM_TARGET_GLES2 - (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_R, GLint(wrapping.z())); + state.parameteriImplementation(texture, GL_TEXTURE_WRAP_R, GLint(wrapping.z())); #else - (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_R_OES, GLint(wrapping.z())); + state.parameteriImplementation(texture, GL_TEXTURE_WRAP_R_OES, GLint(wrapping.z())); #endif } #endif diff --git a/src/Magnum/GL/AbstractTexture.h b/src/Magnum/GL/AbstractTexture.h index 5f72a7085..809035f9d 100644 --- a/src/Magnum/GL/AbstractTexture.h +++ b/src/Magnum/GL/AbstractTexture.h @@ -531,173 +531,173 @@ class MAGNUM_GL_EXPORT AbstractTexture: public AbstractObject { static void MAGNUM_GL_LOCAL bindImplementationMulti(GLint firstTextureUnit, Containers::ArrayView textures); #endif - void MAGNUM_GL_LOCAL createImplementationDefault(); + static void MAGNUM_GL_LOCAL createImplementationDefault(AbstractTexture& self); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL createImplementationDSA(); + static void MAGNUM_GL_LOCAL createImplementationDSA(AbstractTexture& self); #endif #ifndef MAGNUM_TARGET_GLES template std::size_t MAGNUM_GL_LOCAL compressedSubImageSize(TextureFormat format, const Math::Vector& size); #endif - void MAGNUM_GL_LOCAL bindImplementationDefault(GLint textureUnit); + static void MAGNUM_GL_LOCAL bindImplementationDefault(AbstractTexture& self, GLint textureUnit); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL bindImplementationMulti(GLint textureUnit); - void MAGNUM_GL_LOCAL bindImplementationDSA(GLint textureUnit); + static void MAGNUM_GL_LOCAL bindImplementationMulti(AbstractTexture& self, GLint textureUnit); + static void MAGNUM_GL_LOCAL bindImplementationDSA(AbstractTexture& self, GLint textureUnit); #ifdef CORRADE_TARGET_WINDOWS - void MAGNUM_GL_LOCAL bindImplementationDSAIntelWindows(GLint textureUnit); + static void MAGNUM_GL_LOCAL bindImplementationDSAIntelWindows(AbstractTexture& self, GLint textureUnit); #endif #ifdef CORRADE_TARGET_APPLE - void MAGNUM_GL_LOCAL bindImplementationAppleBufferTextureWorkaround(GLint textureUnit); + static void MAGNUM_GL_LOCAL bindImplementationAppleBufferTextureWorkaround(AbstractTexture& self, GLint textureUnit); #endif #endif - void MAGNUM_GL_LOCAL parameterImplementationDefault(GLenum parameter, GLint value); - void MAGNUM_GL_LOCAL parameterImplementationDefault(GLenum parameter, GLfloat value); + static void MAGNUM_GL_LOCAL parameterImplementationDefault(AbstractTexture& self, GLenum parameter, GLint value); + static void MAGNUM_GL_LOCAL parameterImplementationDefault(AbstractTexture& self, GLenum parameter, GLfloat value); #ifndef MAGNUM_TARGET_GLES2 - void MAGNUM_GL_LOCAL parameterImplementationDefault(GLenum parameter, const GLint* values); + static void MAGNUM_GL_LOCAL parameterImplementationDefault(AbstractTexture& self, GLenum parameter, const GLint* values); #endif - void MAGNUM_GL_LOCAL parameterImplementationDefault(GLenum parameter, const GLfloat* values); + static void MAGNUM_GL_LOCAL parameterImplementationDefault(AbstractTexture& self, GLenum parameter, const GLfloat* values); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void MAGNUM_GL_LOCAL parameterIImplementationDefault(GLenum parameter, const GLuint* values); - void MAGNUM_GL_LOCAL parameterIImplementationDefault(GLenum parameter, const GLint* values); + static void MAGNUM_GL_LOCAL parameterIImplementationDefault(AbstractTexture& self, GLenum parameter, const GLuint* values); + static void MAGNUM_GL_LOCAL parameterIImplementationDefault(AbstractTexture& self, GLenum parameter, const GLint* values); #ifdef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL parameterIImplementationEXT(GLenum parameter, const GLuint* values); - void MAGNUM_GL_LOCAL parameterIImplementationEXT(GLenum parameter, const GLint* values); + static void MAGNUM_GL_LOCAL parameterIImplementationEXT(AbstractTexture& self, GLenum parameter, const GLuint* values); + static void MAGNUM_GL_LOCAL parameterIImplementationEXT(AbstractTexture& self, GLenum parameter, const GLint* values); #endif #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL parameterImplementationDSA(GLenum parameter, GLint value); - void MAGNUM_GL_LOCAL parameterImplementationDSA(GLenum parameter, GLfloat value); - void MAGNUM_GL_LOCAL parameterImplementationDSA(GLenum parameter, const GLint* values); - void MAGNUM_GL_LOCAL parameterImplementationDSA(GLenum parameter, const GLfloat* values); - void MAGNUM_GL_LOCAL parameterIImplementationDSA(GLenum parameter, const GLuint* values); - void MAGNUM_GL_LOCAL parameterIImplementationDSA(GLenum parameter, const GLint* values); + static void MAGNUM_GL_LOCAL parameterImplementationDSA(AbstractTexture& self, GLenum parameter, GLint value); + static void MAGNUM_GL_LOCAL parameterImplementationDSA(AbstractTexture& self, GLenum parameter, GLfloat value); + static void MAGNUM_GL_LOCAL parameterImplementationDSA(AbstractTexture& self, GLenum parameter, const GLint* values); + static void MAGNUM_GL_LOCAL parameterImplementationDSA(AbstractTexture& self, GLenum parameter, const GLfloat* values); + static void MAGNUM_GL_LOCAL parameterIImplementationDSA(AbstractTexture& self, GLenum parameter, const GLuint* values); + static void MAGNUM_GL_LOCAL parameterIImplementationDSA(AbstractTexture& self, GLenum parameter, const GLint* values); #endif - void MAGNUM_GL_LOCAL setMaxAnisotropyImplementationNoOp(GLfloat); - void MAGNUM_GL_LOCAL setMaxAnisotropyImplementationArbOrExt(GLfloat anisotropy); + static void MAGNUM_GL_LOCAL setMaxAnisotropyImplementationNoOp(AbstractTexture& self, GLfloat); + static void MAGNUM_GL_LOCAL setMaxAnisotropyImplementationArbOrExt(AbstractTexture& self, GLfloat anisotropy); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void MAGNUM_GL_LOCAL getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values); + static void MAGNUM_GL_LOCAL getLevelParameterImplementationDefault(AbstractTexture& self, GLint level, GLenum parameter, GLint* values); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL getLevelParameterImplementationDSA(GLint level, GLenum parameter, GLint* values); + static void MAGNUM_GL_LOCAL getLevelParameterImplementationDSA(AbstractTexture& self, GLint level, GLenum parameter, GLint* values); #endif #endif - void MAGNUM_GL_LOCAL mipmapImplementationDefault(); + static void MAGNUM_GL_LOCAL mipmapImplementationDefault(AbstractTexture& self); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL mipmapImplementationDSA(); + static void MAGNUM_GL_LOCAL mipmapImplementationDSA(AbstractTexture& self); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); - void MAGNUM_GL_LOCAL storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); - void MAGNUM_GL_LOCAL storageImplementationDSA(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); + static void MAGNUM_GL_LOCAL storageImplementationFallback(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); + static void MAGNUM_GL_LOCAL storageImplementationDefault(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); + static void MAGNUM_GL_LOCAL storageImplementationDSA(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); #endif #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) - void MAGNUM_GL_LOCAL storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector2i& size); + static void MAGNUM_GL_LOCAL storageImplementationFallback(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void MAGNUM_GL_LOCAL storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector2i& size); + static void MAGNUM_GL_LOCAL storageImplementationDefault(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL storageImplementationDSA(GLsizei levels, TextureFormat internalFormat, const Vector2i& size); + static void MAGNUM_GL_LOCAL storageImplementationDSA(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); #endif #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) - void MAGNUM_GL_LOCAL storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector3i& size); + static void MAGNUM_GL_LOCAL storageImplementationFallback(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void MAGNUM_GL_LOCAL storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector3i& size); + static void MAGNUM_GL_LOCAL storageImplementationDefault(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL storageImplementationDSA(GLsizei levels, TextureFormat internalFormat, const Vector3i& size); + static void MAGNUM_GL_LOCAL storageImplementationDSA(AbstractTexture& self, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL storageMultisampleImplementationFallback(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); - void MAGNUM_GL_LOCAL storageMultisampleImplementationFallback(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationFallback(AbstractTexture& self, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationFallback(AbstractTexture& self, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void MAGNUM_GL_LOCAL storageMultisampleImplementationDefault(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); - void MAGNUM_GL_LOCAL storageMultisampleImplementationDefault(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationDefault(AbstractTexture& self, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationDefault(AbstractTexture& self, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); #ifdef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL storageMultisampleImplementationOES(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationOES(AbstractTexture& self, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); #endif #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL storageMultisampleImplementationDSA(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); - void MAGNUM_GL_LOCAL storageMultisampleImplementationDSA(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationDSA(AbstractTexture& self, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationDSA(AbstractTexture& self, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL getImageImplementationDefault(GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getImageImplementationDSA(GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getImageImplementationRobustness(GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getImageImplementationDefault(AbstractTexture& self, GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getImageImplementationDSA(AbstractTexture& self, GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getImageImplementationRobustness(AbstractTexture& self, GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getCompressedImageImplementationDefault(GLint level, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getCompressedImageImplementationDSA(GLint level, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getCompressedImageImplementationRobustness(GLint level, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getCompressedImageImplementationDefault(AbstractTexture& self, GLint level, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getCompressedImageImplementationDSA(AbstractTexture& self, GLint level, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getCompressedImageImplementationRobustness(AbstractTexture& self, GLint level, std::size_t dataSize, GLvoid* data); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL subImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data); - void MAGNUM_GL_LOCAL subImageImplementationDSA(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data); + static void MAGNUM_GL_LOCAL subImageImplementationDefault(AbstractTexture& self, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data); + static void MAGNUM_GL_LOCAL subImageImplementationDSA(AbstractTexture& self, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data); - void MAGNUM_GL_LOCAL compressedSubImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); - void MAGNUM_GL_LOCAL compressedSubImageImplementationDSA(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + static void MAGNUM_GL_LOCAL compressedSubImageImplementationDefault(AbstractTexture& self, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + static void MAGNUM_GL_LOCAL compressedSubImageImplementationDSA(AbstractTexture& self, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); #endif - void MAGNUM_GL_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL imageImplementationDefault(AbstractTexture& self, GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL imageImplementationSvga3DSliceBySlice(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL imageImplementationSvga3DSliceBySlice(AbstractTexture& self, GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); #endif /* Had to put explicit "2D" in the name so it's not overloaded and Clang is able to pass it as template parameter to subImageImplementationSvga3DSliceBySlice(). GCC had no problem with the original. */ - void MAGNUM_GL_LOCAL subImage2DImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL subImage2DImplementationDefault(AbstractTexture& self, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); #ifndef MAGNUM_TARGET_GLES - template void MAGNUM_GL_LOCAL subImageImplementationSvga3DSliceBySlice(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage& storage); + template static void MAGNUM_GL_LOCAL subImageImplementationSvga3DSliceBySlice(AbstractTexture& self, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage& storage); #endif - void MAGNUM_GL_LOCAL compressedSubImageImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + static void MAGNUM_GL_LOCAL compressedSubImageImplementationDefault(AbstractTexture& self, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL subImage2DImplementationDSA(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); - void MAGNUM_GL_LOCAL compressedSubImageImplementationDSA(GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + static void MAGNUM_GL_LOCAL subImage2DImplementationDSA(AbstractTexture& self, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL compressedSubImageImplementationDSA(AbstractTexture& self, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void MAGNUM_GL_LOCAL imageImplementationDefault(GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL imageImplementationDefault(AbstractTexture& self, GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); #ifndef MAGNUM_TARGET_WEBGL - void MAGNUM_GL_LOCAL imageImplementationSvga3DSliceBySlice(GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL imageImplementationSvga3DSliceBySlice(AbstractTexture& self, GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); #endif /* Had to put explicit "3D" in the name so it's not overloaded and Clang is able to pass it as template parameter to subImageImplementationSvga3DSliceBySlice(). GCC had no problem with the original. */ - void MAGNUM_GL_LOCAL subImage3DImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL subImage3DImplementationDefault(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); #ifndef MAGNUM_TARGET_WEBGL - template void MAGNUM_GL_LOCAL subImageImplementationSvga3DSliceBySlice(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage& storage); + template static void MAGNUM_GL_LOCAL subImageImplementationSvga3DSliceBySlice(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage& storage); #endif - void MAGNUM_GL_LOCAL compressedSubImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + static void MAGNUM_GL_LOCAL compressedSubImageImplementationDefault(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL subImage3DImplementationDSA(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL subImage3DImplementationDSA(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); #ifndef MAGNUM_TARGET_WEBGL #endif - void MAGNUM_GL_LOCAL compressedSubImageImplementationDSA(GLint level, const Vector3i& offset, const Vector3i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + static void MAGNUM_GL_LOCAL compressedSubImageImplementationDSA(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); #endif - void MAGNUM_GL_LOCAL invalidateImageImplementationNoOp(GLint level); + static void MAGNUM_GL_LOCAL invalidateImageImplementationNoOp(AbstractTexture& self, GLint level); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL invalidateImageImplementationARB(GLint level); + static void MAGNUM_GL_LOCAL invalidateImageImplementationARB(AbstractTexture& self, GLint level); #endif - void MAGNUM_GL_LOCAL invalidateSubImageImplementationNoOp(GLint level, const Vector3i& offset, const Vector3i& size); + static void MAGNUM_GL_LOCAL invalidateSubImageImplementationNoOp(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL invalidateSubImageImplementationARB(GLint level, const Vector3i& offset, const Vector3i& size); + static void MAGNUM_GL_LOCAL invalidateSubImageImplementationARB(AbstractTexture& self, GLint level, const Vector3i& offset, const Vector3i& size); #endif GLuint _id; @@ -828,14 +828,14 @@ inline GLuint AbstractTexture::release() { #ifdef CORRADE_TARGET_CLANG_CL /* Otherwise Clang-CL complains these functions are not defined */ #ifndef MAGNUM_TARGET_GLES -extern template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); -extern template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDSA>(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); +extern template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(AbstractTexture&, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); +extern template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDSA>(AbstractTexture&, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); #endif #ifndef MAGNUM_TARGET_WEBGL -extern template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); +extern template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(AbstractTexture&, GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); #ifndef MAGNUM_TARGET_GLES -extern template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDSA>(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); +extern template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDSA>(AbstractTexture&, GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); #endif #endif #endif diff --git a/src/Magnum/GL/Buffer.cpp b/src/Magnum/GL/Buffer.cpp index 91fc38daf..78a0b5c13 100644 --- a/src/Magnum/GL/Buffer.cpp +++ b/src/Magnum/GL/Buffer.cpp @@ -171,23 +171,23 @@ void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const Buffer::Buffer(const TargetHint targetHint): _flags{ObjectFlag::DeleteOnDestruction} { const Implementation::BufferState& state = Context::current().state().buffer; - (this->*state.createImplementation)(); - (this->*state.setTargetHintImplementation)(targetHint); + state.createImplementation(*this); + state.setTargetHintImplementation(*this, targetHint); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } Buffer::Buffer(GLuint id, TargetHint targetHint, ObjectFlags flags) noexcept: _id{id}, _flags{flags} { - (this->*Context::current().state().buffer.setTargetHintImplementation)(targetHint); + Context::current().state().buffer.setTargetHintImplementation(*this, targetHint); } -void Buffer::createImplementationDefault() { - glGenBuffers(1, &_id); +void Buffer::createImplementationDefault(Buffer& self) { + glGenBuffers(1, &self._id); } #ifndef MAGNUM_TARGET_GLES -void Buffer::createImplementationDSA() { - glCreateBuffers(1, &_id); - _flags |= ObjectFlag::Created; +void Buffer::createImplementationDSA(Buffer& self) { + glCreateBuffers(1, &self._id); + self._flags |= ObjectFlag::Created; } #endif @@ -205,19 +205,19 @@ Buffer::~Buffer() { } Buffer& Buffer::setTargetHint(TargetHint hint) { - (this->*Context::current().state().buffer.setTargetHintImplementation)(hint); + Context::current().state().buffer.setTargetHintImplementation(*this, hint); return *this; } -void Buffer::setTargetHintImplementationDefault(const TargetHint hint) { - _targetHint = hint; +void Buffer::setTargetHintImplementationDefault(Buffer& self, const TargetHint hint) { + self._targetHint = hint; } #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) -void Buffer::setTargetHintImplementationSwiftShader(const TargetHint hint) { +void Buffer::setTargetHintImplementationSwiftShader(Buffer& self, const TargetHint hint) { /* See the "swiftshader-broken-xfb-buffer-binding-target" workaround for details */ - _targetHint = hint == TargetHint::TransformFeedback ? TargetHint::Array : hint; + self._targetHint = hint == TargetHint::TransformFeedback ? TargetHint::Array : hint; } #endif @@ -314,7 +314,7 @@ Buffer& Buffer::bind(const Target target, const UnsignedInt index) { #ifndef MAGNUM_TARGET_GLES Buffer& Buffer::setStorage(const Containers::ArrayView data, const StorageFlags flags) { - (this->*Context::current().state().buffer.storageImplementation)(data, flags); + Context::current().state().buffer.storageImplementation(*this, data, flags); return *this; } @@ -329,7 +329,7 @@ Int Buffer::size() { * couldn't find any matching extension, though) */ GLint size; - (this->*Context::current().state().buffer.getParameterImplementation)(GL_BUFFER_SIZE, &size); + Context::current().state().buffer.getParameterImplementation(*this, GL_BUFFER_SIZE, &size); return size; } @@ -340,46 +340,46 @@ Containers::Array Buffer::data() { #endif Buffer& Buffer::setData(const Containers::ArrayView data, const BufferUsage usage) { - (this->*Context::current().state().buffer.dataImplementation)(data.size(), data, usage); + Context::current().state().buffer.dataImplementation(*this, data.size(), data, usage); return *this; } Buffer& Buffer::setSubData(const GLintptr offset, const Containers::ArrayView data) { - (this->*Context::current().state().buffer.subDataImplementation)(offset, data.size(), data); + Context::current().state().buffer.subDataImplementation(*this, offset, data.size(), data); return *this; } Buffer& Buffer::invalidateData() { - (this->*Context::current().state().buffer.invalidateImplementation)(); + Context::current().state().buffer.invalidateImplementation(*this); return *this; } Buffer& Buffer::invalidateSubData(const GLintptr offset, const GLsizeiptr length) { - (this->*Context::current().state().buffer.invalidateSubImplementation)(offset, length); + Context::current().state().buffer.invalidateSubImplementation(*this, offset, length); return *this; } #ifndef MAGNUM_TARGET_WEBGL char* Buffer::map(const MapAccess access) { - return static_cast((this->*Context::current().state().buffer.mapImplementation)(access)); + return static_cast(Context::current().state().buffer.mapImplementation(*this, access)); } Containers::ArrayView Buffer::map(const GLintptr offset, const GLsizeiptr length, const MapFlags flags) { - return {static_cast((this->*Context::current().state().buffer.mapRangeImplementation)(offset, length, flags)), std::size_t(length)}; + return {static_cast(Context::current().state().buffer.mapRangeImplementation(*this, offset, length, flags)), std::size_t(length)}; } Buffer& Buffer::flushMappedRange(const GLintptr offset, const GLsizeiptr length) { - (this->*Context::current().state().buffer.flushMappedRangeImplementation)(offset, length); + Context::current().state().buffer.flushMappedRangeImplementation(*this, offset, length); return *this; } -bool Buffer::unmap() { return (this->*Context::current().state().buffer.unmapImplementation)(); } +bool Buffer::unmap() { return Context::current().state().buffer.unmapImplementation(*this); } #endif #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) Containers::Array Buffer::subData(const GLintptr offset, const GLsizeiptr size) { Containers::Array data(size); - if(size) (this->*Context::current().state().buffer.getSubDataImplementation)(offset, size, data); + if(size) Context::current().state().buffer.getSubDataImplementation(*this, offset, size, data); return data; } #endif @@ -452,129 +452,129 @@ void Buffer::copyImplementationDSA(Buffer& read, Buffer& write, const GLintptr r #endif #ifndef MAGNUM_TARGET_GLES -void Buffer::storageImplementationDefault(Containers::ArrayView data, StorageFlags flags) { - glBufferStorage(GLenum(bindSomewhereInternal(_targetHint)), data.size(), data.data(), GLbitfield(flags)); +void Buffer::storageImplementationDefault(Buffer& self, Containers::ArrayView data, StorageFlags flags) { + glBufferStorage(GLenum(self.bindSomewhereInternal(self._targetHint)), data.size(), data.data(), GLbitfield(flags)); } -void Buffer::storageImplementationDSA(Containers::ArrayView data, const StorageFlags flags) { - glNamedBufferStorage(_id, data.size(), data.data(), GLbitfield(flags)); +void Buffer::storageImplementationDSA(Buffer& self, Containers::ArrayView data, const StorageFlags flags) { + glNamedBufferStorage(self._id, data.size(), data.data(), GLbitfield(flags)); } #endif -void Buffer::getParameterImplementationDefault(const GLenum value, GLint* const data) { - glGetBufferParameteriv(GLenum(bindSomewhereInternal(_targetHint)), value, data); +void Buffer::getParameterImplementationDefault(Buffer& self, const GLenum value, GLint* const data) { + glGetBufferParameteriv(GLenum(self.bindSomewhereInternal(self._targetHint)), value, data); } #ifndef MAGNUM_TARGET_GLES -void Buffer::getParameterImplementationDSA(const GLenum value, GLint* const data) { - glGetNamedBufferParameteriv(_id, value, data); +void Buffer::getParameterImplementationDSA(Buffer& self, const GLenum value, GLint* const data) { + glGetNamedBufferParameteriv(self._id, value, data); } #endif #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) -void Buffer::getSubDataImplementationDefault(const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { - glGetBufferSubData(GLenum(bindSomewhereInternal(_targetHint)), offset, size, data); +void Buffer::getSubDataImplementationDefault(Buffer& self, const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { + glGetBufferSubData(GLenum(self.bindSomewhereInternal(self._targetHint)), offset, size, data); } #endif #ifndef MAGNUM_TARGET_GLES -void Buffer::getSubDataImplementationDSA(const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { - glGetNamedBufferSubData(_id, offset, size, data); +void Buffer::getSubDataImplementationDSA(Buffer& self, const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { + glGetNamedBufferSubData(self._id, offset, size, data); } #endif -void Buffer::dataImplementationDefault(GLsizeiptr size, const GLvoid* data, BufferUsage usage) { - glBufferData(GLenum(bindSomewhereInternal(_targetHint)), size, data, GLenum(usage)); +void Buffer::dataImplementationDefault(Buffer& self, GLsizeiptr size, const GLvoid* data, BufferUsage usage) { + glBufferData(GLenum(self.bindSomewhereInternal(self._targetHint)), size, data, GLenum(usage)); } #ifndef MAGNUM_TARGET_GLES -void Buffer::dataImplementationDSA(const GLsizeiptr size, const GLvoid* const data, const BufferUsage usage) { - glNamedBufferData(_id, size, data, GLenum(usage)); +void Buffer::dataImplementationDSA(Buffer& self, const GLsizeiptr size, const GLvoid* const data, const BufferUsage usage) { + glNamedBufferData(self._id, size, data, GLenum(usage)); } #endif -void Buffer::subDataImplementationDefault(GLintptr offset, GLsizeiptr size, const GLvoid* data) { - glBufferSubData(GLenum(bindSomewhereInternal(_targetHint)), offset, size, data); +void Buffer::subDataImplementationDefault(Buffer& self, GLintptr offset, GLsizeiptr size, const GLvoid* data) { + glBufferSubData(GLenum(self.bindSomewhereInternal(self._targetHint)), offset, size, data); } #ifndef MAGNUM_TARGET_GLES -void Buffer::subDataImplementationDSA(const GLintptr offset, const GLsizeiptr size, const GLvoid* const data) { - glNamedBufferSubData(_id, offset, size, data); +void Buffer::subDataImplementationDSA(Buffer& self, const GLintptr offset, const GLsizeiptr size, const GLvoid* const data) { + glNamedBufferSubData(self._id, offset, size, data); } #endif -void Buffer::invalidateImplementationNoOp() {} +void Buffer::invalidateImplementationNoOp(Buffer&) {} #ifndef MAGNUM_TARGET_GLES -void Buffer::invalidateImplementationARB() { - createIfNotAlready(); - glInvalidateBufferData(_id); +void Buffer::invalidateImplementationARB(Buffer& self) { + self.createIfNotAlready(); + glInvalidateBufferData(self._id); } #endif -void Buffer::invalidateSubImplementationNoOp(GLintptr, GLsizeiptr) {} +void Buffer::invalidateSubImplementationNoOp(Buffer&, GLintptr, GLsizeiptr) {} #ifndef MAGNUM_TARGET_GLES -void Buffer::invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length) { - createIfNotAlready(); - glInvalidateBufferSubData(_id, offset, length); +void Buffer::invalidateSubImplementationARB(Buffer& self, GLintptr offset, GLsizeiptr length) { + self.createIfNotAlready(); + glInvalidateBufferSubData(self._id, offset, length); } #endif #ifndef MAGNUM_TARGET_WEBGL -void* Buffer::mapImplementationDefault(MapAccess access) { +void* Buffer::mapImplementationDefault(Buffer& self, MapAccess access) { #ifndef MAGNUM_TARGET_GLES - return glMapBuffer(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); + return glMapBuffer(GLenum(self.bindSomewhereInternal(self._targetHint)), GLenum(access)); #else - return glMapBufferOES(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); + return glMapBufferOES(GLenum(self.bindSomewhereInternal(self._targetHint)), GLenum(access)); #endif } #ifndef MAGNUM_TARGET_GLES -void* Buffer::mapImplementationDSA(const MapAccess access) { - return glMapNamedBuffer(_id, GLenum(access)); +void* Buffer::mapImplementationDSA(Buffer& self, const MapAccess access) { + return glMapNamedBuffer(self._id, GLenum(access)); } #endif -void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access) { +void* Buffer::mapRangeImplementationDefault(Buffer& self, GLintptr offset, GLsizeiptr length, MapFlags access) { #ifndef MAGNUM_TARGET_GLES2 - return glMapBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); + return glMapBufferRange(GLenum(self.bindSomewhereInternal(self._targetHint)), offset, length, GLenum(access)); #else - return glMapBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); + return glMapBufferRangeEXT(GLenum(self.bindSomewhereInternal(self._targetHint)), offset, length, GLenum(access)); #endif } #ifndef MAGNUM_TARGET_GLES -void* Buffer::mapRangeImplementationDSA(const GLintptr offset, const GLsizeiptr length, const MapFlags access) { - return glMapNamedBufferRange(_id, offset, length, GLenum(access)); +void* Buffer::mapRangeImplementationDSA(Buffer& self, const GLintptr offset, const GLsizeiptr length, const MapFlags access) { + return glMapNamedBufferRange(self._id, offset, length, GLenum(access)); } #endif -void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length) { +void Buffer::flushMappedRangeImplementationDefault(Buffer& self, GLintptr offset, GLsizeiptr length) { #ifndef MAGNUM_TARGET_GLES2 - glFlushMappedBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length); + glFlushMappedBufferRange(GLenum(self.bindSomewhereInternal(self._targetHint)), offset, length); #else - glFlushMappedBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length); + glFlushMappedBufferRangeEXT(GLenum(self.bindSomewhereInternal(self._targetHint)), offset, length); #endif } #ifndef MAGNUM_TARGET_GLES -void Buffer::flushMappedRangeImplementationDSA(const GLintptr offset, const GLsizeiptr length) { - glFlushMappedNamedBufferRange(_id, offset, length); +void Buffer::flushMappedRangeImplementationDSA(Buffer& self, const GLintptr offset, const GLsizeiptr length) { + glFlushMappedNamedBufferRange(self._id, offset, length); } #endif -bool Buffer::unmapImplementationDefault() { +bool Buffer::unmapImplementationDefault(Buffer& self) { #ifndef MAGNUM_TARGET_GLES2 - return glUnmapBuffer(GLenum(bindSomewhereInternal(_targetHint))); + return glUnmapBuffer(GLenum(self.bindSomewhereInternal(self._targetHint))); #else - return glUnmapBufferOES(GLenum(bindSomewhereInternal(_targetHint))); + return glUnmapBufferOES(GLenum(self.bindSomewhereInternal(self._targetHint))); #endif } #ifndef MAGNUM_TARGET_GLES -bool Buffer::unmapImplementationDSA() { - return glUnmapNamedBuffer(_id); +bool Buffer::unmapImplementationDSA(Buffer& self) { + return glUnmapNamedBuffer(self._id); } #endif #endif @@ -608,29 +608,29 @@ void Buffer::textureWorkaroundAppleBefore() { } } -void Buffer::dataImplementationApple(const GLsizeiptr size, const GLvoid* const data, const BufferUsage usage) { - textureWorkaroundAppleBefore(); - dataImplementationDefault(size, data, usage); +void Buffer::dataImplementationApple(Buffer& self, const GLsizeiptr size, const GLvoid* const data, const BufferUsage usage) { + self.textureWorkaroundAppleBefore(); + dataImplementationDefault(self, size, data, usage); } -void Buffer::subDataImplementationApple(const GLintptr offset, const GLsizeiptr size, const GLvoid* const data) { - textureWorkaroundAppleBefore(); - subDataImplementationDefault(offset, size, data); +void Buffer::subDataImplementationApple(Buffer& self, const GLintptr offset, const GLsizeiptr size, const GLvoid* const data) { + self.textureWorkaroundAppleBefore(); + subDataImplementationDefault(self, offset, size, data); } -void* Buffer::mapImplementationApple(const MapAccess access) { - textureWorkaroundAppleBefore(); - return mapImplementationDefault(access); +void* Buffer::mapImplementationApple(Buffer& self, const MapAccess access) { + self.textureWorkaroundAppleBefore(); + return mapImplementationDefault(self, access); } -void* Buffer::mapRangeImplementationApple(const GLintptr offset, const GLsizeiptr length, const MapFlags access) { - textureWorkaroundAppleBefore(); - return mapRangeImplementationDefault(offset, length, access); +void* Buffer::mapRangeImplementationApple(Buffer& self, const GLintptr offset, const GLsizeiptr length, const MapFlags access) { + self.textureWorkaroundAppleBefore(); + return mapRangeImplementationDefault(self, offset, length, access); } -bool Buffer::unmapImplementationApple() { - textureWorkaroundAppleBefore(); - return unmapImplementationDefault(); +bool Buffer::unmapImplementationApple(Buffer& self) { + self.textureWorkaroundAppleBefore(); + return unmapImplementationDefault(self); } #endif diff --git a/src/Magnum/GL/Buffer.h b/src/Magnum/GL/Buffer.h index 3744bbb91..37c62db0d 100644 --- a/src/Magnum/GL/Buffer.h +++ b/src/Magnum/GL/Buffer.h @@ -1364,33 +1364,33 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject { explicit Buffer(GLuint id, TargetHint targetHint, ObjectFlags flags) noexcept; - void MAGNUM_GL_LOCAL createImplementationDefault(); + static void MAGNUM_GL_LOCAL createImplementationDefault(Buffer& self); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL createImplementationDSA(); + static void MAGNUM_GL_LOCAL createImplementationDSA(Buffer& self); #endif - void MAGNUM_GL_LOCAL setTargetHintImplementationDefault(TargetHint hint); + static void MAGNUM_GL_LOCAL setTargetHintImplementationDefault(Buffer& self, TargetHint hint); #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) - void MAGNUM_GL_LOCAL setTargetHintImplementationSwiftShader(TargetHint hint); + static void MAGNUM_GL_LOCAL setTargetHintImplementationSwiftShader(Buffer& self, TargetHint hint); #endif void MAGNUM_GL_LOCAL createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL storageImplementationDefault(Containers::ArrayView data, StorageFlags flags); - void MAGNUM_GL_LOCAL storageImplementationDSA(Containers::ArrayView data, StorageFlags flags); + static void MAGNUM_GL_LOCAL storageImplementationDefault(Buffer& self, Containers::ArrayView data, StorageFlags flags); + static void MAGNUM_GL_LOCAL storageImplementationDSA(Buffer& self, Containers::ArrayView data, StorageFlags flags); #endif - void MAGNUM_GL_LOCAL getParameterImplementationDefault(GLenum value, GLint* data); + static void MAGNUM_GL_LOCAL getParameterImplementationDefault(Buffer& self, GLenum value, GLint* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL getParameterImplementationDSA(GLenum value, GLint* data); + static void MAGNUM_GL_LOCAL getParameterImplementationDSA(Buffer& self, GLenum value, GLint* data); #endif #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) - void MAGNUM_GL_LOCAL getSubDataImplementationDefault(GLintptr offset, GLsizeiptr size, GLvoid* data); + static void MAGNUM_GL_LOCAL getSubDataImplementationDefault(Buffer& self, GLintptr offset, GLsizeiptr size, GLvoid* data); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL getSubDataImplementationDSA(GLintptr offset, GLsizeiptr size, GLvoid* data); + static void MAGNUM_GL_LOCAL getSubDataImplementationDSA(Buffer& self, GLintptr offset, GLsizeiptr size, GLvoid* data); #endif #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) @@ -1398,66 +1398,66 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject { void MAGNUM_GL_LOCAL textureWorkaroundAppleAfter(); #endif - void MAGNUM_GL_LOCAL dataImplementationDefault(GLsizeiptr size, const GLvoid* data, BufferUsage usage); + static void MAGNUM_GL_LOCAL dataImplementationDefault(Buffer& self, GLsizeiptr size, const GLvoid* data, BufferUsage usage); #if defined(CORRADE_TARGET_APPLE) && !defined(CORRADE_TARGET_IOS) - void MAGNUM_GL_LOCAL dataImplementationApple(GLsizeiptr size, const GLvoid* data, BufferUsage usage); + static void MAGNUM_GL_LOCAL dataImplementationApple(Buffer& self, GLsizeiptr size, const GLvoid* data, BufferUsage usage); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL dataImplementationDSA(GLsizeiptr size, const GLvoid* data, BufferUsage usage); + static void MAGNUM_GL_LOCAL dataImplementationDSA(Buffer& self, GLsizeiptr size, const GLvoid* data, BufferUsage usage); #endif - void MAGNUM_GL_LOCAL subDataImplementationDefault(GLintptr offset, GLsizeiptr size, const GLvoid* data); + static void MAGNUM_GL_LOCAL subDataImplementationDefault(Buffer& self, GLintptr offset, GLsizeiptr size, const GLvoid* data); #if defined(CORRADE_TARGET_APPLE) && !defined(CORRADE_TARGET_IOS) - void MAGNUM_GL_LOCAL subDataImplementationApple(GLintptr offset, GLsizeiptr size, const GLvoid* data); + static void MAGNUM_GL_LOCAL subDataImplementationApple(Buffer& self, GLintptr offset, GLsizeiptr size, const GLvoid* data); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL subDataImplementationDSA(GLintptr offset, GLsizeiptr size, const GLvoid* data); + static void MAGNUM_GL_LOCAL subDataImplementationDSA(Buffer& self, GLintptr offset, GLsizeiptr size, const GLvoid* data); #endif - void MAGNUM_GL_LOCAL invalidateImplementationNoOp(); + static void MAGNUM_GL_LOCAL invalidateImplementationNoOp(Buffer& self); /* No need for Apple-specific invalidateImplementation, as GL_ARB_invalidate_subdata isn't supported */ #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL invalidateImplementationARB(); + static void MAGNUM_GL_LOCAL invalidateImplementationARB(Buffer& self); #endif - void MAGNUM_GL_LOCAL invalidateSubImplementationNoOp(GLintptr offset, GLsizeiptr length); + static void MAGNUM_GL_LOCAL invalidateSubImplementationNoOp(Buffer& self, GLintptr offset, GLsizeiptr length); /* No need for Apple-specific invalidateSubImplementation, as GL_ARB_invalidate_subdata isn't supported */ #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length); + static void MAGNUM_GL_LOCAL invalidateSubImplementationARB(Buffer& self, GLintptr offset, GLsizeiptr length); #endif #ifndef MAGNUM_TARGET_WEBGL - void MAGNUM_GL_LOCAL * mapImplementationDefault(MapAccess access); + static void MAGNUM_GL_LOCAL * mapImplementationDefault(Buffer& self, MapAccess access); #if defined(CORRADE_TARGET_APPLE) && !defined(CORRADE_TARGET_IOS) - void MAGNUM_GL_LOCAL * mapImplementationApple(MapAccess access); + static void MAGNUM_GL_LOCAL * mapImplementationApple(Buffer& self, MapAccess access); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL * mapImplementationDSA(MapAccess access); + static void MAGNUM_GL_LOCAL * mapImplementationDSA(Buffer& self, MapAccess access); #endif - void MAGNUM_GL_LOCAL * mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access); + static void MAGNUM_GL_LOCAL * mapRangeImplementationDefault(Buffer& self, GLintptr offset, GLsizeiptr length, MapFlags access); #if defined(CORRADE_TARGET_APPLE) && !defined(CORRADE_TARGET_IOS) - void MAGNUM_GL_LOCAL * mapRangeImplementationApple(GLintptr offset, GLsizeiptr length, MapFlags access); + static void MAGNUM_GL_LOCAL * mapRangeImplementationApple(Buffer& self, GLintptr offset, GLsizeiptr length, MapFlags access); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL * mapRangeImplementationDSA(GLintptr offset, GLsizeiptr length, MapFlags access); + static void MAGNUM_GL_LOCAL * mapRangeImplementationDSA(Buffer& self, GLintptr offset, GLsizeiptr length, MapFlags access); #endif - void MAGNUM_GL_LOCAL flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length); + static void MAGNUM_GL_LOCAL flushMappedRangeImplementationDefault(Buffer& self, GLintptr offset, GLsizeiptr length); /* No need for Apple-specific flushMappedRangeImplementation, as this doesn't seem to hit the crashy code path */ #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL flushMappedRangeImplementationDSA(GLintptr offset, GLsizeiptr length); + static void MAGNUM_GL_LOCAL flushMappedRangeImplementationDSA(Buffer& self, GLintptr offset, GLsizeiptr length); #endif - bool MAGNUM_GL_LOCAL unmapImplementationDefault(); + static bool MAGNUM_GL_LOCAL unmapImplementationDefault(Buffer& self); #if defined(CORRADE_TARGET_APPLE) && !defined(CORRADE_TARGET_IOS) - bool MAGNUM_GL_LOCAL unmapImplementationApple(); + static bool MAGNUM_GL_LOCAL unmapImplementationApple(Buffer& self); #endif #ifndef MAGNUM_TARGET_GLES - bool MAGNUM_GL_LOCAL unmapImplementationDSA(); + static bool MAGNUM_GL_LOCAL unmapImplementationDSA(Buffer& self); #endif #endif diff --git a/src/Magnum/GL/BufferTexture.cpp b/src/Magnum/GL/BufferTexture.cpp index feeb983c6..a06eeaa79 100644 --- a/src/Magnum/GL/BufferTexture.cpp +++ b/src/Magnum/GL/BufferTexture.cpp @@ -79,62 +79,62 @@ Int BufferTexture::size() { /* Can't use DataHelper<1>::imageSize(*this, 0)[0] because for 1D textures it's not defined on ES */ Int size; - (this->*Context::current().state().texture.getLevelParameterivImplementation)(0, GL_TEXTURE_WIDTH, &size); + Context::current().state().texture.getLevelParameterivImplementation(*this, 0, GL_TEXTURE_WIDTH, &size); return size; } BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer) { buffer.createIfNotAlready(); - (this->*Context::current().state().texture.setBufferImplementation)(internalFormat, &buffer); + Context::current().state().texture.setBufferImplementation(*this, internalFormat, &buffer); return *this; } BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { buffer.createIfNotAlready(); - (this->*Context::current().state().texture.setBufferRangeImplementation)(internalFormat, buffer, offset, size); + Context::current().state().texture.setBufferRangeImplementation(*this, internalFormat, buffer, offset, size); return *this; } -void BufferTexture::setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer) { - bindInternal(); +void BufferTexture::setBufferImplementationDefault(BufferTexture& self, BufferTextureFormat internalFormat, Buffer* buffer) { + self.bindInternal(); glTexBuffer(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer ? buffer->id() : 0); } #ifdef MAGNUM_TARGET_GLES -void BufferTexture::setBufferImplementationEXT(BufferTextureFormat internalFormat, Buffer* buffer) { - bindInternal(); +void BufferTexture::setBufferImplementationEXT(BufferTexture& self, BufferTextureFormat internalFormat, Buffer* buffer) { + self.bindInternal(); glTexBufferEXT(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer ? buffer->id() : 0); } #endif #ifndef MAGNUM_TARGET_GLES -void BufferTexture::setBufferImplementationDSA(const BufferTextureFormat internalFormat, Buffer* buffer) { - glTextureBuffer(id(), GLenum(internalFormat), buffer ? buffer->id() : 0); +void BufferTexture::setBufferImplementationDSA(BufferTexture& self, const BufferTextureFormat internalFormat, Buffer* buffer) { + glTextureBuffer(self.id(), GLenum(internalFormat), buffer ? buffer->id() : 0); } #endif -void BufferTexture::setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size) { - bindInternal(); +void BufferTexture::setBufferRangeImplementationDefault(BufferTexture& self, BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size) { + self.bindInternal(); glTexBufferRange(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id(), offset, size); } #ifdef MAGNUM_TARGET_GLES -void BufferTexture::setBufferRangeImplementationEXT(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size) { - bindInternal(); +void BufferTexture::setBufferRangeImplementationEXT(BufferTexture& self, BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size) { + self.bindInternal(); glTexBufferRangeEXT(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id(), offset, size); } #endif #ifndef MAGNUM_TARGET_GLES -void BufferTexture::setBufferRangeImplementationDSA(const BufferTextureFormat internalFormat, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { - glTextureBufferRange(id(), GLenum(internalFormat), buffer.id(), offset, size); +void BufferTexture::setBufferRangeImplementationDSA(BufferTexture& self, const BufferTextureFormat internalFormat, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { + glTextureBufferRange(self.id(), GLenum(internalFormat), buffer.id(), offset, size); } #endif BufferTexture& BufferTexture::resetBuffer() { /* R8 is the default state according to ARB_texture_buffer_object, so use that */ - (this->*Context::current().state().texture.setBufferImplementation)(BufferTextureFormat::R8, nullptr); + Context::current().state().texture.setBufferImplementation(*this, BufferTextureFormat::R8, nullptr); return *this; } diff --git a/src/Magnum/GL/BufferTexture.h b/src/Magnum/GL/BufferTexture.h index 716e3db68..c050bbf6f 100644 --- a/src/Magnum/GL/BufferTexture.h +++ b/src/Magnum/GL/BufferTexture.h @@ -254,20 +254,20 @@ class MAGNUM_GL_EXPORT BufferTexture: public AbstractTexture { explicit BufferTexture(GLuint id, ObjectFlags flags): AbstractTexture{id, GL_TEXTURE_BUFFER, flags} {} - void MAGNUM_GL_LOCAL setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer); + static void MAGNUM_GL_LOCAL setBufferImplementationDefault(BufferTexture& self, BufferTextureFormat internalFormat, Buffer* buffer); #ifdef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL setBufferImplementationEXT(BufferTextureFormat internalFormat, Buffer* buffer); + static void MAGNUM_GL_LOCAL setBufferImplementationEXT(BufferTexture& self, BufferTextureFormat internalFormat, Buffer* buffer); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer); + static void MAGNUM_GL_LOCAL setBufferImplementationDSA(BufferTexture& self, BufferTextureFormat internalFormat, Buffer* buffer); #endif - void MAGNUM_GL_LOCAL setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); + static void MAGNUM_GL_LOCAL setBufferRangeImplementationDefault(BufferTexture& self, BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); #ifdef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL setBufferRangeImplementationEXT(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); + static void MAGNUM_GL_LOCAL setBufferRangeImplementationEXT(BufferTexture& self, BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); + static void MAGNUM_GL_LOCAL setBufferRangeImplementationDSA(BufferTexture& self, BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); #endif }; diff --git a/src/Magnum/GL/CubeMapTexture.cpp b/src/Magnum/GL/CubeMapTexture.cpp index 23375df5a..938a03eeb 100644 --- a/src/Magnum/GL/CubeMapTexture.cpp +++ b/src/Magnum/GL/CubeMapTexture.cpp @@ -60,8 +60,8 @@ Vector2i CubeMapTexture::imageSize(const Int level) { const Implementation::TextureState& state = Context::current().state().texture; Vector2i value; - (this->*state.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); - (this->*state.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]); + state.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_WIDTH, &value[0]); + state.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_HEIGHT, &value[1]); return value; } #endif @@ -80,7 +80,7 @@ void CubeMapTexture::image(const Int level, Image3D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCubeImage3DImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data, image.storage()); + Context::current().state().texture.getCubeImage3DImplementation(*this, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data, image.storage()); image = Image3D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data), ImageFlag3D::CubeMap}; } @@ -98,7 +98,7 @@ void CubeMapTexture::image(const Int level, const MutableImageView3D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCubeImage3DImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data(), image.storage()); + Context::current().state().texture.getCubeImage3DImplementation(*this, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data(), image.storage()); } void CubeMapTexture::image(const Int level, BufferImage3D& image, const BufferUsage usage) { @@ -115,7 +115,7 @@ void CubeMapTexture::image(const Int level, BufferImage3D& image, const BufferUs image.buffer().bindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCubeImage3DImplementation)(level, size, image.format(), image.type(), dataSize, nullptr, image.storage()); + Context::current().state().texture.getCubeImage3DImplementation(*this, level, size, image.format(), image.type(), dataSize, nullptr, image.storage()); } BufferImage3D CubeMapTexture::image(const Int level, BufferImage3D&& image, const BufferUsage usage) { @@ -137,12 +137,12 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image) nv-cubemap-broken-full-compressed-image-query workaround, where it needs to go slice-by-slice, advancing the offset each time */ dataOffsetSize.first = 0; - dataOffsetSize.second = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level)*6; + dataOffsetSize.second = Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation(*this, level)*6; } else dataOffsetSize = Magnum::Implementation::compressedImageDataOffsetSizeFor(image, size); /* Internal texture format */ GLint format; - (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ Containers::Array data{image.release()}; @@ -151,7 +151,7 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image) Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCompressedCubeImage3DImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, data); + Context::current().state().texture.getCompressedCubeImage3DImplementation(*this, level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, data); image = CompressedImage3D{image.storage(), CompressedPixelFormat(format), size, std::move(data), ImageFlag3D::CubeMap}; } @@ -177,7 +177,7 @@ void CubeMapTexture::compressedImage(const Int level, const MutableCompressedIma nv-cubemap-broken-full-compressed-image-query workaround, where it needs to go slice-by-slice, advancing the offset each time */ dataOffsetSize.first = 0; - dataOffsetSize.second = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level)*6; + dataOffsetSize.second = Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation(*this, level)*6; } else dataOffsetSize = Magnum::Implementation::compressedImageDataOffsetSizeFor(image, size); CORRADE_ASSERT(image.data().size() == dataOffsetSize.first + dataOffsetSize.second, @@ -186,7 +186,7 @@ void CubeMapTexture::compressedImage(const Int level, const MutableCompressedIma #ifndef CORRADE_NO_ASSERT /* Internal texture format */ GLint format; - (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), "GL::CubeMapTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); @@ -194,7 +194,7 @@ void CubeMapTexture::compressedImage(const Int level, const MutableCompressedIma Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCompressedCubeImage3DImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, image.data()); + Context::current().state().texture.getCompressedCubeImage3DImplementation(*this, level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, image.data()); } void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& image, const BufferUsage usage) { @@ -211,12 +211,12 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i nv-cubemap-broken-full-compressed-image-query workaround, where it needs to go slice-by-slice, advancing the offset each time */ dataOffsetSize.first = 0; - dataOffsetSize.second = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level)*6; + dataOffsetSize.second = Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation(*this, level)*6; } else dataOffsetSize = Magnum::Implementation::compressedImageDataOffsetSizeFor(image, size); /* Internal texture format */ GLint format; - (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ if(image.dataSize() < dataOffsetSize.first + dataOffsetSize.second) @@ -226,7 +226,7 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i image.buffer().bindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCompressedCubeImage3DImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, nullptr); + Context::current().state().texture.getCompressedCubeImage3DImplementation(*this, level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, nullptr); } CompressedBufferImage3D CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D&& image, const BufferUsage usage) { @@ -245,7 +245,7 @@ void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCubeImageImplementation)(coordinate, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data); + Context::current().state().texture.getCubeImageImplementation(*this, coordinate, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data); image = Image2D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data), ImageFlags2D{}}; } @@ -263,7 +263,7 @@ void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCubeImageImplementation)(coordinate, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data()); + Context::current().state().texture.getCubeImageImplementation(*this, coordinate, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data()); } void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, BufferImage2D& image, const BufferUsage usage) { @@ -278,7 +278,7 @@ void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, image.buffer().bindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), dataSize, nullptr); + Context::current().state().texture.getCubeImageImplementation(*this, coordinate, level, size, image.format(), image.type(), dataSize, nullptr); } BufferImage2D CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, BufferImage2D&& image, const BufferUsage usage) { @@ -293,7 +293,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I the compression, we need to ask GL for it */ std::size_t dataSize; if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) - dataSize = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level); + dataSize = Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation(*this, level); else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); @@ -301,7 +301,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I already wrapped in compressedPixelFormatWrap() later if the drivers are extra shitty (Intel Windows drivers, I'm talking about you). */ GLint format{}; - (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ Containers::Array data{image.release()}; @@ -310,7 +310,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCompressedCubeImageImplementation)(coordinate, level, size, data.size(), data); + Context::current().state().texture.getCompressedCubeImageImplementation(*this, coordinate, level, size, data.size(), data); image = CompressedImage2D{image.storage(), CompressedPixelFormat(format), size, std::move(data), ImageFlags2D{}}; } @@ -332,7 +332,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I the compression, we need to ask GL for it */ std::size_t dataSize; if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) - dataSize = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level); + dataSize = Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation(*this, level); else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); @@ -343,7 +343,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I already wrapped in compressedPixelFormatWrap() later if the drivers are extra shitty (Intel Windows drivers, I'm talking about you). */ GLint format{}; - (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), "GL::CubeMapTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); @@ -351,7 +351,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCompressedCubeImageImplementation)(coordinate, level, size, image.data().size(), image.data()); + Context::current().state().texture.getCompressedCubeImageImplementation(*this, coordinate, level, size, image.data().size(), image.data()); } void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedBufferImage2D& image, const BufferUsage usage) { @@ -361,7 +361,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I the compression, we need to ask GL for it */ std::size_t dataSize; if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) - dataSize = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level); + dataSize = Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation(*this, level); else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); @@ -369,7 +369,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I already wrapped in compressedPixelFormatWrap() later if the drivers are extra shitty (Intel Windows drivers, I'm talking about you). */ GLint format{}; - (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ if(image.dataSize() < dataSize) @@ -379,7 +379,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I image.buffer().bindInternal(Buffer::TargetHint::PixelPack); Context::current().state().renderer.applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture.getCompressedCubeImageImplementation)(coordinate, level, size, dataSize, nullptr); + Context::current().state().texture.getCompressedCubeImageImplementation(*this, coordinate, level, size, dataSize, nullptr); } CompressedBufferImage2D CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedBufferImage2D&& image, const BufferUsage usage) { @@ -404,7 +404,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, already wrapped in compressedPixelFormatWrap() later if the drivers are extra shitty (Intel Windows drivers, I'm talking about you). */ GLint format{}; - (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Calculate compressed subimage size. If the user-provided pixel storage doesn't tell us all properties about the compression, we need to ask GL @@ -446,7 +446,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, already wrapped in compressedPixelFormatWrap() later if the drivers are extra shitty (Intel Windows drivers, I'm talking about you). */ GLint format{}; - (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), "GL::CubeMapTexture::compressedSubImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); @@ -475,7 +475,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, already wrapped in compressedPixelFormatWrap() later if the drivers are extra shitty (Intel Windows drivers, I'm talking about you). */ GLint format{}; - (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + Context::current().state().texture.getCubeLevelParameterivImplementation(*this, level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Calculate compressed subimage size. If the user-provided pixel storage doesn't tell us all properties about the compression, we need to ask GL @@ -509,7 +509,7 @@ CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& off Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (this->*Context::current().state().texture.cubeSubImage3DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() + Context::current().state().texture.cubeSubImage3DImplementation(*this, level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -523,7 +523,7 @@ CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& off image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (this->*Context::current().state().texture.cubeSubImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage()); + Context::current().state().texture.cubeSubImage3DImplementation(*this, level, offset, image.size(), image.format(), image.type(), nullptr, image.storage()); return *this; } #endif @@ -553,7 +553,7 @@ CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (this->*Context::current().state().texture.cubeSubImageImplementation)(coordinate, level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() + Context::current().state().texture.cubeSubImageImplementation(*this, coordinate, level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -565,7 +565,7 @@ CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, BufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (this->*Context::current().state().texture.cubeSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.type(), nullptr); + Context::current().state().texture.cubeSubImageImplementation(*this, coordinate, level, offset, image.size(), image.format(), image.type(), nullptr); return *this; } #endif @@ -575,7 +575,7 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate co Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (this->*Context::current().state().texture.cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); + Context::current().state().texture.cubeCompressedSubImageImplementation(*this, coordinate, level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); return *this; } @@ -583,29 +583,29 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate co CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, CompressedBufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); - (this->*Context::current().state().texture.cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); + Context::current().state().texture.cubeCompressedSubImageImplementation(*this, coordinate, level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); return *this; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) -void CubeMapTexture::getLevelParameterImplementationDefault(const GLint level, const GLenum parameter, GLint* const values) { - bindInternal(); +void CubeMapTexture::getLevelParameterImplementationDefault(CubeMapTexture& self, const GLint level, const GLenum parameter, GLint* const values) { + self.bindInternal(); /* Using only parameters of +X in pre-DSA code path and assuming that all other faces are the same */ glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, parameter, values); } #ifndef MAGNUM_TARGET_GLES -void CubeMapTexture::getLevelParameterImplementationDSA(const GLint level, const GLenum parameter, GLint* const values) { - glGetTextureLevelParameteriv(_id, level, parameter, values); +void CubeMapTexture::getLevelParameterImplementationDSA(CubeMapTexture& self, const GLint level, const GLenum parameter, GLint* const values) { + glGetTextureLevelParameteriv(self._id, level, parameter, values); } #endif #endif #ifndef MAGNUM_TARGET_GLES -GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDefault(const GLint level) { - bindInternal(); +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDefault(CubeMapTexture& self, const GLint level) { + self.bindInternal(); /* Using only parameters of +X in pre-DSA code path and assuming that all other faces are the same */ GLint value; @@ -614,123 +614,123 @@ GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDefault(const GLi return value; } -GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround(const GLint level) { - const GLint value = getLevelCompressedImageSizeImplementationDefault(level); +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround(CubeMapTexture& self, const GLint level) { + const GLint value = getLevelCompressedImageSizeImplementationDefault(self, level); GLint immutable; glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_LEVELS, &immutable); return immutable ? value/6 : value; } -GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSA(const GLint level) { +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSA(CubeMapTexture& self, const GLint level) { GLint value; - glGetTextureLevelParameteriv(_id, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &value); + glGetTextureLevelParameteriv(self._id, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &value); return value; } -GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround(const GLint level) { - const GLint value = getLevelCompressedImageSizeImplementationDSA(level); +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround(CubeMapTexture& self, const GLint level) { + const GLint value = getLevelCompressedImageSizeImplementationDSA(self, level); GLint immutable; - glGetTextureParameteriv(_id, GL_TEXTURE_IMMUTABLE_LEVELS, &immutable); + glGetTextureParameteriv(self._id, GL_TEXTURE_IMMUTABLE_LEVELS, &immutable); return immutable ? value/6 : value; } #endif #ifndef MAGNUM_TARGET_GLES -void CubeMapTexture::getImageImplementationDSA(const GLint level, const Vector3i&, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data, const PixelStorage&) { - glGetTextureImage(_id, level, GLenum(format), GLenum(type), dataSize, data); +void CubeMapTexture::getImageImplementationDSA(CubeMapTexture& self, const GLint level, const Vector3i&, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data, const PixelStorage&) { + glGetTextureImage(self._id, level, GLenum(format), GLenum(type), dataSize, data); } -void CubeMapTexture::getImageImplementationDSAAmdSliceBySlice(const GLint level, const Vector3i& size, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data, const PixelStorage& storage) { +void CubeMapTexture::getImageImplementationDSAAmdSliceBySlice(CubeMapTexture& self, const GLint level, const Vector3i& size, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data, const PixelStorage& storage) { auto dataProperties = storage.dataProperties(pixelFormatSize(format, type), size); const std::size_t stride = dataProperties.second.xy().product(); for(Int i = 0; i != size.z(); ++i) - glGetTextureSubImage(_id, level, 0, 0, i, size.x(), size.y(), 1, GLenum(format), GLenum(type), stride, static_cast(data) + dataProperties.first.sum() + stride*i); + glGetTextureSubImage(self._id, level, 0, 0, i, size.x(), size.y(), 1, GLenum(format), GLenum(type), stride, static_cast(data) + dataProperties.first.sum() + stride*i); } -void CubeMapTexture::getImageImplementationSliceBySlice(const GLint level, const Vector3i& size, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data, const PixelStorage& storage) { +void CubeMapTexture::getImageImplementationSliceBySlice(CubeMapTexture& self, const GLint level, const Vector3i& size, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data, const PixelStorage& storage) { auto dataProperties = storage.dataProperties(pixelFormatSize(format, type), size); const std::size_t stride = dataProperties.second.xy().product(); for(Int i = 0; i != size.z(); ++i) - getImageImplementationDefault(CubeMapCoordinate(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i), level, size.xy(), format, type, stride, static_cast(data) + stride*i); + getImageImplementationDefault(self, CubeMapCoordinate(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i), level, size.xy(), format, type, stride, static_cast(data) + stride*i); } -void CubeMapTexture::getCompressedImageImplementationDSA(const GLint level, const Vector2i&, const std::size_t dataOffset, const std::size_t dataSize, GLvoid* const data) { - glGetCompressedTextureImage(_id, level, dataOffset + dataSize, data); +void CubeMapTexture::getCompressedImageImplementationDSA(CubeMapTexture& self, const GLint level, const Vector2i&, const std::size_t dataOffset, const std::size_t dataSize, GLvoid* const data) { + glGetCompressedTextureImage(self._id, level, dataOffset + dataSize, data); } -void CubeMapTexture::getCompressedImageImplementationDSASingleSliceWorkaround(const GLint level, const Vector2i& size, const std::size_t dataOffset, const std::size_t dataSize, GLvoid* const data) { +void CubeMapTexture::getCompressedImageImplementationDSASingleSliceWorkaround(CubeMapTexture& self, const GLint level, const Vector2i& size, const std::size_t dataOffset, const std::size_t dataSize, GLvoid* const data) { /* On NVidia (358.16) calling glGetCompressedTextureImage() extracts only the first face */ for(Int face = 0; face != 6; ++face) - glGetCompressedTextureSubImage(_id, level, 0, 0, face, size.x(), size.y(), 1, dataOffset + dataSize/6, static_cast(data) + dataSize*face/6); + glGetCompressedTextureSubImage(self._id, level, 0, 0, face, size.x(), size.y(), 1, dataOffset + dataSize/6, static_cast(data) + dataSize*face/6); } -void CubeMapTexture::getImageImplementationDefault(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) { - bindInternal(); +void CubeMapTexture::getImageImplementationDefault(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) { + self.bindInternal(); glGetTexImage(GLenum(coordinate), level, GLenum(format), GLenum(type), data); } -void CubeMapTexture::getCompressedImageImplementationDefault(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, std::size_t, GLvoid* const data) { - bindInternal(); +void CubeMapTexture::getCompressedImageImplementationDefault(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, std::size_t, GLvoid* const data) { + self.bindInternal(); glGetCompressedTexImage(GLenum(coordinate), level, data); } -void CubeMapTexture::getImageImplementationDSA(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& size, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { - glGetTextureSubImage(_id, level, 0, 0, GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), GLenum(type), dataSize, data); +void CubeMapTexture::getImageImplementationDSA(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i& size, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { + glGetTextureSubImage(self._id, level, 0, 0, GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), GLenum(type), dataSize, data); } -void CubeMapTexture::getCompressedImageImplementationDSA(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& size, const std::size_t dataSize, GLvoid* const data) { - glGetCompressedTextureSubImage(_id, level, 0, 0, GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, dataSize, data); +void CubeMapTexture::getCompressedImageImplementationDSA(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i& size, const std::size_t dataSize, GLvoid* const data) { + glGetCompressedTextureSubImage(self._id, level, 0, 0, GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, dataSize, data); } -void CubeMapTexture::getImageImplementationRobustness(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { - bindInternal(); +void CubeMapTexture::getImageImplementationRobustness(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { + self.bindInternal(); glGetnTexImageARB(GLenum(coordinate), level, GLenum(format), GLenum(type), dataSize, data); } -void CubeMapTexture::getCompressedImageImplementationRobustness(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const std::size_t dataSize, GLvoid* const data) { - bindInternal(); +void CubeMapTexture::getCompressedImageImplementationRobustness(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const std::size_t dataSize, GLvoid* const data) { + self.bindInternal(); glGetnCompressedTexImageARB(GLenum(coordinate), level, dataSize, data); } #endif #ifndef MAGNUM_TARGET_GLES -void CubeMapTexture::subImageImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) { - glTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); +void CubeMapTexture::subImageImplementationDSA(CubeMapTexture& self, const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) { + glTextureSubImage3D(self._id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); } -void CubeMapTexture::subImageImplementationDSASliceBySlice(const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage& storage) { +void CubeMapTexture::subImageImplementationDSASliceBySlice(CubeMapTexture& self, const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage& storage) { const std::size_t stride = std::get<1>(storage.dataProperties(pixelFormatSize(format, type), size)).xy().product(); for(Int i = 0; i != size.z(); ++i) - subImageImplementationDSA(level, {offset.xy(), offset.z() + i}, {size.xy(), 1}, format, type, static_cast(data) + stride*i, storage); + subImageImplementationDSA(self, level, {offset.xy(), offset.z() + i}, {size.xy(), 1}, format, type, static_cast(data) + stride*i, storage); } #endif -void CubeMapTexture::subImageImplementationSliceBySlice(const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage& storage) { +void CubeMapTexture::subImageImplementationSliceBySlice(CubeMapTexture& self, const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage& storage) { const std::size_t stride = std::get<1>(storage.dataProperties(pixelFormatSize(format, type), size)).xy().product(); for(Int i = 0; i != size.z(); ++i) - subImageImplementationDefault(CubeMapCoordinate(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i), level, offset.xy(), size.xy(), format, type, static_cast(data) + stride*i); + subImageImplementationDefault(self, CubeMapCoordinate(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i), level, offset.xy(), size.xy(), format, type, static_cast(data) + stride*i); } -void CubeMapTexture::subImageImplementationDefault(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { - bindInternal(); +void CubeMapTexture::subImageImplementationDefault(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { + self.bindInternal(); glTexSubImage2D(GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data); } -void CubeMapTexture::compressedSubImageImplementationDefault(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { - bindInternal(); +void CubeMapTexture::compressedSubImageImplementationDefault(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { + self.bindInternal(); glCompressedTexSubImage2D(GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data); } #ifndef MAGNUM_TARGET_GLES -void CubeMapTexture::subImageImplementationDSA(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { - glTextureSubImage3D(_id, level, offset.x(), offset.y(), GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), GLenum(type), data); +void CubeMapTexture::subImageImplementationDSA(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { + glTextureSubImage3D(self._id, level, offset.x(), offset.y(), GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), GLenum(type), data); } -void CubeMapTexture::compressedSubImageImplementationDSA(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { - glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), dataSize, data); +void CubeMapTexture::compressedSubImageImplementationDSA(CubeMapTexture& self, const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { + glCompressedTextureSubImage3D(self._id, level, offset.x(), offset.y(), GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), dataSize, data); } #endif diff --git a/src/Magnum/GL/CubeMapTexture.h b/src/Magnum/GL/CubeMapTexture.h index 2b1efe454..c316aab29 100644 --- a/src/Magnum/GL/CubeMapTexture.h +++ b/src/Magnum/GL/CubeMapTexture.h @@ -1289,50 +1289,50 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture { explicit CubeMapTexture(GLuint id, ObjectFlags flags) noexcept: AbstractTexture{id, GL_TEXTURE_CUBE_MAP, flags} {} #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void MAGNUM_GL_LOCAL getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values); + static void MAGNUM_GL_LOCAL getLevelParameterImplementationDefault(CubeMapTexture& self, GLint level, GLenum parameter, GLint* values); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL getLevelParameterImplementationDSA(GLint level, GLenum parameter, GLint* values); + static void MAGNUM_GL_LOCAL getLevelParameterImplementationDSA(CubeMapTexture& self, GLint level, GLenum parameter, GLint* values); #endif #endif #ifndef MAGNUM_TARGET_GLES - GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDefault(GLint level); - GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround(GLint level); - GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDSA(GLint level); - GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround(GLint level); + static GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDefault(CubeMapTexture& self, GLint level); + static GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround(CubeMapTexture& self, GLint level); + static GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDSA(CubeMapTexture& self, GLint level); + static GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround(CubeMapTexture& self, GLint level); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL getImageImplementationDSA(GLint level, const Vector3i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data, const PixelStorage& storage); - void MAGNUM_GL_LOCAL getImageImplementationDSAAmdSliceBySlice(GLint level, const Vector3i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data, const PixelStorage& storage); - void MAGNUM_GL_LOCAL getImageImplementationSliceBySlice(GLint level, const Vector3i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data, const PixelStorage& storage); + static void MAGNUM_GL_LOCAL getImageImplementationDSA(CubeMapTexture& self, GLint level, const Vector3i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data, const PixelStorage& storage); + static void MAGNUM_GL_LOCAL getImageImplementationDSAAmdSliceBySlice(CubeMapTexture& self, GLint level, const Vector3i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data, const PixelStorage& storage); + static void MAGNUM_GL_LOCAL getImageImplementationSliceBySlice(CubeMapTexture& self, GLint level, const Vector3i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data, const PixelStorage& storage); - void MAGNUM_GL_LOCAL getCompressedImageImplementationDSA(GLint level, const Vector2i& size, std::size_t dataOffset, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getCompressedImageImplementationDSASingleSliceWorkaround(GLint level, const Vector2i& size, std::size_t dataOffset, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getCompressedImageImplementationDSA(CubeMapTexture& self, GLint level, const Vector2i& size, std::size_t dataOffset, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getCompressedImageImplementationDSASingleSliceWorkaround(CubeMapTexture& self, GLint level, const Vector2i& size, std::size_t dataOffset, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getImageImplementationDefault(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getImageImplementationDSA(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getImageImplementationRobustness(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getImageImplementationDefault(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getImageImplementationDSA(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getImageImplementationRobustness(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getCompressedImageImplementationDefault(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getCompressedImageImplementationDSA(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); - void MAGNUM_GL_LOCAL getCompressedImageImplementationRobustness(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getCompressedImageImplementationDefault(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getCompressedImageImplementationDSA(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); + static void MAGNUM_GL_LOCAL getCompressedImageImplementationRobustness(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL subImageImplementationDSA(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); - void MAGNUM_GL_LOCAL subImageImplementationDSASliceBySlice(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL subImageImplementationDSA(CubeMapTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL subImageImplementationDSASliceBySlice(CubeMapTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); #endif - void MAGNUM_GL_LOCAL subImageImplementationSliceBySlice(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); + static void MAGNUM_GL_LOCAL subImageImplementationSliceBySlice(CubeMapTexture& self, GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&); - void MAGNUM_GL_LOCAL subImageImplementationDefault(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); + static void MAGNUM_GL_LOCAL subImageImplementationDefault(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL subImageImplementationDSA(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); + static void MAGNUM_GL_LOCAL subImageImplementationDSA(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); #endif - void MAGNUM_GL_LOCAL compressedSubImageImplementationDefault(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + static void MAGNUM_GL_LOCAL compressedSubImageImplementationDefault(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL compressedSubImageImplementationDSA(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + static void MAGNUM_GL_LOCAL compressedSubImageImplementationDSA(CubeMapTexture& self, CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); #endif }; diff --git a/src/Magnum/GL/DefaultFramebuffer.cpp b/src/Magnum/GL/DefaultFramebuffer.cpp index 24f34b361..bcce4f2ae 100644 --- a/src/Magnum/GL/DefaultFramebuffer.cpp +++ b/src/Magnum/GL/DefaultFramebuffer.cpp @@ -40,22 +40,22 @@ namespace Magnum { namespace GL { DefaultFramebuffer defaultFramebuffer; DefaultFramebuffer::Status DefaultFramebuffer::checkStatus(const FramebufferTarget target) { - return Status((this->*Context::current().state().framebuffer.checkStatusImplementation)(target)); + return Status(Context::current().state().framebuffer.checkStatusImplementation(*this, target)); } #ifndef MAGNUM_TARGET_GLES2 DefaultFramebuffer& DefaultFramebuffer::clearColor(const Color4& color) { - (this->*Context::current().state().framebuffer.clearFImplementation)(GL_COLOR, 0, color.data()); + Context::current().state().framebuffer.clearFImplementation(*this, GL_COLOR, 0, color.data()); return *this; } DefaultFramebuffer& DefaultFramebuffer::clearColor(const Vector4i& color) { - (this->*Context::current().state().framebuffer.clearIImplementation)(GL_COLOR, 0, color.data()); + Context::current().state().framebuffer.clearIImplementation(*this, GL_COLOR, 0, color.data()); return *this; } DefaultFramebuffer& DefaultFramebuffer::clearColor(const Vector4ui& color) { - (this->*Context::current().state().framebuffer.clearUIImplementation)(GL_COLOR, 0, color.data()); + Context::current().state().framebuffer.clearUIImplementation(*this, GL_COLOR, 0, color.data()); return *this; } #endif @@ -73,7 +73,7 @@ DefaultFramebuffer& DefaultFramebuffer::mapForDraw(const Containers::ArrayView*Context::current().state().framebuffer.drawBuffersImplementation)(max+1, _attachments); + Context::current().state().framebuffer.drawBuffersImplementation(*this, max+1, _attachments); return *this; } @@ -83,16 +83,16 @@ DefaultFramebuffer& DefaultFramebuffer::mapForDraw(std::initializer_list*Context::current().state().framebuffer.drawBufferImplementation)(GLenum(attachment)); + Context::current().state().framebuffer.drawBufferImplementation(*this, GLenum(attachment)); #else - (this->*Context::current().state().framebuffer.drawBuffersImplementation)(1, reinterpret_cast(&attachment)); + Context::current().state().framebuffer.drawBuffersImplementation(*this, 1, reinterpret_cast(&attachment)); #endif return *this; } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) DefaultFramebuffer& DefaultFramebuffer::mapForRead(const ReadAttachment attachment) { - (this->*Context::current().state().framebuffer.readBufferImplementation)(GLenum(attachment)); + Context::current().state().framebuffer.readBufferImplementation(*this, GLenum(attachment)); return *this; } @@ -102,7 +102,7 @@ void DefaultFramebuffer::invalidate(Containers::ArrayView*Context::current().state().framebuffer.invalidateImplementation)(attachments.size(), _attachments); + Context::current().state().framebuffer.invalidateImplementation(*this, attachments.size(), _attachments); } void DefaultFramebuffer::invalidate(std::initializer_list attachments) { @@ -117,7 +117,7 @@ void DefaultFramebuffer::invalidate(const Containers::ArrayView*Context::current().state().framebuffer.invalidateSubImplementation)(attachments.size(), _attachments, rectangle); + Context::current().state().framebuffer.invalidateSubImplementation(*this, attachments.size(), _attachments, rectangle); } void DefaultFramebuffer::invalidate(std::initializer_list attachments, const Range2Di& rectangle) { diff --git a/src/Magnum/GL/Framebuffer.cpp b/src/Magnum/GL/Framebuffer.cpp index b067ebd37..6b5c7ad20 100644 --- a/src/Magnum/GL/Framebuffer.cpp +++ b/src/Magnum/GL/Framebuffer.cpp @@ -107,18 +107,18 @@ Int Framebuffer::maxColorAttachments() { Framebuffer::Framebuffer(const Range2Di& viewport): AbstractFramebuffer{0, viewport, ObjectFlag::DeleteOnDestruction} { CORRADE_INTERNAL_ASSERT(viewport != Implementation::FramebufferState::DisengagedViewport); - (this->*Context::current().state().framebuffer.createImplementation)(); + Context::current().state().framebuffer.createImplementation(*this); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } -void Framebuffer::createImplementationDefault() { - glGenFramebuffers(1, &_id); +void Framebuffer::createImplementationDefault(Framebuffer& self) { + glGenFramebuffers(1, &self._id); } #ifndef MAGNUM_TARGET_GLES -void Framebuffer::createImplementationDSA() { - glCreateFramebuffers(1, &_id); - _flags |= ObjectFlag::Created; +void Framebuffer::createImplementationDSA(Framebuffer& self) { + glCreateFramebuffers(1, &self._id); + self._flags |= ObjectFlag::Created; } #endif @@ -163,22 +163,22 @@ Framebuffer& Framebuffer::setLabel(const Containers::StringView label) { #endif Framebuffer::Status Framebuffer::checkStatus(const FramebufferTarget target) { - return Status((this->*Context::current().state().framebuffer.checkStatusImplementation)(target)); + return Status(Context::current().state().framebuffer.checkStatusImplementation(*this, target)); } #ifndef MAGNUM_TARGET_GLES2 Framebuffer& Framebuffer::clearColor(const Int attachment, const Color4& color) { - (this->*Context::current().state().framebuffer.clearFImplementation)(GL_COLOR, attachment, color.data()); + Context::current().state().framebuffer.clearFImplementation(*this, GL_COLOR, attachment, color.data()); return *this; } Framebuffer& Framebuffer::clearColor(const Int attachment, const Vector4i& color) { - (this->*Context::current().state().framebuffer.clearIImplementation)(GL_COLOR, attachment, color.data()); + Context::current().state().framebuffer.clearIImplementation(*this, GL_COLOR, attachment, color.data()); return *this; } Framebuffer& Framebuffer::clearColor(const Int attachment, const Vector4ui& color) { - (this->*Context::current().state().framebuffer.clearUIImplementation)(GL_COLOR, attachment, color.data()); + Context::current().state().framebuffer.clearUIImplementation(*this, GL_COLOR, attachment, color.data()); return *this; } #endif @@ -196,7 +196,7 @@ Framebuffer& Framebuffer::mapForDraw(const Containers::ArrayView*Context::current().state().framebuffer.drawBuffersImplementation)(max+1, _attachments); + Context::current().state().framebuffer.drawBuffersImplementation(*this, max+1, _attachments); return *this; } @@ -206,16 +206,16 @@ Framebuffer& Framebuffer::mapForDraw(std::initializer_list*Context::current().state().framebuffer.drawBufferImplementation)(GLenum(attachment)); + Context::current().state().framebuffer.drawBufferImplementation(*this, GLenum(attachment)); #else - (this->*Context::current().state().framebuffer.drawBuffersImplementation)(1, reinterpret_cast(&attachment)); + Context::current().state().framebuffer.drawBuffersImplementation(*this, 1, reinterpret_cast(&attachment)); #endif return *this; } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) Framebuffer& Framebuffer::mapForRead(const ColorAttachment attachment) { - (this->*Context::current().state().framebuffer.readBufferImplementation)(GLenum(attachment)); + Context::current().state().framebuffer.readBufferImplementation(*this, GLenum(attachment)); return *this; } @@ -225,7 +225,7 @@ void Framebuffer::invalidate(const Containers::ArrayView*Context::current().state().framebuffer.invalidateImplementation)(attachments.size(), _attachments); + Context::current().state().framebuffer.invalidateImplementation(*this, attachments.size(), _attachments); } void Framebuffer::invalidate(const std::initializer_list attachments) { @@ -239,7 +239,7 @@ void Framebuffer::invalidate(const Containers::ArrayView*Context::current().state().framebuffer.invalidateSubImplementation)(attachments.size(), _attachments, rectangle); + Context::current().state().framebuffer.invalidateSubImplementation(*this, attachments.size(), _attachments, rectangle); } void Framebuffer::invalidate(const std::initializer_list attachments, const Range2Di& rectangle) { @@ -249,173 +249,173 @@ void Framebuffer::invalidate(const std::initializer_list #endif Framebuffer& Framebuffer::attachRenderbuffer(const BufferAttachment attachment, Renderbuffer& renderbuffer) { - (this->*Context::current().state().framebuffer.renderbufferImplementation)(attachment, renderbuffer.id()); + Context::current().state().framebuffer.renderbufferImplementation(*this, attachment, renderbuffer.id()); return *this; } #ifndef MAGNUM_TARGET_GLES Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture1D& texture, const Int level) { - (this->*Context::current().state().framebuffer.texture1DImplementation)(attachment, texture.id(), level); + Context::current().state().framebuffer.texture1DImplementation(*this, attachment, texture.id(), level); return *this; } #endif Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture2D& texture, const Int level) { - (this->*Context::current().state().framebuffer.texture2DImplementation)(attachment, GL_TEXTURE_2D, texture.id(), level); + Context::current().state().framebuffer.texture2DImplementation(*this, attachment, GL_TEXTURE_2D, texture.id(), level); return *this; } #ifndef MAGNUM_TARGET_GLES Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, RectangleTexture& texture) { - (this->*Context::current().state().framebuffer.texture2DImplementation)(attachment, GL_TEXTURE_RECTANGLE, texture.id(), 0); + Context::current().state().framebuffer.texture2DImplementation(*this, attachment, GL_TEXTURE_RECTANGLE, texture.id(), 0); return *this; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, MultisampleTexture2D& texture) { - (this->*Context::current().state().framebuffer.texture2DImplementation)(attachment, GL_TEXTURE_2D_MULTISAMPLE, texture.id(), 0); + Context::current().state().framebuffer.texture2DImplementation(*this, attachment, GL_TEXTURE_2D_MULTISAMPLE, texture.id(), 0); return *this; } #endif Framebuffer& Framebuffer::attachCubeMapTexture(const BufferAttachment attachment, CubeMapTexture& texture, CubeMapCoordinate coordinate, const Int level) { - (this->*Context::current().state().framebuffer.textureCubeMapImplementation)(attachment, GLenum(coordinate), texture.id(), level); + Context::current().state().framebuffer.textureCubeMapImplementation(*this, attachment, GLenum(coordinate), texture.id(), level); return *this; } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture3D& texture, Int level, Int layer) { - (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), level, layer); + Context::current().state().framebuffer.textureLayerImplementation(*this, attachment, texture.id(), level, layer); return *this; } #endif #ifndef MAGNUM_TARGET_GLES Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture1DArray& texture, Int level, Int layer) { - (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), level, layer); + Context::current().state().framebuffer.textureLayerImplementation(*this, attachment, texture.id(), level, layer); return *this; } #endif #ifndef MAGNUM_TARGET_GLES2 Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture2DArray& texture, Int level, Int layer) { - (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), level, layer); + Context::current().state().framebuffer.textureLayerImplementation(*this, attachment, texture.id(), level, layer); return *this; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, CubeMapTextureArray& texture, Int level, Int layer) { - (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), level, layer); + Context::current().state().framebuffer.textureLayerImplementation(*this, attachment, texture.id(), level, layer); return *this; } Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, MultisampleTexture2DArray& texture, Int layer) { - (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), 0, layer); + Context::current().state().framebuffer.textureLayerImplementation(*this, attachment, texture.id(), 0, layer); return *this; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture3D& texture, const Int level) { - (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), level); + Context::current().state().framebuffer.textureImplementation(*this, attachment, texture.id(), level); return *this; } #ifndef MAGNUM_TARGET_GLES Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture1DArray& texture, const Int level) { - (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), level); + Context::current().state().framebuffer.textureImplementation(*this, attachment, texture.id(), level); return *this; } #endif Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture2DArray& texture, const Int level) { - (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), level); + Context::current().state().framebuffer.textureImplementation(*this, attachment, texture.id(), level); return *this; } Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, CubeMapTexture& texture, const Int level) { - (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), level); + Context::current().state().framebuffer.textureImplementation(*this, attachment, texture.id(), level); return *this; } Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, CubeMapTextureArray& texture, const Int level) { - (this->*Context::current().state().framebuffer.layeredTextureCubeMapArrayImplementation)(attachment, texture.id(), level); + Context::current().state().framebuffer.layeredTextureCubeMapArrayImplementation(*this, attachment, texture.id(), level); return *this; } Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, MultisampleTexture2DArray& texture) { - (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), 0); + Context::current().state().framebuffer.textureImplementation(*this, attachment, texture.id(), 0); return *this; } #endif Framebuffer& Framebuffer::detach(const BufferAttachment attachment) { - (this->*Context::current().state().framebuffer.renderbufferImplementation)(attachment, 0); + Context::current().state().framebuffer.renderbufferImplementation(*this, attachment, 0); return *this; } -void Framebuffer::renderbufferImplementationDefault(const BufferAttachment attachment, const GLuint renderbufferId) { - glFramebufferRenderbuffer(GLenum(bindInternal()), GLenum(attachment), GL_RENDERBUFFER, renderbufferId); +void Framebuffer::renderbufferImplementationDefault(Framebuffer& self, const BufferAttachment attachment, const GLuint renderbufferId) { + glFramebufferRenderbuffer(GLenum(self.bindInternal()), GLenum(attachment), GL_RENDERBUFFER, renderbufferId); } #ifndef MAGNUM_TARGET_GLES -void Framebuffer::renderbufferImplementationDSA(const BufferAttachment attachment, const GLuint renderbufferId) { - glNamedFramebufferRenderbuffer(_id, GLenum(attachment), GL_RENDERBUFFER, renderbufferId); +void Framebuffer::renderbufferImplementationDSA(Framebuffer& self, const BufferAttachment attachment, const GLuint renderbufferId) { + glNamedFramebufferRenderbuffer(self._id, GLenum(attachment), GL_RENDERBUFFER, renderbufferId); } -void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint mipLevel) { - glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), GL_TEXTURE_1D, textureId, mipLevel); +void Framebuffer::texture1DImplementationDefault(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint mipLevel) { + glFramebufferTexture1D(GLenum(self.bindInternal()), GLenum(attachment), GL_TEXTURE_1D, textureId, mipLevel); } #endif -void Framebuffer::texture2DImplementationDefault(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint mipLevel) { - glFramebufferTexture2D(GLenum(bindInternal()), GLenum(attachment), textureTarget, textureId, mipLevel); +void Framebuffer::texture2DImplementationDefault(Framebuffer& self, BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint mipLevel) { + glFramebufferTexture2D(GLenum(self.bindInternal()), GLenum(attachment), textureTarget, textureId, mipLevel); } #ifndef MAGNUM_TARGET_GLES -void Framebuffer::texture2DImplementationDSA(const BufferAttachment attachment, GLenum, const GLuint textureId, const GLint mipLevel) { - glNamedFramebufferTexture(_id, GLenum(attachment), textureId, mipLevel); +void Framebuffer::texture2DImplementationDSA(Framebuffer& self, const BufferAttachment attachment, GLenum, const GLuint textureId, const GLint mipLevel) { + glNamedFramebufferTexture(self._id, GLenum(attachment), textureId, mipLevel); } -void Framebuffer::textureCubeMapImplementationDSA(const BufferAttachment attachment, const GLenum textureTarget, const GLuint textureId, const GLint mipLevel) { - glNamedFramebufferTextureLayer(_id, GLenum(attachment), textureId, mipLevel, textureTarget - GL_TEXTURE_CUBE_MAP_POSITIVE_X); +void Framebuffer::textureCubeMapImplementationDSA(Framebuffer& self, const BufferAttachment attachment, const GLenum textureTarget, const GLuint textureId, const GLint mipLevel) { + glNamedFramebufferTextureLayer(self._id, GLenum(attachment), textureId, mipLevel, textureTarget - GL_TEXTURE_CUBE_MAP_POSITIVE_X); } #endif #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) -void Framebuffer::textureImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint mipLevel) { - glFramebufferTexture(GLenum(bindInternal()), GLenum(attachment), textureId, mipLevel); +void Framebuffer::textureImplementationDefault(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint mipLevel) { + glFramebufferTexture(GLenum(self.bindInternal()), GLenum(attachment), textureId, mipLevel); } #ifdef MAGNUM_TARGET_GLES -void Framebuffer::textureImplementationEXT(BufferAttachment attachment, GLuint textureId, GLint mipLevel) { - glFramebufferTextureEXT(GLenum(bindInternal()), GLenum(attachment), textureId, mipLevel); +void Framebuffer::textureImplementationEXT(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint mipLevel) { + glFramebufferTextureEXT(GLenum(self.bindInternal()), GLenum(attachment), textureId, mipLevel); } #endif #endif #ifndef MAGNUM_TARGET_GLES -void Framebuffer::textureImplementationDSA(const BufferAttachment attachment, const GLuint textureId, const GLint mipLevel) { - glNamedFramebufferTexture(_id, GLenum(attachment), textureId, mipLevel); +void Framebuffer::textureImplementationDSA(Framebuffer& self, const BufferAttachment attachment, const GLuint textureId, const GLint mipLevel) { + glNamedFramebufferTexture(self._id, GLenum(attachment), textureId, mipLevel); } #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) -void Framebuffer::textureLayerImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint mipLevel, GLint layer) { +void Framebuffer::textureLayerImplementationDefault(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint mipLevel, GLint layer) { #ifndef MAGNUM_TARGET_GLES2 - glFramebufferTextureLayer(GLenum(bindInternal()), GLenum(attachment), textureId, mipLevel, layer); + glFramebufferTextureLayer(GLenum(self.bindInternal()), GLenum(attachment), textureId, mipLevel, layer); #else - glFramebufferTexture3DOES(GLenum(bindInternal()), GLenum(attachment), GL_TEXTURE_3D_OES, textureId, mipLevel, layer); + glFramebufferTexture3DOES(GLenum(self.bindInternal()), GLenum(attachment), GL_TEXTURE_3D_OES, textureId, mipLevel, layer); #endif } #endif #ifndef MAGNUM_TARGET_GLES -void Framebuffer::textureLayerImplementationDSA(const BufferAttachment attachment, const GLuint textureId, const GLint mipLevel, const GLint layer) { - glNamedFramebufferTextureLayer(_id, GLenum(attachment), textureId, mipLevel, layer); +void Framebuffer::textureLayerImplementationDSA(Framebuffer& self, const BufferAttachment attachment, const GLuint textureId, const GLint mipLevel, const GLint layer) { + glNamedFramebufferTextureLayer(self._id, GLenum(attachment), textureId, mipLevel, layer); } #endif diff --git a/src/Magnum/GL/Framebuffer.h b/src/Magnum/GL/Framebuffer.h index 3b926e9d4..d437e9e09 100644 --- a/src/Magnum/GL/Framebuffer.h +++ b/src/Magnum/GL/Framebuffer.h @@ -933,41 +933,41 @@ class MAGNUM_GL_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractO private: explicit Framebuffer(GLuint id, const Range2Di& viewport, ObjectFlags flags) noexcept: AbstractFramebuffer{id, viewport, flags} {} - void MAGNUM_GL_LOCAL createImplementationDefault(); + static void MAGNUM_GL_LOCAL createImplementationDefault(Framebuffer& self); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL createImplementationDSA(); + static void MAGNUM_GL_LOCAL createImplementationDSA(Framebuffer& self); #endif - void MAGNUM_GL_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, GLuint renderbufferId); + static void MAGNUM_GL_LOCAL renderbufferImplementationDefault(Framebuffer& self, BufferAttachment attachment, GLuint renderbufferId); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, GLuint renderbufferId); + static void MAGNUM_GL_LOCAL renderbufferImplementationDSA(Framebuffer& self, BufferAttachment attachment, GLuint renderbufferId); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL texture1DImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint level); + static void MAGNUM_GL_LOCAL texture1DImplementationDefault(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint level); #endif - void MAGNUM_GL_LOCAL texture2DImplementationDefault(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); + static void MAGNUM_GL_LOCAL texture2DImplementationDefault(Framebuffer& self, BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL texture2DImplementationDSA(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); - void MAGNUM_GL_LOCAL textureCubeMapImplementationDSA(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); + static void MAGNUM_GL_LOCAL texture2DImplementationDSA(Framebuffer& self, BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); + static void MAGNUM_GL_LOCAL textureCubeMapImplementationDSA(Framebuffer& self, BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); #endif #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) - void MAGNUM_GL_LOCAL textureImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint level); + static void MAGNUM_GL_LOCAL textureImplementationDefault(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint level); #ifdef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL textureImplementationEXT(BufferAttachment attachment, GLuint textureId, GLint level); + static void MAGNUM_GL_LOCAL textureImplementationEXT(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint level); #endif #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL textureImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint level); + static void MAGNUM_GL_LOCAL textureImplementationDSA(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint level); #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void MAGNUM_GL_LOCAL textureLayerImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint level, GLint layer); + static void MAGNUM_GL_LOCAL textureLayerImplementationDefault(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint level, GLint layer); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL textureLayerImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint level, GLint layer); + static void MAGNUM_GL_LOCAL textureLayerImplementationDSA(Framebuffer& self, BufferAttachment attachment, GLuint textureId, GLint level, GLint layer); #endif }; diff --git a/src/Magnum/GL/Implementation/BufferState.h b/src/Magnum/GL/Implementation/BufferState.h index 422d852ac..5fa162e3a 100644 --- a/src/Magnum/GL/Implementation/BufferState.h +++ b/src/Magnum/GL/Implementation/BufferState.h @@ -64,24 +64,24 @@ struct BufferState { void(*bindRangesImplementation)(Buffer::Target, UnsignedInt, Containers::ArrayView>); void(*copyImplementation)(Buffer&, Buffer&, GLintptr, GLintptr, GLsizeiptr); #endif - void(Buffer::*createImplementation)(); - void(Buffer::*setTargetHintImplementation)(Buffer::TargetHint); + void(*createImplementation)(Buffer&); + void(*setTargetHintImplementation)(Buffer&, Buffer::TargetHint); #ifndef MAGNUM_TARGET_GLES - void(Buffer::*storageImplementation)(Containers::ArrayView, Buffer::StorageFlags); + void(*storageImplementation)(Buffer&, Containers::ArrayView, Buffer::StorageFlags); #endif - void(Buffer::*getParameterImplementation)(GLenum, GLint*); + void(*getParameterImplementation)(Buffer&, GLenum, GLint*); #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) - void(Buffer::*getSubDataImplementation)(GLintptr, GLsizeiptr, GLvoid*); + void(*getSubDataImplementation)(Buffer&, GLintptr, GLsizeiptr, GLvoid*); #endif - void(Buffer::*dataImplementation)(GLsizeiptr, const GLvoid*, BufferUsage); - void(Buffer::*subDataImplementation)(GLintptr, GLsizeiptr, const GLvoid*); - void(Buffer::*invalidateImplementation)(); - void(Buffer::*invalidateSubImplementation)(GLintptr, GLsizeiptr); + void(*dataImplementation)(Buffer&, GLsizeiptr, const GLvoid*, BufferUsage); + void(*subDataImplementation)(Buffer&, GLintptr, GLsizeiptr, const GLvoid*); + void(*invalidateImplementation)(Buffer&); + void(*invalidateSubImplementation)(Buffer&, GLintptr, GLsizeiptr); #ifndef MAGNUM_TARGET_WEBGL - void*(Buffer::*mapImplementation)(Buffer::MapAccess); - void*(Buffer::*mapRangeImplementation)(GLintptr, GLsizeiptr, Buffer::MapFlags); - void(Buffer::*flushMappedRangeImplementation)(GLintptr, GLsizeiptr); - bool(Buffer::*unmapImplementation)(); + void*(*mapImplementation)(Buffer&, Buffer::MapAccess); + void*(*mapRangeImplementation)(Buffer&, GLintptr, GLsizeiptr, Buffer::MapFlags); + void(*flushMappedRangeImplementation)(Buffer&, GLintptr, GLsizeiptr); + bool(*unmapImplementation)(Buffer&); #endif /* Currently bound buffer for all targets */ diff --git a/src/Magnum/GL/Implementation/FramebufferState.h b/src/Magnum/GL/Implementation/FramebufferState.h index c2307d257..c7f1ce701 100644 --- a/src/Magnum/GL/Implementation/FramebufferState.h +++ b/src/Magnum/GL/Implementation/FramebufferState.h @@ -27,13 +27,6 @@ #include "Magnum/GL/Framebuffer.h" -#ifdef CORRADE_TARGET_MSVC -/* Otherwise the member function pointers will have different size based on - whether the header was included or not. CAUSES SERIOUS MEMORY CORRUPTION AND - IS NOT CAUGHT BY ANY WARNING WHATSOEVER! AARGH! */ -#include "Magnum/GL/Renderbuffer.h" -#endif - namespace Magnum { namespace GL { namespace Implementation { struct FramebufferState { @@ -46,21 +39,21 @@ struct FramebufferState { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void(*blitImplementation)(AbstractFramebuffer&, AbstractFramebuffer&, const Range2Di&, const Range2Di&, FramebufferBlitMask, FramebufferBlitFilter); #endif - GLenum(AbstractFramebuffer::*checkStatusImplementation)(FramebufferTarget); + GLenum(*checkStatusImplementation)(AbstractFramebuffer&, FramebufferTarget); #ifndef MAGNUM_TARGET_GLES2 - void(AbstractFramebuffer::*clearIImplementation)(GLenum, GLint, const GLint*); - void(AbstractFramebuffer::*clearUIImplementation)(GLenum, GLint, const GLuint*); - void(AbstractFramebuffer::*clearFImplementation)(GLenum, GLint, const GLfloat*); - void(AbstractFramebuffer::*clearFIImplementation)(GLenum, GLfloat, GLint); + void(*clearIImplementation)(AbstractFramebuffer&, GLenum, GLint, const GLint*); + void(*clearUIImplementation)(AbstractFramebuffer&, GLenum, GLint, const GLuint*); + void(*clearFImplementation)(AbstractFramebuffer&, GLenum, GLint, const GLfloat*); + void(*clearFIImplementation)(AbstractFramebuffer&, GLenum, GLfloat, GLint); #endif - void(AbstractFramebuffer::*drawBuffersImplementation)(GLsizei, const GLenum*); + void(*drawBuffersImplementation)(AbstractFramebuffer&, GLsizei, const GLenum*); #ifndef MAGNUM_TARGET_GLES - void(AbstractFramebuffer::*drawBufferImplementation)(GLenum); + void(*drawBufferImplementation)(AbstractFramebuffer&, GLenum); #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void(AbstractFramebuffer::*readBufferImplementation)(GLenum); + void(*readBufferImplementation)(AbstractFramebuffer&, GLenum); #endif #ifndef MAGNUM_TARGET_GLES void(*copySub1DImplementation)(const Range2Di&, AbstractTexture&, Int, Int); @@ -71,37 +64,37 @@ struct FramebufferState { void(*copySub3DImplementation)(const Range2Di&, AbstractTexture&, Int, const Vector3i&); #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void(AbstractFramebuffer::*invalidateImplementation)(GLsizei, const GLenum*); + void(*invalidateImplementation)(AbstractFramebuffer&, GLsizei, const GLenum*); #endif #ifndef MAGNUM_TARGET_GLES2 - void(AbstractFramebuffer::*invalidateSubImplementation)(GLsizei, const GLenum*, const Range2Di&); + void(*invalidateSubImplementation)(AbstractFramebuffer&, GLsizei, const GLenum*, const Range2Di&); #endif #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void(AbstractFramebuffer::*bindImplementation)(FramebufferTarget); - FramebufferTarget(AbstractFramebuffer::*bindInternalImplementation)(); + void(*bindImplementation)(AbstractFramebuffer&, FramebufferTarget); + FramebufferTarget(*bindInternalImplementation)(AbstractFramebuffer&); #endif - GLenum(AbstractFramebuffer::*implementationColorReadFormatTypeImplementation)(GLenum what); + GLenum(*implementationColorReadFormatTypeImplementation)(AbstractFramebuffer&, GLenum what); - void(Framebuffer::*createImplementation)(); - void(Framebuffer::*renderbufferImplementation)(Framebuffer::BufferAttachment, GLuint); + void(*createImplementation)(Framebuffer&); + void(*renderbufferImplementation)(Framebuffer&, Framebuffer::BufferAttachment, GLuint); #ifndef MAGNUM_TARGET_GLES - void(Framebuffer::*texture1DImplementation)(Framebuffer::BufferAttachment, GLuint, GLint); + void(*texture1DImplementation)(Framebuffer&, Framebuffer::BufferAttachment, GLuint, GLint); #endif - void(Framebuffer::*texture2DImplementation)(Framebuffer::BufferAttachment, GLenum, GLuint, GLint); - void(Framebuffer::*textureCubeMapImplementation)(Framebuffer::BufferAttachment, GLenum, GLuint, GLint); + void(*texture2DImplementation)(Framebuffer&, Framebuffer::BufferAttachment, GLenum, GLuint, GLint); + void(*textureCubeMapImplementation)(Framebuffer&, Framebuffer::BufferAttachment, GLenum, GLuint, GLint); #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) - void(Framebuffer::*textureImplementation)(Framebuffer::BufferAttachment, GLuint, GLint); - void(Framebuffer::*layeredTextureCubeMapArrayImplementation)(Framebuffer::BufferAttachment, GLuint, GLint); + void(*textureImplementation)(Framebuffer&, Framebuffer::BufferAttachment, GLuint, GLint); + void(*layeredTextureCubeMapArrayImplementation)(Framebuffer&, Framebuffer::BufferAttachment, GLuint, GLint); #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void(Framebuffer::*textureLayerImplementation)(Framebuffer::BufferAttachment, GLuint, GLint, GLint); + void(*textureLayerImplementation)(Framebuffer&, Framebuffer::BufferAttachment, GLuint, GLint, GLint); #endif - void(Renderbuffer::*createRenderbufferImplementation)(); - void(Renderbuffer::*renderbufferStorageImplementation)(RenderbufferFormat, const Vector2i&); + void(*createRenderbufferImplementation)(Renderbuffer&); + void(*renderbufferStorageImplementation)(Renderbuffer&, RenderbufferFormat, const Vector2i&); #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void(Renderbuffer::*renderbufferStorageMultisampleImplementation)(GLsizei, RenderbufferFormat, const Vector2i&); + void(*renderbufferStorageMultisampleImplementation)(Renderbuffer&, GLsizei, RenderbufferFormat, const Vector2i&); #endif void(*readImplementation)(const Range2Di&, PixelFormat, PixelType, std::size_t, GLvoid*); diff --git a/src/Magnum/GL/Implementation/MeshState.h b/src/Magnum/GL/Implementation/MeshState.h index 7b48fffb7..3da5fc8d0 100644 --- a/src/Magnum/GL/Implementation/MeshState.h +++ b/src/Magnum/GL/Implementation/MeshState.h @@ -39,18 +39,18 @@ struct MeshState { void reset(); - void(Mesh::*createImplementation)(bool); - void(Mesh::*moveConstructImplementation)(Mesh&&); - void(Mesh::*moveAssignImplementation)(Mesh&&); - void(Mesh::*destroyImplementation)(bool); - void(Mesh::*attributePointerImplementation)(Mesh::AttributeLayout&&); + void(*createImplementation)(Mesh&, bool); + void(*moveConstructImplementation)(Mesh&, Mesh&&); + void(*moveAssignImplementation)(Mesh&, Mesh&&); + void(*destroyImplementation)(Mesh&, bool); + void(*attributePointerImplementation)(Mesh&, Mesh::AttributeLayout&&); #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) - void(Mesh::*vertexAttribDivisorImplementation)(GLuint, GLuint); + void(*vertexAttribDivisorImplementation)(Mesh&, GLuint, GLuint); #endif - void(Mesh::*acquireVertexBufferImplementation)(Buffer&&); - void(Mesh::*bindIndexBufferImplementation)(Buffer&); - void(Mesh::*bindImplementation)(); - void(Mesh::*unbindImplementation)(); + void(*acquireVertexBufferImplementation)(Mesh&, Buffer&&); + void(*bindIndexBufferImplementation)(Mesh&, Buffer&); + void(*bindImplementation)(Mesh&); + void(*unbindImplementation)(Mesh&); #ifdef MAGNUM_TARGET_GLES #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) diff --git a/src/Magnum/GL/Implementation/QueryState.h b/src/Magnum/GL/Implementation/QueryState.h index b5aafe168..cb11f1291 100644 --- a/src/Magnum/GL/Implementation/QueryState.h +++ b/src/Magnum/GL/Implementation/QueryState.h @@ -28,13 +28,6 @@ #include "Magnum/Magnum.h" #include "Magnum/GL/GL.h" -#ifdef CORRADE_TARGET_MSVC -/* Otherwise the member function pointers will have different size based on - whether the header was included or not. CAUSES SERIOUS MEMORY CORRUPTION AND - IS NOT CAUGHT BY ANY WARNING WHATSOEVER! AARGH! */ -#include "Magnum/GL/AbstractQuery.h" -#endif - namespace Magnum { namespace GL { namespace Implementation { struct QueryState { @@ -42,7 +35,7 @@ struct QueryState { void reset(); - void(AbstractQuery::*createImplementation)(); + void(*createImplementation)(AbstractQuery&); }; }}} diff --git a/src/Magnum/GL/Implementation/ShaderProgramState.h b/src/Magnum/GL/Implementation/ShaderProgramState.h index 613d2af6b..3f38f02a1 100644 --- a/src/Magnum/GL/Implementation/ShaderProgramState.h +++ b/src/Magnum/GL/Implementation/ShaderProgramState.h @@ -44,7 +44,7 @@ struct ShaderProgramState { void reset(); #ifndef MAGNUM_TARGET_GLES2 - void(AbstractShaderProgram::*transformFeedbackVaryingsImplementation)(const Containers::StringIterable&, AbstractShaderProgram::TransformFeedbackBufferMode); + void(*transformFeedbackVaryingsImplementation)(AbstractShaderProgram&, const Containers::StringIterable&, AbstractShaderProgram::TransformFeedbackBufferMode); #endif void(*cleanLogImplementation)(Containers::String&); /* This is a direct pointer to a GL function, so needs a __stdcall on diff --git a/src/Magnum/GL/Implementation/ShaderState.h b/src/Magnum/GL/Implementation/ShaderState.h index df0a72a58..da08b5982 100644 --- a/src/Magnum/GL/Implementation/ShaderState.h +++ b/src/Magnum/GL/Implementation/ShaderState.h @@ -30,13 +30,6 @@ #include "Magnum/GL/GL.h" #include "Magnum/GL/OpenGL.h" -#ifdef CORRADE_TARGET_MSVC -/* Otherwise the member function pointers will have different size based on - whether the header was included or not. CAUSES SERIOUS MEMORY CORRUPTION AND - IS NOT CAUGHT BY ANY WARNING WHATSOEVER! AARGH! */ -#include "Magnum/GL/Shader.h" -#endif - namespace Magnum { namespace GL { namespace Implementation { struct ShaderState { @@ -50,7 +43,7 @@ struct ShaderState { #endif }; - void(Shader::*addSourceImplementation)(Containers::String&&); + void(*addSourceImplementation)(Shader&, Containers::String&&); void(*cleanLogImplementation)(Containers::String&); /* This is a direct pointer to a GL function, so needs a __stdcall on Windows to compile properly on 32 bits */ diff --git a/src/Magnum/GL/Implementation/TextureState.h b/src/Magnum/GL/Implementation/TextureState.h index 5b31d1909..e9ac573ac 100644 --- a/src/Magnum/GL/Implementation/TextureState.h +++ b/src/Magnum/GL/Implementation/TextureState.h @@ -32,18 +32,6 @@ #include "Magnum/GL/GL.h" #include "Magnum/GL/OpenGL.h" -#ifdef CORRADE_TARGET_MSVC -#include "Magnum/GL/AbstractTexture.h" - -#ifndef MAGNUM_TARGET_GLES2 -/* Otherwise the member function pointers will have different size based on - whether the header was included or not. CAUSES SERIOUS MEMORY CORRUPTION AND - IS NOT CAUGHT BY ANY WARNING WHATSOEVER! AARGH! */ -#include "Magnum/GL/BufferTexture.h" -#include "Magnum/GL/CubeMapTexture.h" -#endif -#endif - #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #include "Magnum/Math/BitVector.h" #endif @@ -85,72 +73,72 @@ struct TextureState { Int(*compressedBlockDataSizeImplementation)(GLenum, TextureFormat); void(*unbindImplementation)(GLint); void(*bindMultiImplementation)(GLint, Containers::ArrayView); - void(AbstractTexture::*createImplementation)(); - void(AbstractTexture::*bindImplementation)(GLint); - void(AbstractTexture::*bindInternalImplementation)(GLint); - void(AbstractTexture::*parameteriImplementation)(GLenum, GLint); - void(AbstractTexture::*parameterfImplementation)(GLenum, GLfloat); + void(*createImplementation)(AbstractTexture&); + void(*bindImplementation)(AbstractTexture&, GLint); + void(*bindInternalImplementation)(AbstractTexture&, GLint); + void(*parameteriImplementation)(AbstractTexture&, GLenum, GLint); + void(*parameterfImplementation)(AbstractTexture&, GLenum, GLfloat); #ifndef MAGNUM_TARGET_GLES2 - void(AbstractTexture::*parameterivImplementation)(GLenum, const GLint*); + void(*parameterivImplementation)(AbstractTexture&, GLenum, const GLint*); #endif - void(AbstractTexture::*parameterfvImplementation)(GLenum, const GLfloat*); + void(*parameterfvImplementation)(AbstractTexture&, GLenum, const GLfloat*); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void(AbstractTexture::*parameterIuivImplementation)(GLenum, const GLuint*); - void(AbstractTexture::*parameterIivImplementation)(GLenum, const GLint*); + void(*parameterIuivImplementation)(AbstractTexture&, GLenum, const GLuint*); + void(*parameterIivImplementation)(AbstractTexture&, GLenum, const GLint*); #endif - void(AbstractTexture::*setMaxAnisotropyImplementation)(GLfloat); + void(*setMaxAnisotropyImplementation)(AbstractTexture&, GLfloat); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void(AbstractTexture::*getLevelParameterivImplementation)(GLint, GLenum, GLint*); + void(*getLevelParameterivImplementation)(AbstractTexture&, GLint, GLenum, GLint*); #endif - void(AbstractTexture::*mipmapImplementation)(); + void(*mipmapImplementation)(AbstractTexture&); #ifndef MAGNUM_TARGET_GLES - void(AbstractTexture::*storage1DImplementation)(GLsizei, TextureFormat, const Math::Vector<1, GLsizei>&); + void(*storage1DImplementation)(AbstractTexture&, GLsizei, TextureFormat, const Math::Vector<1, GLsizei>&); #endif - void(AbstractTexture::*storage2DImplementation)(GLsizei, TextureFormat, const Vector2i&); + void(*storage2DImplementation)(AbstractTexture&, GLsizei, TextureFormat, const Vector2i&); #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void(AbstractTexture::*storage3DImplementation)(GLsizei, TextureFormat, const Vector3i&); + void(*storage3DImplementation)(AbstractTexture&, GLsizei, TextureFormat, const Vector3i&); #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void(AbstractTexture::*storage2DMultisampleImplementation)(GLsizei, TextureFormat, const Vector2i&, GLboolean); - void(AbstractTexture::*storage3DMultisampleImplementation)(GLsizei, TextureFormat, const Vector3i&, GLboolean); + void(*storage2DMultisampleImplementation)(AbstractTexture&, GLsizei, TextureFormat, const Vector2i&, GLboolean); + void(*storage3DMultisampleImplementation)(AbstractTexture&, GLsizei, TextureFormat, const Vector3i&, GLboolean); #endif #ifndef MAGNUM_TARGET_GLES - void(AbstractTexture::*getImageImplementation)(GLint, PixelFormat, PixelType, std::size_t, GLvoid*); - void(AbstractTexture::*getCompressedImageImplementation)(GLint, std::size_t, GLvoid*); + void(*getImageImplementation)(AbstractTexture&, GLint, PixelFormat, PixelType, std::size_t, GLvoid*); + void(*getCompressedImageImplementation)(AbstractTexture&, GLint, std::size_t, GLvoid*); #endif #ifndef MAGNUM_TARGET_GLES - void(AbstractTexture::*subImage1DImplementation)(GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, PixelFormat, PixelType, const GLvoid*); - void(AbstractTexture::*compressedSubImage1DImplementation)(GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, CompressedPixelFormat, const GLvoid*, GLsizei); + void(*subImage1DImplementation)(AbstractTexture&, GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, PixelFormat, PixelType, const GLvoid*); + void(*compressedSubImage1DImplementation)(AbstractTexture&, GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, CompressedPixelFormat, const GLvoid*, GLsizei); #endif - void (AbstractTexture::*image2DImplementation)(GLenum, GLint, TextureFormat, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); - void(AbstractTexture::*subImage2DImplementation)(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); - void(AbstractTexture::*compressedSubImage2DImplementation)(GLint, const Vector2i&, const Vector2i&, CompressedPixelFormat, const GLvoid*, GLsizei); + void(*image2DImplementation)(AbstractTexture&, GLenum, GLint, TextureFormat, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); + void(*subImage2DImplementation)(AbstractTexture&, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); + void(*compressedSubImage2DImplementation)(AbstractTexture&, GLint, const Vector2i&, const Vector2i&, CompressedPixelFormat, const GLvoid*, GLsizei); #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) - void (AbstractTexture::*image3DImplementation)(GLint, TextureFormat, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); - void(AbstractTexture::*subImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); - void(AbstractTexture::*compressedSubImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, CompressedPixelFormat, const GLvoid*, GLsizei); + void(*image3DImplementation)(AbstractTexture&, GLint, TextureFormat, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); + void(*subImage3DImplementation)(AbstractTexture&, GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); + void(*compressedSubImage3DImplementation)(AbstractTexture&, GLint, const Vector3i&, const Vector3i&, CompressedPixelFormat, const GLvoid*, GLsizei); #endif - void(AbstractTexture::*invalidateImageImplementation)(GLint); - void(AbstractTexture::*invalidateSubImageImplementation)(GLint, const Vector3i&, const Vector3i&); + void(*invalidateImageImplementation)(AbstractTexture&, GLint); + void(*invalidateSubImageImplementation)(AbstractTexture&, GLint, const Vector3i&, const Vector3i&); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void(BufferTexture::*setBufferImplementation)(BufferTextureFormat, Buffer*); - void(BufferTexture::*setBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr); + void(*setBufferImplementation)(BufferTexture&, BufferTextureFormat, Buffer*); + void(*setBufferRangeImplementation)(BufferTexture&, BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr); #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void(CubeMapTexture::*getCubeLevelParameterivImplementation)(GLint, GLenum, GLint*); + void(*getCubeLevelParameterivImplementation)(CubeMapTexture&, GLint, GLenum, GLint*); #endif #ifndef MAGNUM_TARGET_GLES - GLint(CubeMapTexture::*getCubeLevelCompressedImageSizeImplementation)(GLint); - void(CubeMapTexture::*getCubeImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*); - void(CubeMapTexture::*getCubeImage3DImplementation)(GLint, const Vector3i&, PixelFormat, PixelType, std::size_t, GLvoid*, const PixelStorage&); - void(CubeMapTexture::*getCompressedCubeImage3DImplementation)(GLint, const Vector2i&, std::size_t, std::size_t, GLvoid*); - void(CubeMapTexture::*getCompressedCubeImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, std::size_t, GLvoid*); - #endif - void(CubeMapTexture::*cubeSubImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); - void(CubeMapTexture::*cubeSubImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*); - void(CubeMapTexture::*cubeCompressedSubImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, const Vector2i&, CompressedPixelFormat, const GLvoid*, GLsizei); + GLint(*getCubeLevelCompressedImageSizeImplementation)(CubeMapTexture&, GLint); + void(*getCubeImageImplementation)(CubeMapTexture&, CubeMapCoordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*); + void(*getCubeImage3DImplementation)(CubeMapTexture&, GLint, const Vector3i&, PixelFormat, PixelType, std::size_t, GLvoid*, const PixelStorage&); + void(*getCompressedCubeImage3DImplementation)(CubeMapTexture&, GLint, const Vector2i&, std::size_t, std::size_t, GLvoid*); + void(*getCompressedCubeImageImplementation)(CubeMapTexture&, CubeMapCoordinate, GLint, const Vector2i&, std::size_t, GLvoid*); + #endif + void(*cubeSubImage3DImplementation)(CubeMapTexture&, GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); + void(*cubeSubImageImplementation)(CubeMapTexture&, CubeMapCoordinate, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*); + void(*cubeCompressedSubImageImplementation)(CubeMapTexture&, CubeMapCoordinate, GLint, const Vector2i&, const Vector2i&, CompressedPixelFormat, const GLvoid*, GLsizei); GLint maxSize, #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) diff --git a/src/Magnum/GL/Implementation/TransformFeedbackState.h b/src/Magnum/GL/Implementation/TransformFeedbackState.h index 72f6b68e0..ac2e41771 100644 --- a/src/Magnum/GL/Implementation/TransformFeedbackState.h +++ b/src/Magnum/GL/Implementation/TransformFeedbackState.h @@ -32,13 +32,6 @@ #include "Magnum/GL/GL.h" #include "Magnum/GL/OpenGL.h" -#ifdef CORRADE_TARGET_MSVC -/* Otherwise the member function pointers will have different size based on - whether the header was included or not. CAUSES SERIOUS MEMORY CORRUPTION AND - IS NOT CAUGHT BY ANY WARNING WHATSOEVER! AARGH! */ -#include "Magnum/GL/TransformFeedback.h" -#endif - #ifdef MAGNUM_TARGET_GLES2 #error this header is not available in OpenGL ES 2.0 build #endif @@ -60,11 +53,11 @@ struct TransformFeedbackState { GLuint binding; - void(TransformFeedback::*createImplementation)(); - void(TransformFeedback::*attachRangeImplementation)(GLuint, Buffer&, GLintptr, GLsizeiptr); - void(TransformFeedback::*attachBaseImplementation)(GLuint, Buffer&); - void(TransformFeedback::*attachRangesImplementation)(GLuint, Containers::ArrayView>); - void(TransformFeedback::*attachBasesImplementation)(GLuint, Containers::ArrayView); + void(*createImplementation)(TransformFeedback&); + void(*attachRangeImplementation)(TransformFeedback&, GLuint, Buffer&, GLintptr, GLsizeiptr); + void(*attachBaseImplementation)(TransformFeedback&, GLuint, Buffer&); + void(*attachRangesImplementation)(TransformFeedback&, GLuint, Containers::ArrayView>); + void(*attachBasesImplementation)(TransformFeedback&, GLuint, Containers::ArrayView); }; }}} diff --git a/src/Magnum/GL/Mesh.cpp b/src/Magnum/GL/Mesh.cpp index 906e251a0..626497477 100644 --- a/src/Magnum/GL/Mesh.cpp +++ b/src/Magnum/GL/Mesh.cpp @@ -254,7 +254,7 @@ Int Mesh::maxElementsVertices() { #endif Mesh::Mesh(const MeshPrimitive primitive): _primitive{primitive}, _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current().state().mesh.createImplementation)(true); + Context::current().state().mesh.createImplementation(*this, true); } Mesh::Mesh(NoCreateT) noexcept: _id{0}, _primitive{MeshPrimitive::Triangles}, _flags{ObjectFlag::DeleteOnDestruction} {} @@ -269,7 +269,7 @@ Mesh::~Mesh() { if(current == _id) current = 0; } - if(_constructed) (this->*Context::current().state().mesh.destroyImplementation)(deleteObject); + if(_constructed) Context::current().state().mesh.destroyImplementation(*this, deleteObject); } Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), _flags{other._flags}, _countSet{other._countSet}, _count(other._count), _baseVertex{other._baseVertex}, _instanceCount{other._instanceCount}, @@ -282,7 +282,7 @@ Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), _indexOffset(other._indexOffset), _indexType(other._indexType), _indexBuffer{std::move(other._indexBuffer)} { if(_constructed || other._constructed) - (this->*Context::current().state().mesh.moveConstructImplementation)(std::move(other)); + Context::current().state().mesh.moveConstructImplementation(*this, std::move(other)); other._id = 0; } @@ -307,13 +307,13 @@ Mesh& Mesh::operator=(Mesh&& other) noexcept { swap(_indexBuffer, other._indexBuffer); if(_constructed || other._constructed) - (this->*Context::current().state().mesh.moveAssignImplementation)(std::move(other)); + Context::current().state().mesh.moveAssignImplementation(*this, std::move(other)); return *this; } Mesh::Mesh(const GLuint id, const MeshPrimitive primitive, const ObjectFlags flags): _id{id}, _primitive{primitive}, _flags{flags} { - (this->*Context::current().state().mesh.createImplementation)(false); + Context::current().state().mesh.createImplementation(*this, false); } inline void Mesh::createIfNotAlready() { @@ -390,7 +390,7 @@ Mesh& Mesh::setIndexBuffer(Buffer&& buffer, GLintptr offset, MeshIndexType type, /* It's IMPORTANT to do this *before* the _indexBuffer is set, since the bindVAO() function called from here is resetting element buffer state tracker to _indexBuffer.id(). */ - (this->*Context::current().state().mesh.bindIndexBufferImplementation)(buffer); + Context::current().state().mesh.bindIndexBufferImplementation(*this, buffer); _indexBuffer = std::move(buffer); _indexOffset = offset; @@ -422,7 +422,7 @@ void Mesh::drawInternal(const Containers::ArrayView& counts, the range being drawn */ const Implementation::MeshState& state = Context::current().state().mesh; - (this->*state.bindImplementation)(); + state.bindImplementation(*this); /* Non-indexed meshes */ if(!_indexBuffer.id()) { @@ -468,7 +468,7 @@ void Mesh::drawInternal(const Containers::ArrayView& counts, } } - (this->*state.unbindImplementation)(); + state.unbindImplementation(*this); } #ifdef MAGNUM_TARGET_GLES @@ -483,7 +483,7 @@ void Mesh::drawInternal(const Containers::ArrayView& counts, #endif ) { const Implementation::MeshState& state = Context::current().state().mesh; - (this->*state.bindImplementation)(); + state.bindImplementation(*this); CORRADE_ASSERT(instanceCounts.size() == counts.size(), "GL::AbstractShaderProgram::draw(): expected" << counts.size() << "instance count items but got" << instanceCounts.size(), ); @@ -544,7 +544,7 @@ void Mesh::drawInternal(const Containers::ArrayView& counts, } } - (this->*state.unbindImplementation)(); + state.unbindImplementation(*this); } #endif @@ -792,7 +792,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i { const Implementation::MeshState& state = Context::current().state().mesh; - (this->*state.bindImplementation)(); + state.bindImplementation(*this); /* Non-instanced mesh */ if(instanceCount == 1 @@ -932,14 +932,14 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i } } - (this->*state.unbindImplementation)(); + state.unbindImplementation(*this); } #ifndef MAGNUM_TARGET_GLES void Mesh::drawInternal(TransformFeedback& xfb, const UnsignedInt stream, const Int instanceCount) { const Implementation::MeshState& state = Context::current().state().mesh; - (this->*state.bindImplementation)(); + state.bindImplementation(*this); /* Default stream */ if(stream == 0) { @@ -958,7 +958,7 @@ void Mesh::drawInternal(TransformFeedback& xfb, const UnsignedInt stream, const else glDrawTransformFeedbackStreamInstanced(GLenum(_primitive), xfb.id(), stream, instanceCount); } - (this->*state.unbindImplementation)(); + state.unbindImplementation(*this); } #endif @@ -1015,54 +1015,54 @@ void Mesh::bindVAO() { } } -void Mesh::createImplementationDefault(bool) { - _id = 0; - _flags |= ObjectFlag::Created; +void Mesh::createImplementationDefault(Mesh& self, bool) { + self._id = 0; + self._flags |= ObjectFlag::Created; static_assert(sizeof(_attributes) >= sizeof(std::vector), "attribute storage buffer size too small"); - new(&_attributes) std::vector; - _constructed = true; + new(&self._attributes) std::vector; + self._constructed = true; } -void Mesh::createImplementationVAO(const bool createObject) { +void Mesh::createImplementationVAO(Mesh& self, const bool createObject) { if(createObject) { #ifndef MAGNUM_TARGET_GLES2 - glGenVertexArrays(1, &_id); + glGenVertexArrays(1, &self._id); #else - glGenVertexArraysOES(1, &_id); + glGenVertexArraysOES(1, &self._id); #endif - CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); + CORRADE_INTERNAL_ASSERT(self._id != Implementation::State::DisengagedBinding); } static_assert(sizeof(_attributes) >= sizeof(std::vector), "attribute storage buffer size too small"); - new(&_attributes) std::vector; - _constructed = true; + new(&self._attributes) std::vector; + self._constructed = true; } #ifndef MAGNUM_TARGET_GLES -void Mesh::createImplementationVAODSA(const bool createObject) { +void Mesh::createImplementationVAODSA(Mesh& self, const bool createObject) { if(createObject) { - glCreateVertexArrays(1, &_id); - _flags |= ObjectFlag::Created; + glCreateVertexArrays(1, &self._id); + self._flags |= ObjectFlag::Created; } static_assert(sizeof(_attributes) >= sizeof(std::vector), "attribute storage buffer size too small"); - new(&_attributes) std::vector; - _constructed = true; + new(&self._attributes) std::vector; + self._constructed = true; } #endif -void Mesh::moveConstructImplementationDefault(Mesh&& other) { - new(&_attributes) std::vector{std::move(*reinterpret_cast*>(&other._attributes))}; - _constructed = true; +void Mesh::moveConstructImplementationDefault(Mesh& self, Mesh&& other) { + new(&self._attributes) std::vector{std::move(*reinterpret_cast*>(&other._attributes))}; + self._constructed = true; } -void Mesh::moveConstructImplementationVAO(Mesh&& other) { - new(&_attributes) std::vector{std::move(*reinterpret_cast*>(&other._attributes))}; - _constructed = true; +void Mesh::moveConstructImplementationVAO(Mesh& self, Mesh&& other) { + new(&self._attributes) std::vector{std::move(*reinterpret_cast*>(&other._attributes))}; + self._constructed = true; } /* In the move construction / assignment we need to stay noexcept, which means @@ -1071,46 +1071,46 @@ void Mesh::moveConstructImplementationVAO(Mesh&& other) { is not, we do a "partial swap" -- `other` gets our data and our data gets emptied. */ -void Mesh::moveAssignImplementationDefault(Mesh&& other) { - if(_constructed && other._constructed) - std::swap(*reinterpret_cast*>(&_attributes), +void Mesh::moveAssignImplementationDefault(Mesh& self, Mesh&& other) { + if(self._constructed && other._constructed) + std::swap(*reinterpret_cast*>(&self._attributes), *reinterpret_cast*>(&other._attributes)); - else if(_constructed && !other._constructed) { + else if(self._constructed && !other._constructed) { other._constructed = true; - new(&other._attributes) std::vector{std::move(*reinterpret_cast*>(&_attributes))}; - } else if(!_constructed && other._constructed) { - _constructed = true; - new(&_attributes) std::vector{std::move(*reinterpret_cast*>(&other._attributes))}; + new(&other._attributes) std::vector{std::move(*reinterpret_cast*>(&self._attributes))}; + } else if(!self._constructed && other._constructed) { + self._constructed = true; + new(&self._attributes) std::vector{std::move(*reinterpret_cast*>(&other._attributes))}; } } -void Mesh::moveAssignImplementationVAO(Mesh&& other) { - if(_constructed && other._constructed) - std::swap(*reinterpret_cast*>(&_attributes), +void Mesh::moveAssignImplementationVAO(Mesh& self, Mesh&& other) { + if(self._constructed && other._constructed) + std::swap(*reinterpret_cast*>(&self._attributes), *reinterpret_cast*>(&other._attributes)); - else if(_constructed && !other._constructed) { + else if(self._constructed && !other._constructed) { other._constructed = true; - new(&other._attributes) std::vector{std::move(*reinterpret_cast*>(&_attributes))}; - } else if(!_constructed && other._constructed) { - _constructed = true; - new(&_attributes) std::vector{std::move(*reinterpret_cast*>(&other._attributes))}; + new(&other._attributes) std::vector{std::move(*reinterpret_cast*>(&self._attributes))}; + } else if(!self._constructed && other._constructed) { + self._constructed = true; + new(&self._attributes) std::vector{std::move(*reinterpret_cast*>(&other._attributes))}; } } -void Mesh::destroyImplementationDefault(bool) { - reinterpret_cast*>(&_attributes)->~vector(); +void Mesh::destroyImplementationDefault(Mesh& self, bool) { + reinterpret_cast*>(&self._attributes)->~vector(); } -void Mesh::destroyImplementationVAO(const bool deleteObject) { +void Mesh::destroyImplementationVAO(Mesh& self, const bool deleteObject) { if(deleteObject) { #ifndef MAGNUM_TARGET_GLES2 - glDeleteVertexArrays(1, &_id); + glDeleteVertexArrays(1, &self._id); #else - glDeleteVertexArraysOES(1, &_id); + glDeleteVertexArraysOES(1, &self._id); #endif } - reinterpret_cast*>(&_attributes)->~vector(); + reinterpret_cast*>(&self._attributes)->~vector(); } void Mesh::attributePointerInternal(const Buffer& buffer, const GLuint location, const GLint size, const GLenum type, const DynamicAttribute::Kind kind, const GLintptr offset, const GLsizei stride, const GLuint divisor) { @@ -1120,61 +1120,61 @@ void Mesh::attributePointerInternal(const Buffer& buffer, const GLuint location, void Mesh::attributePointerInternal(AttributeLayout&& attribute) { CORRADE_ASSERT(attribute.buffer.id(), "GL::Mesh::addVertexBuffer(): empty or moved-out Buffer instance was passed", ); - (this->*Context::current().state().mesh.attributePointerImplementation)(std::move(attribute)); + Context::current().state().mesh.attributePointerImplementation(*this, std::move(attribute)); } -void Mesh::attributePointerImplementationDefault(AttributeLayout&& attribute) { +void Mesh::attributePointerImplementationDefault(Mesh& self, AttributeLayout&& attribute) { #ifdef MAGNUM_TARGET_WEBGL CORRADE_ASSERT(attribute.buffer.targetHint() == Buffer::TargetHint::Array, "GL::Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::Array << "but got" << attribute.buffer.targetHint(), ); #endif - reinterpret_cast*>(&_attributes)->push_back(std::move(attribute)); + reinterpret_cast*>(&self._attributes)->push_back(std::move(attribute)); } -void Mesh::attributePointerImplementationVAO(AttributeLayout&& attribute) { +void Mesh::attributePointerImplementationVAO(Mesh& self, AttributeLayout&& attribute) { #ifdef MAGNUM_TARGET_WEBGL CORRADE_ASSERT(attribute.buffer.targetHint() == Buffer::TargetHint::Array, "GL::Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::Array << "but got" << attribute.buffer.targetHint(), ); #endif - bindVAO(); - vertexAttribPointer(attribute); + self.bindVAO(); + self.vertexAttribPointer(attribute); } #ifndef MAGNUM_TARGET_GLES -void Mesh::attributePointerImplementationVAODSA(AttributeLayout&& attribute) { - glEnableVertexArrayAttrib(_id, attribute.location); +void Mesh::attributePointerImplementationVAODSA(Mesh& self, AttributeLayout&& attribute) { + glEnableVertexArrayAttrib(self._id, attribute.location); #ifndef MAGNUM_TARGET_GLES2 if(attribute.kind == DynamicAttribute::Kind::Integral) - glVertexArrayAttribIFormat(_id, attribute.location, attribute.size, attribute.type, 0); + glVertexArrayAttribIFormat(self._id, attribute.location, attribute.size, attribute.type, 0); #ifndef MAGNUM_TARGET_GLES else if(attribute.kind == DynamicAttribute::Kind::Long) - glVertexArrayAttribLFormat(_id, attribute.location, attribute.size, attribute.type, 0); + glVertexArrayAttribLFormat(self._id, attribute.location, attribute.size, attribute.type, 0); #endif else #endif { - glVertexArrayAttribFormat(_id, attribute.location, attribute.size, attribute.type, attribute.kind == DynamicAttribute::Kind::GenericNormalized, 0); + glVertexArrayAttribFormat(self._id, attribute.location, attribute.size, attribute.type, attribute.kind == DynamicAttribute::Kind::GenericNormalized, 0); } - glVertexArrayAttribBinding(_id, attribute.location, attribute.location); + glVertexArrayAttribBinding(self._id, attribute.location, attribute.location); CORRADE_INTERNAL_ASSERT(attribute.stride != 0); - glVertexArrayVertexBuffer(_id, attribute.location, attribute.buffer.id(), attribute.offset, attribute.stride); + glVertexArrayVertexBuffer(self._id, attribute.location, attribute.buffer.id(), attribute.offset, attribute.stride); if(attribute.divisor) - (this->*Context::current().state().mesh.vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); + Context::current().state().mesh.vertexAttribDivisorImplementation(self, attribute.location, attribute.divisor); } #ifdef CORRADE_TARGET_WINDOWS -void Mesh::attributePointerImplementationVAODSAIntelWindows(AttributeLayout&& attribute) { +void Mesh::attributePointerImplementationVAODSAIntelWindows(Mesh& self, AttributeLayout&& attribute) { /* See the "intel-windows-broken-dsa-integer-vertex-attributes" workaround for more information. */ if(attribute.kind == DynamicAttribute::Kind::Integral) - return attributePointerImplementationVAO(std::move(attribute)); + return attributePointerImplementationVAO(self, std::move(attribute)); else - return attributePointerImplementationVAODSA(std::move(attribute)); + return attributePointerImplementationVAODSA(self, std::move(attribute)); } #endif #endif @@ -1182,13 +1182,13 @@ void Mesh::attributePointerImplementationVAODSAIntelWindows(AttributeLayout&& at #ifdef MAGNUM_TARGET_GLES /* See the "angle-instanced-attributes-always-draw-instanced" workaround for these two */ -void Mesh::attributePointerImplementationDefaultAngleAlwaysInstanced(AttributeLayout&& attribute) { - if(attribute.divisor) _instanced = true; - return attributePointerImplementationDefault(std::move(attribute)); +void Mesh::attributePointerImplementationDefaultAngleAlwaysInstanced(Mesh& self, AttributeLayout&& attribute) { + if(attribute.divisor) self._instanced = true; + return attributePointerImplementationDefault(self, std::move(attribute)); } -void Mesh::attributePointerImplementationVAOAngleAlwaysInstanced(AttributeLayout&& attribute) { - if(attribute.divisor) _instanced = true; - return attributePointerImplementationVAO(std::move(attribute)); +void Mesh::attributePointerImplementationVAOAngleAlwaysInstanced(Mesh& self, AttributeLayout&& attribute) { + if(attribute.divisor) self._instanced = true; + return attributePointerImplementationVAO(self, std::move(attribute)); } #endif @@ -1213,56 +1213,56 @@ void Mesh::vertexAttribPointer(AttributeLayout& attribute) { #ifndef MAGNUM_TARGET_GLES2 glVertexAttribDivisor(attribute.location, attribute.divisor); #else - (this->*Context::current().state().mesh.vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); + Context::current().state().mesh.vertexAttribDivisorImplementation(*this, attribute.location, attribute.divisor); #endif } } #ifndef MAGNUM_TARGET_GLES -void Mesh::vertexAttribDivisorImplementationVAO(const GLuint index, const GLuint divisor) { - bindVAO(); +void Mesh::vertexAttribDivisorImplementationVAO(Mesh& self, const GLuint index, const GLuint divisor) { + self.bindVAO(); glVertexAttribDivisor(index, divisor); } -void Mesh::vertexAttribDivisorImplementationVAODSA(const GLuint index, const GLuint divisor) { - glVertexArrayBindingDivisor(_id, index, divisor); +void Mesh::vertexAttribDivisorImplementationVAODSA(Mesh& self, const GLuint index, const GLuint divisor) { + glVertexArrayBindingDivisor(self._id, index, divisor); } #elif defined(MAGNUM_TARGET_GLES2) -void Mesh::vertexAttribDivisorImplementationANGLE(const GLuint index, const GLuint divisor) { +void Mesh::vertexAttribDivisorImplementationANGLE(Mesh&, const GLuint index, const GLuint divisor) { glVertexAttribDivisorANGLE(index, divisor); } #ifndef MAGNUM_TARGET_WEBGL -void Mesh::vertexAttribDivisorImplementationEXT(const GLuint index, const GLuint divisor) { +void Mesh::vertexAttribDivisorImplementationEXT(Mesh&, const GLuint index, const GLuint divisor) { glVertexAttribDivisorEXT(index, divisor); } -void Mesh::vertexAttribDivisorImplementationNV(const GLuint index, const GLuint divisor) { +void Mesh::vertexAttribDivisorImplementationNV(Mesh&, const GLuint index, const GLuint divisor) { glVertexAttribDivisorNV(index, divisor); } #endif #endif void Mesh::acquireVertexBuffer(Buffer&& buffer) { - (this->*Context::current().state().mesh.acquireVertexBufferImplementation)(std::move(buffer)); + Context::current().state().mesh.acquireVertexBufferImplementation(*this, std::move(buffer)); } -void Mesh::acquireVertexBufferImplementationDefault(Buffer&& buffer) { +void Mesh::acquireVertexBufferImplementationDefault(Mesh& self, Buffer&& buffer) { /* The last added buffer should be this one, replace it with a owning one */ - auto& attributes = *reinterpret_cast*>(&_attributes); + auto& attributes = *reinterpret_cast*>(&self._attributes); CORRADE_INTERNAL_ASSERT(!attributes.empty() && attributes.back().buffer.id() == buffer.id() && buffer.id()); attributes.back().buffer.release(); /* so we swap back a zero ID */ attributes.back().buffer = std::move(buffer); } -void Mesh::acquireVertexBufferImplementationVAO(Buffer&& buffer) { +void Mesh::acquireVertexBufferImplementationVAO(Mesh& self, Buffer&& buffer) { CORRADE_INTERNAL_ASSERT(buffer.id()); /* With VAOs we are not maintaining the attribute list, so just store the buffer directly */ - reinterpret_cast*>(&_attributes)->emplace_back(std::move(buffer)); + reinterpret_cast*>(&self._attributes)->emplace_back(std::move(buffer)); } -void Mesh::bindIndexBufferImplementationDefault(Buffer&) {} +void Mesh::bindIndexBufferImplementationDefault(Mesh&, Buffer&) {} -void Mesh::bindIndexBufferImplementationVAO(Buffer& buffer) { - bindVAO(); +void Mesh::bindIndexBufferImplementationVAO(Mesh& self, Buffer& buffer) { + self.bindVAO(); /* Binding the VAO in the above function resets element buffer binding, meaning the following will always cause the glBindBuffer() to be called */ @@ -1270,26 +1270,26 @@ void Mesh::bindIndexBufferImplementationVAO(Buffer& buffer) { } #ifndef MAGNUM_TARGET_GLES -void Mesh::bindIndexBufferImplementationVAODSA(Buffer& buffer) { - glVertexArrayElementBuffer(_id, buffer.id()); +void Mesh::bindIndexBufferImplementationVAODSA(Mesh& self, Buffer& buffer) { + glVertexArrayElementBuffer(self._id, buffer.id()); } #endif -void Mesh::bindImplementationDefault() { +void Mesh::bindImplementationDefault(Mesh& self) { /* Specify vertex attributes */ - for(AttributeLayout& attribute: *reinterpret_cast*>(&_attributes)) - vertexAttribPointer(attribute); + for(AttributeLayout& attribute: *reinterpret_cast*>(&self._attributes)) + self.vertexAttribPointer(attribute); /* Bind index buffer, if the mesh is indexed */ - if(_indexBuffer.id()) _indexBuffer.bindInternal(Buffer::TargetHint::ElementArray); + if(self._indexBuffer.id()) self._indexBuffer.bindInternal(Buffer::TargetHint::ElementArray); } -void Mesh::bindImplementationVAO() { - bindVAO(); +void Mesh::bindImplementationVAO(Mesh& self) { + self.bindVAO(); } -void Mesh::unbindImplementationDefault() { - for(const AttributeLayout& attribute: *reinterpret_cast*>(&_attributes)) { +void Mesh::unbindImplementationDefault(Mesh& self) { + for(const AttributeLayout& attribute: *reinterpret_cast*>(&self._attributes)) { glDisableVertexAttribArray(attribute.location); /* Reset also the divisor back so it doesn't affect */ @@ -1297,13 +1297,13 @@ void Mesh::unbindImplementationDefault() { #ifndef MAGNUM_TARGET_GLES2 glVertexAttribDivisor(attribute.location, 0); #else - (this->*Context::current().state().mesh.vertexAttribDivisorImplementation)(attribute.location, 0); + Context::current().state().mesh.vertexAttribDivisorImplementation(self, attribute.location, 0); #endif } } } -void Mesh::unbindImplementationVAO() {} +void Mesh::unbindImplementationVAO(Mesh&) {} #ifdef MAGNUM_TARGET_GLES #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) diff --git a/src/Magnum/GL/Mesh.h b/src/Magnum/GL/Mesh.h index 0086bfa5b..eb681d5fc 100644 --- a/src/Magnum/GL/Mesh.h +++ b/src/Magnum/GL/Mesh.h @@ -1258,62 +1258,62 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject { MAGNUM_GL_LOCAL void drawInternal(TransformFeedback& xfb, UnsignedInt stream, Int instanceCount); #endif - void MAGNUM_GL_LOCAL createImplementationDefault(bool); - void MAGNUM_GL_LOCAL createImplementationVAO(bool createObject); + static void MAGNUM_GL_LOCAL createImplementationDefault(Mesh& self, bool); + static void MAGNUM_GL_LOCAL createImplementationVAO(Mesh& self, bool createObject); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL createImplementationVAODSA(bool createObject); + static void MAGNUM_GL_LOCAL createImplementationVAODSA(Mesh& self, bool createObject); #endif - void MAGNUM_GL_LOCAL moveConstructImplementationDefault(Mesh&& other); - void MAGNUM_GL_LOCAL moveConstructImplementationVAO(Mesh&& other); - void MAGNUM_GL_LOCAL moveAssignImplementationDefault(Mesh&& other); - void MAGNUM_GL_LOCAL moveAssignImplementationVAO(Mesh&& other); + static void MAGNUM_GL_LOCAL moveConstructImplementationDefault(Mesh& self, Mesh&& other); + static void MAGNUM_GL_LOCAL moveConstructImplementationVAO(Mesh& self, Mesh&& other); + static void MAGNUM_GL_LOCAL moveAssignImplementationDefault(Mesh& self, Mesh&& other); + static void MAGNUM_GL_LOCAL moveAssignImplementationVAO(Mesh& self, Mesh&& other); - void MAGNUM_GL_LOCAL destroyImplementationDefault(bool); - void MAGNUM_GL_LOCAL destroyImplementationVAO(bool deleteObject); + static void MAGNUM_GL_LOCAL destroyImplementationDefault(Mesh& self, bool); + static void MAGNUM_GL_LOCAL destroyImplementationVAO(Mesh& self, bool deleteObject); void attributePointerInternal(const Buffer& buffer, GLuint location, GLint size, GLenum type, DynamicAttribute::Kind kind, GLintptr offset, GLsizei stride, GLuint divisor); void MAGNUM_GL_LOCAL attributePointerInternal(AttributeLayout&& attribute); - void MAGNUM_GL_LOCAL attributePointerImplementationDefault(AttributeLayout&& attribute); - void MAGNUM_GL_LOCAL attributePointerImplementationVAO(AttributeLayout&& attribute); + static void MAGNUM_GL_LOCAL attributePointerImplementationDefault(Mesh& self, AttributeLayout&& attribute); + static void MAGNUM_GL_LOCAL attributePointerImplementationVAO(Mesh& self, AttributeLayout&& attribute); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL attributePointerImplementationVAODSA(AttributeLayout&& attribute); + static void MAGNUM_GL_LOCAL attributePointerImplementationVAODSA(Mesh& self, AttributeLayout&& attribute); #ifdef CORRADE_TARGET_WINDOWS - void MAGNUM_GL_LOCAL attributePointerImplementationVAODSAIntelWindows(AttributeLayout&& attribute); + static void MAGNUM_GL_LOCAL attributePointerImplementationVAODSAIntelWindows(Mesh& self, AttributeLayout&& attribute); #endif #endif #ifdef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL attributePointerImplementationDefaultAngleAlwaysInstanced(AttributeLayout&& attribute); - void MAGNUM_GL_LOCAL attributePointerImplementationVAOAngleAlwaysInstanced(AttributeLayout&& attribute); + static void MAGNUM_GL_LOCAL attributePointerImplementationDefaultAngleAlwaysInstanced(Mesh& self, AttributeLayout&& attribute); + static void MAGNUM_GL_LOCAL attributePointerImplementationVAOAngleAlwaysInstanced(Mesh& self, AttributeLayout&& attribute); #endif void MAGNUM_GL_LOCAL vertexAttribPointer(AttributeLayout& attribute); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationVAO(GLuint index, GLuint divisor); - void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationVAODSA(GLuint index, GLuint divisor); + static void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationVAO(Mesh& self, GLuint index, GLuint divisor); + static void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationVAODSA(Mesh& self, GLuint index, GLuint divisor); #elif defined(MAGNUM_TARGET_GLES2) - void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationANGLE(GLuint index, GLuint divisor); + static void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationANGLE(Mesh& self, GLuint index, GLuint divisor); #ifndef MAGNUM_TARGET_WEBGL - void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationEXT(GLuint index, GLuint divisor); - void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationNV(GLuint index, GLuint divisor); + static void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationEXT(Mesh& self, GLuint index, GLuint divisor); + static void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationNV(Mesh& self, GLuint index, GLuint divisor); #endif #endif void acquireVertexBuffer(Buffer&& buffer); - void MAGNUM_GL_LOCAL acquireVertexBufferImplementationDefault(Buffer&& buffer); - void MAGNUM_GL_LOCAL acquireVertexBufferImplementationVAO(Buffer&& buffer); + static void MAGNUM_GL_LOCAL acquireVertexBufferImplementationDefault(Mesh& self, Buffer&& buffer); + static void MAGNUM_GL_LOCAL acquireVertexBufferImplementationVAO(Mesh& self, Buffer&& buffer); - void MAGNUM_GL_LOCAL bindIndexBufferImplementationDefault(Buffer&); - void MAGNUM_GL_LOCAL bindIndexBufferImplementationVAO(Buffer& buffer); + static void MAGNUM_GL_LOCAL bindIndexBufferImplementationDefault(Mesh& self, Buffer&); + static void MAGNUM_GL_LOCAL bindIndexBufferImplementationVAO(Mesh& self, Buffer& buffer); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL bindIndexBufferImplementationVAODSA(Buffer& buffer); + static void MAGNUM_GL_LOCAL bindIndexBufferImplementationVAODSA(Mesh& self, Buffer& buffer); #endif - void MAGNUM_GL_LOCAL bindImplementationDefault(); - void MAGNUM_GL_LOCAL bindImplementationVAO(); + static void MAGNUM_GL_LOCAL bindImplementationDefault(Mesh& self); + static void MAGNUM_GL_LOCAL bindImplementationVAO(Mesh& self); - void MAGNUM_GL_LOCAL unbindImplementationDefault(); - void MAGNUM_GL_LOCAL unbindImplementationVAO(); + static void MAGNUM_GL_LOCAL unbindImplementationDefault(Mesh& self); + static void MAGNUM_GL_LOCAL unbindImplementationVAO(Mesh& self); #ifdef MAGNUM_TARGET_GLES #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) diff --git a/src/Magnum/GL/Renderbuffer.cpp b/src/Magnum/GL/Renderbuffer.cpp index 033533821..6b385c300 100644 --- a/src/Magnum/GL/Renderbuffer.cpp +++ b/src/Magnum/GL/Renderbuffer.cpp @@ -73,17 +73,17 @@ Int Renderbuffer::maxSamples() { #endif Renderbuffer::Renderbuffer(): _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current().state().framebuffer.createRenderbufferImplementation)(); + Context::current().state().framebuffer.createRenderbufferImplementation(*this); } -void Renderbuffer::createImplementationDefault() { - glGenRenderbuffers(1, &_id); +void Renderbuffer::createImplementationDefault(Renderbuffer& self) { + glGenRenderbuffers(1, &self._id); } #ifndef MAGNUM_TARGET_GLES -void Renderbuffer::createImplementationDSA() { - glCreateRenderbuffers(1, &_id); - _flags |= ObjectFlag::Created; +void Renderbuffer::createImplementationDSA(Renderbuffer& self) { + glCreateRenderbuffers(1, &self._id); + self._flags |= ObjectFlag::Created; } #endif @@ -123,12 +123,12 @@ Renderbuffer& Renderbuffer::setLabel(const Containers::StringView label) { #endif void Renderbuffer::setStorage(const RenderbufferFormat internalFormat, const Vector2i& size) { - (this->*Context::current().state().framebuffer.renderbufferStorageImplementation)(internalFormat, size); + Context::current().state().framebuffer.renderbufferStorageImplementation(*this, internalFormat, size); } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void Renderbuffer::setStorageMultisample(const Int samples, const RenderbufferFormat internalFormat, const Vector2i& size) { - (this->*Context::current().state().framebuffer.renderbufferStorageMultisampleImplementation)(samples, internalFormat, size); + Context::current().state().framebuffer.renderbufferStorageMultisampleImplementation(*this, samples, internalFormat, size); } #endif @@ -143,37 +143,37 @@ void Renderbuffer::bind() { glBindRenderbuffer(GL_RENDERBUFFER, _id); } -void Renderbuffer::storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size) { - bind(); +void Renderbuffer::storageImplementationDefault(Renderbuffer& self, RenderbufferFormat internalFormat, const Vector2i& size) { + self.bind(); glRenderbufferStorage(GL_RENDERBUFFER, GLenum(internalFormat), size.x(), size.y()); } #ifndef MAGNUM_TARGET_GLES -void Renderbuffer::storageImplementationDSA(const RenderbufferFormat internalFormat, const Vector2i& size) { - glNamedRenderbufferStorage(_id, GLenum(internalFormat), size.x(), size.y()); +void Renderbuffer::storageImplementationDSA(Renderbuffer& self, const RenderbufferFormat internalFormat, const Vector2i& size) { + glNamedRenderbufferStorage(self._id, GLenum(internalFormat), size.x(), size.y()); } #endif #ifndef MAGNUM_TARGET_GLES2 -void Renderbuffer::storageMultisampleImplementationDefault(const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { - bind(); +void Renderbuffer::storageMultisampleImplementationDefault(Renderbuffer& self, const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { + self.bind(); glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GLenum(internalFormat), size.x(), size.y()); } #elif !defined(MAGNUM_TARGET_WEBGL) -void Renderbuffer::storageMultisampleImplementationANGLE(const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { - bind(); +void Renderbuffer::storageMultisampleImplementationANGLE(Renderbuffer& self, const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { + self.bind(); glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, samples, GLenum(internalFormat), size.x(), size.y()); } -void Renderbuffer::storageMultisampleImplementationNV(const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { - bind(); +void Renderbuffer::storageMultisampleImplementationNV(Renderbuffer& self, const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { + self.bind(); glRenderbufferStorageMultisampleNV(GL_RENDERBUFFER, samples, GLenum(internalFormat), size.x(), size.y()); } #endif #ifndef MAGNUM_TARGET_GLES -void Renderbuffer::storageMultisampleImplementationDSA(const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { - glNamedRenderbufferStorageMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y()); +void Renderbuffer::storageMultisampleImplementationDSA(Renderbuffer& self, const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { + glNamedRenderbufferStorageMultisample(self._id, samples, GLenum(internalFormat), size.x(), size.y()); } #endif diff --git a/src/Magnum/GL/Renderbuffer.h b/src/Magnum/GL/Renderbuffer.h index 283287b4c..d5775d29e 100644 --- a/src/Magnum/GL/Renderbuffer.h +++ b/src/Magnum/GL/Renderbuffer.h @@ -247,26 +247,26 @@ class MAGNUM_GL_EXPORT Renderbuffer: public AbstractObject { private: explicit Renderbuffer(GLuint id, ObjectFlags flags) noexcept: _id{id}, _flags{flags} {} - void MAGNUM_GL_LOCAL createImplementationDefault(); + static void MAGNUM_GL_LOCAL createImplementationDefault(Renderbuffer& self); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL createImplementationDSA(); + static void MAGNUM_GL_LOCAL createImplementationDSA(Renderbuffer& self); #endif void MAGNUM_GL_LOCAL createIfNotAlready(); - void MAGNUM_GL_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size); + static void MAGNUM_GL_LOCAL storageImplementationDefault(Renderbuffer& self, RenderbufferFormat internalFormat, const Vector2i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size); + static void MAGNUM_GL_LOCAL storageImplementationDSA(Renderbuffer& self, RenderbufferFormat internalFormat, const Vector2i& size); #endif #ifndef MAGNUM_TARGET_GLES2 - void MAGNUM_GL_LOCAL storageMultisampleImplementationDefault(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationDefault(Renderbuffer& self, GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL storageMultisampleImplementationDSA(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationDSA(Renderbuffer& self, GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); #endif #elif !defined(MAGNUM_TARGET_WEBGL) - void MAGNUM_GL_LOCAL storageMultisampleImplementationANGLE(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); - void MAGNUM_GL_LOCAL storageMultisampleImplementationNV(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationANGLE(Renderbuffer& self, GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); + static void MAGNUM_GL_LOCAL storageMultisampleImplementationNV(Renderbuffer& self, GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); #endif void MAGNUM_GL_LOCAL bind(); diff --git a/src/Magnum/GL/Shader.cpp b/src/Magnum/GL/Shader.cpp index cb690f7bc..0428c2107 100644 --- a/src/Magnum/GL/Shader.cpp +++ b/src/Magnum/GL/Shader.cpp @@ -780,18 +780,18 @@ Shader& Shader::addSourceInternal(Containers::String&& source) { (_sources.size() + 1)/2)); else arrayAppend(_sources, Containers::String::nullTerminatedGlobalView(""_s)); - (this->*Context::current().state().shader.addSourceImplementation)(std::move(source)); + Context::current().state().shader.addSourceImplementation(*this, std::move(source)); } return *this; } -void Shader::addSourceImplementationDefault(Containers::String&& source) { - arrayAppend(_sources, std::move(source)); +void Shader::addSourceImplementationDefault(Shader& self, Containers::String&& source) { + arrayAppend(self._sources, std::move(source)); } #if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__) -void Shader::addSourceImplementationEmscriptenPthread(Containers::String&& source) { +void Shader::addSourceImplementationEmscriptenPthread(Shader& self, Containers::String&& source) { /* Modify the string to remove non-ASCII characters. Ensure we're only modifying a string we actually own, if not make a copy first. See the "emscripten-pthreads-broken-unicode-shader-sources" workaround @@ -799,7 +799,7 @@ void Shader::addSourceImplementationEmscriptenPthread(Containers::String&& sourc if(!source.isSmall() && !source.deleter()) source = Containers::String{source}; for(char& c: source) if(c < 0) c = ' '; - arrayAppend(_sources, std::move(source)); + arrayAppend(self._sources, std::move(source)); } #endif diff --git a/src/Magnum/GL/Shader.h b/src/Magnum/GL/Shader.h index ec2bb154b..0097d1c76 100644 --- a/src/Magnum/GL/Shader.h +++ b/src/Magnum/GL/Shader.h @@ -770,9 +770,9 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject { /* Used by addSource(Containers::String&&) */ Shader& addSourceInternal(Containers::String&& source); - void MAGNUM_GL_LOCAL addSourceImplementationDefault(Containers::String&& source); + static void MAGNUM_GL_LOCAL addSourceImplementationDefault(Shader& self, Containers::String&& source); #if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__) - void MAGNUM_GL_LOCAL addSourceImplementationEmscriptenPthread(Containers::String&& source); + static void MAGNUM_GL_LOCAL addSourceImplementationEmscriptenPthread(Shader& self, Containers::String&& source); #endif static MAGNUM_GL_LOCAL void cleanLogImplementationNoOp(Containers::String& message); diff --git a/src/Magnum/GL/TransformFeedback.cpp b/src/Magnum/GL/TransformFeedback.cpp index d0b07147b..930a01ec9 100644 --- a/src/Magnum/GL/TransformFeedback.cpp +++ b/src/Magnum/GL/TransformFeedback.cpp @@ -114,18 +114,18 @@ Int TransformFeedback::maxVertexStreams() { #endif TransformFeedback::TransformFeedback(): _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current().state().transformFeedback.createImplementation)(); + Context::current().state().transformFeedback.createImplementation(*this); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } -void TransformFeedback::createImplementationDefault() { - glGenTransformFeedbacks(1, &_id); +void TransformFeedback::createImplementationDefault(TransformFeedback& self) { + glGenTransformFeedbacks(1, &self._id); } #ifndef MAGNUM_TARGET_GLES -void TransformFeedback::createImplementationDSA() { - glCreateTransformFeedbacks(1, &_id); - _flags |= ObjectFlag::Created; +void TransformFeedback::createImplementationDSA(TransformFeedback& self) { + glCreateTransformFeedbacks(1, &self._id); + self._flags |= ObjectFlag::Created; } #endif @@ -177,49 +177,49 @@ TransformFeedback& TransformFeedback::setLabel(const Containers::StringView labe #endif TransformFeedback& TransformFeedback::attachBuffer(const UnsignedInt index, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { - (this->*Context::current().state().transformFeedback.attachRangeImplementation)(index, buffer, offset, size); + Context::current().state().transformFeedback.attachRangeImplementation(*this, index, buffer, offset, size); return *this; } TransformFeedback& TransformFeedback::attachBuffer(const UnsignedInt index, Buffer& buffer) { - (this->*Context::current().state().transformFeedback.attachBaseImplementation)(index, buffer); + Context::current().state().transformFeedback.attachBaseImplementation(*this, index, buffer); return *this; } -void TransformFeedback::attachImplementationFallback(const GLuint index, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { - bindInternal(); +void TransformFeedback::attachImplementationFallback(TransformFeedback& self, const GLuint index, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { + self.bindInternal(); buffer.bind(Buffer::Target(GL_TRANSFORM_FEEDBACK_BUFFER), index, offset, size); } #ifndef MAGNUM_TARGET_GLES -void TransformFeedback::attachImplementationDSA(const GLuint index, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { - glTransformFeedbackBufferRange(_id, index, buffer.id(), offset, size); +void TransformFeedback::attachImplementationDSA(TransformFeedback& self, const GLuint index, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { + glTransformFeedbackBufferRange(self._id, index, buffer.id(), offset, size); } #endif -void TransformFeedback::attachImplementationFallback(const GLuint index, Buffer& buffer) { - bindInternal(); +void TransformFeedback::attachImplementationFallback(TransformFeedback& self, const GLuint index, Buffer& buffer) { + self.bindInternal(); buffer.bind(Buffer::Target(GL_TRANSFORM_FEEDBACK_BUFFER), index); } #ifndef MAGNUM_TARGET_GLES -void TransformFeedback::attachImplementationDSA(const GLuint index, Buffer& buffer) { - glTransformFeedbackBufferBase(_id, index, buffer.id()); +void TransformFeedback::attachImplementationDSA(TransformFeedback& self, const GLuint index, Buffer& buffer) { + glTransformFeedbackBufferBase(self._id, index, buffer.id()); } #endif TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, Containers::ArrayView> buffers) { - (this->*Context::current().state().transformFeedback.attachRangesImplementation)(firstIndex, buffers); + Context::current().state().transformFeedback.attachRangesImplementation(*this, firstIndex, buffers); return *this; } TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list> buffers) { - (this->*Context::current().state().transformFeedback.attachRangesImplementation)(firstIndex, Containers::arrayView(buffers)); + Context::current().state().transformFeedback.attachRangesImplementation(*this, firstIndex, Containers::arrayView(buffers)); return *this; } TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, Containers::ArrayView buffers) { - (this->*Context::current().state().transformFeedback.attachBasesImplementation)(firstIndex, buffers); + Context::current().state().transformFeedback.attachBasesImplementation(*this, firstIndex, buffers); return *this; } @@ -227,29 +227,29 @@ TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex return attachBuffers(firstIndex, Containers::arrayView(buffers)); } -void TransformFeedback::attachImplementationFallback(const GLuint firstIndex, Containers::ArrayView> buffers) { - bindInternal(); +void TransformFeedback::attachImplementationFallback(TransformFeedback& self, const GLuint firstIndex, Containers::ArrayView> buffers) { + self.bindInternal(); Buffer::bind(Buffer::Target(GL_TRANSFORM_FEEDBACK_BUFFER), firstIndex, buffers); } #ifndef MAGNUM_TARGET_GLES -void TransformFeedback::attachImplementationDSA(const GLuint firstIndex, Containers::ArrayView> buffers) { +void TransformFeedback::attachImplementationDSA(TransformFeedback& self, const GLuint firstIndex, Containers::ArrayView> buffers) { for(std::size_t i = 0; i != buffers.size(); ++i) { Buffer* buffer = buffers[i].first(); - glTransformFeedbackBufferRange(_id, firstIndex + i, buffer ? buffer->id() : 0, buffers[i].second(), buffers[i].third()); + glTransformFeedbackBufferRange(self._id, firstIndex + i, buffer ? buffer->id() : 0, buffers[i].second(), buffers[i].third()); } } #endif -void TransformFeedback::attachImplementationFallback(const GLuint firstIndex, Containers::ArrayView buffers) { - bindInternal(); +void TransformFeedback::attachImplementationFallback(TransformFeedback& self, const GLuint firstIndex, Containers::ArrayView buffers) { + self.bindInternal(); Buffer::bind(Buffer::Target(GL_TRANSFORM_FEEDBACK_BUFFER), firstIndex, buffers); } #ifndef MAGNUM_TARGET_GLES -void TransformFeedback::attachImplementationDSA(const GLuint firstIndex, Containers::ArrayView buffers) { +void TransformFeedback::attachImplementationDSA(TransformFeedback& self, const GLuint firstIndex, Containers::ArrayView buffers) { for(std::size_t i = 0; i != buffers.size(); ++i) - glTransformFeedbackBufferBase(_id, firstIndex + i, *(buffers.begin() + i) ? (*(buffers.begin() + i))->id() : 0); + glTransformFeedbackBufferBase(self._id, firstIndex + i, *(buffers.begin() + i) ? (*(buffers.begin() + i))->id() : 0); } #endif diff --git a/src/Magnum/GL/TransformFeedback.h b/src/Magnum/GL/TransformFeedback.h index c08fcef1b..d2426676a 100644 --- a/src/Magnum/GL/TransformFeedback.h +++ b/src/Magnum/GL/TransformFeedback.h @@ -428,23 +428,23 @@ class MAGNUM_GL_EXPORT TransformFeedback: public AbstractObject { void MAGNUM_GL_LOCAL createIfNotAlready(); - void MAGNUM_GL_LOCAL createImplementationDefault(); + static void MAGNUM_GL_LOCAL createImplementationDefault(TransformFeedback& self); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL createImplementationDSA(); + static void MAGNUM_GL_LOCAL createImplementationDSA(TransformFeedback& self); #endif - void MAGNUM_GL_LOCAL attachImplementationFallback(GLuint index, Buffer& buffer, GLintptr offset, GLsizeiptr size); - void MAGNUM_GL_LOCAL attachImplementationFallback(GLuint index, Buffer& buffer); + static void MAGNUM_GL_LOCAL attachImplementationFallback(TransformFeedback& self, GLuint index, Buffer& buffer, GLintptr offset, GLsizeiptr size); + static void MAGNUM_GL_LOCAL attachImplementationFallback(TransformFeedback& self, GLuint index, Buffer& buffer); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint index, Buffer& buffer, GLintptr offset, GLsizeiptr size); - void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint index, Buffer& buffer); + static void MAGNUM_GL_LOCAL attachImplementationDSA(TransformFeedback& self, GLuint index, Buffer& buffer, GLintptr offset, GLsizeiptr size); + static void MAGNUM_GL_LOCAL attachImplementationDSA(TransformFeedback& self, GLuint index, Buffer& buffer); #endif - void MAGNUM_GL_LOCAL attachImplementationFallback(GLuint firstIndex, Containers::ArrayView> buffers); - void MAGNUM_GL_LOCAL attachImplementationFallback(GLuint firstIndex, Containers::ArrayView buffers); + static void MAGNUM_GL_LOCAL attachImplementationFallback(TransformFeedback& self, GLuint firstIndex, Containers::ArrayView> buffers); + static void MAGNUM_GL_LOCAL attachImplementationFallback(TransformFeedback& self, GLuint firstIndex, Containers::ArrayView buffers); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint firstIndex, Containers::ArrayView> buffers); - void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint firstIndex, Containers::ArrayView buffers); + static void MAGNUM_GL_LOCAL attachImplementationDSA(TransformFeedback& self, GLuint firstIndex, Containers::ArrayView> buffers); + static void MAGNUM_GL_LOCAL attachImplementationDSA(TransformFeedback& self, GLuint firstIndex, Containers::ArrayView buffers); #endif GLuint _id;