Browse Source

GL: clean up remaining member function pointers in the state tracker.

And use static functions with an explicit "self" pointer instead. Those
have half the size (8 vs 16 bytes on 64bit x86), which in turn reduces
the state tracker memory use by about 750 bytes. On desktop GL with an
Intel GPU & Mesa this reduces the state tracker allocation size by almot
10%, from 8.3 kB to 7.6 kB. Not bad.

Apart from small memory savings, this also removes the need to include
the full class definiton from the State headers on MSVC (because
on that compiler the member function pointer size is different based on
whether the type definition is known or not, IMAGINE THAT BEING A
FEATURE AND NOT A BUG), leading to less header dependencies and better
incremental compile times there.

This was already done in some cases (and the Vk library used this from
the beginning), and as I'm about to add some more extension-dependent
functionality it felt like a good time to finish that change, finally.

In some cases the *Implementation() could even be dropped in favor of
pointing to the GL API directly (such as is already done for various
glUniform*() calls), that'd be another step -- this is good enough for
now.
pull/601/head
Vladimír Vondruš 3 years ago
parent
commit
3eb131c82e
  1. 185
      src/Magnum/GL/AbstractFramebuffer.cpp
  2. 66
      src/Magnum/GL/AbstractFramebuffer.h
  3. 50
      src/Magnum/GL/AbstractQuery.cpp
  4. 8
      src/Magnum/GL/AbstractQuery.h
  5. 12
      src/Magnum/GL/AbstractShaderProgram.cpp
  6. 4
      src/Magnum/GL/AbstractShaderProgram.h
  7. 554
      src/Magnum/GL/AbstractTexture.cpp
  8. 150
      src/Magnum/GL/AbstractTexture.h
  9. 174
      src/Magnum/GL/Buffer.cpp
  10. 62
      src/Magnum/GL/Buffer.h
  11. 32
      src/Magnum/GL/BufferTexture.cpp
  12. 12
      src/Magnum/GL/BufferTexture.h
  13. 168
      src/Magnum/GL/CubeMapTexture.cpp
  14. 48
      src/Magnum/GL/CubeMapTexture.h
  15. 20
      src/Magnum/GL/DefaultFramebuffer.cpp
  16. 114
      src/Magnum/GL/Framebuffer.cpp
  17. 26
      src/Magnum/GL/Framebuffer.h
  18. 26
      src/Magnum/GL/Implementation/BufferState.h
  19. 55
      src/Magnum/GL/Implementation/FramebufferState.h
  20. 20
      src/Magnum/GL/Implementation/MeshState.h
  21. 9
      src/Magnum/GL/Implementation/QueryState.h
  22. 2
      src/Magnum/GL/Implementation/ShaderProgramState.h
  23. 9
      src/Magnum/GL/Implementation/ShaderState.h
  24. 94
      src/Magnum/GL/Implementation/TextureState.h
  25. 17
      src/Magnum/GL/Implementation/TransformFeedbackState.h
  26. 218
      src/Magnum/GL/Mesh.cpp
  27. 58
      src/Magnum/GL/Mesh.h
  28. 40
      src/Magnum/GL/Renderbuffer.cpp
  29. 16
      src/Magnum/GL/Renderbuffer.h
  30. 10
      src/Magnum/GL/Shader.cpp
  31. 4
      src/Magnum/GL/Shader.h
  32. 54
      src/Magnum/GL/TransformFeedback.cpp
  33. 20
      src/Magnum/GL/TransformFeedback.h

185
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<void>(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<void>(self);
static_cast<void>(count);
static_cast<void>(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

66
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
};

50
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

8
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;

12
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<Containers::String> nameData;
Containers::ArrayView<const char*> 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<Containers::String> nameData;
Containers::ArrayView<const char*> 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

4
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

554
src/Magnum/GL/AbstractTexture.cpp

File diff suppressed because it is too large Load Diff

150
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<AbstractTexture* const> 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<UnsignedInt dimensions> std::size_t MAGNUM_GL_LOCAL compressedSubImageSize(TextureFormat format, const Math::Vector<dimensions, Int>& 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(AbstractTexture::*original)(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&)> void MAGNUM_GL_LOCAL subImageImplementationSvga3DSliceBySlice(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage& storage);
template<void(*original)(AbstractTexture&, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&)> 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(AbstractTexture::*original)(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&)> void MAGNUM_GL_LOCAL subImageImplementationSvga3DSliceBySlice(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage& storage);
template<void(*original)(AbstractTexture&, GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&)> 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

174
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<const void> 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<char> Buffer::data() {
#endif
Buffer& Buffer::setData(const Containers::ArrayView<const void> 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<const void> 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<char*>((this->*Context::current().state().buffer.mapImplementation)(access));
return static_cast<char*>(Context::current().state().buffer.mapImplementation(*this, access));
}
Containers::ArrayView<char> Buffer::map(const GLintptr offset, const GLsizeiptr length, const MapFlags flags) {
return {static_cast<char*>((this->*Context::current().state().buffer.mapRangeImplementation)(offset, length, flags)), std::size_t(length)};
return {static_cast<char*>(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<char> Buffer::subData(const GLintptr offset, const GLsizeiptr size) {
Containers::Array<char> 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<const void> data, StorageFlags flags) {
glBufferStorage(GLenum(bindSomewhereInternal(_targetHint)), data.size(), data.data(), GLbitfield(flags));
void Buffer::storageImplementationDefault(Buffer& self, Containers::ArrayView<const void> data, StorageFlags flags) {
glBufferStorage(GLenum(self.bindSomewhereInternal(self._targetHint)), data.size(), data.data(), GLbitfield(flags));
}
void Buffer::storageImplementationDSA(Containers::ArrayView<const void> data, const StorageFlags flags) {
glNamedBufferStorage(_id, data.size(), data.data(), GLbitfield(flags));
void Buffer::storageImplementationDSA(Buffer& self, Containers::ArrayView<const void> 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

62
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<const void> data, StorageFlags flags);
void MAGNUM_GL_LOCAL storageImplementationDSA(Containers::ArrayView<const void> data, StorageFlags flags);
static void MAGNUM_GL_LOCAL storageImplementationDefault(Buffer& self, Containers::ArrayView<const void> data, StorageFlags flags);
static void MAGNUM_GL_LOCAL storageImplementationDSA(Buffer& self, Containers::ArrayView<const void> 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

32
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;
}

12
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
};

168
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<char> 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<char> 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<char*>(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<char*>(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<char*>(data) + stride*i);
getImageImplementationDefault(self, CubeMapCoordinate(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i), level, size.xy(), format, type, stride, static_cast<char*>(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<char*>(data) + dataSize*face/6);
glGetCompressedTextureSubImage(self._id, level, 0, 0, face, size.x(), size.y(), 1, dataOffset + dataSize/6, static_cast<char*>(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<const char*>(data) + stride*i, storage);
subImageImplementationDSA(self, level, {offset.xy(), offset.z() + i}, {size.xy(), 1}, format, type, static_cast<const char*>(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<const char*>(data) + stride*i);
subImageImplementationDefault(self, CubeMapCoordinate(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i), level, offset.xy(), size.xy(), format, type, static_cast<const char*>(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

48
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
};

20
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<c
for(const auto& attachment: attachments)
_attachments[attachment.first()] = GLenum(attachment.second());
(this->*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<Contain
DefaultFramebuffer& DefaultFramebuffer::mapForDraw(const DrawAttachment attachment) {
#ifndef MAGNUM_TARGET_GLES
(this->*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<const GLenum*>(&attachment));
Context::current().state().framebuffer.drawBuffersImplementation(*this, 1, reinterpret_cast<const GLenum*>(&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<const InvalidationAtta
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
(this->*Context::current().state().framebuffer.invalidateImplementation)(attachments.size(), _attachments);
Context::current().state().framebuffer.invalidateImplementation(*this, attachments.size(), _attachments);
}
void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments) {
@ -117,7 +117,7 @@ void DefaultFramebuffer::invalidate(const Containers::ArrayView<const Invalidati
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
(this->*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<InvalidationAttachment> attachments, const Range2Di& rectangle) {

114
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<const Container
for(const auto& attachment: attachments)
_attachments[attachment.first()] = GLenum(attachment.second());
(this->*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<Containers::Pair<Unsi
Framebuffer& Framebuffer::mapForDraw(const DrawAttachment attachment) {
#ifndef MAGNUM_TARGET_GLES
(this->*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<const GLenum*>(&attachment));
Context::current().state().framebuffer.drawBuffersImplementation(*this, 1, reinterpret_cast<const GLenum*>(&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<const InvalidationAttac
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
(this->*Context::current().state().framebuffer.invalidateImplementation)(attachments.size(), _attachments);
Context::current().state().framebuffer.invalidateImplementation(*this, attachments.size(), _attachments);
}
void Framebuffer::invalidate(const std::initializer_list<InvalidationAttachment> attachments) {
@ -239,7 +239,7 @@ void Framebuffer::invalidate(const Containers::ArrayView<const InvalidationAttac
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
(this->*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<InvalidationAttachment> attachments, const Range2Di& rectangle) {
@ -249,173 +249,173 @@ void Framebuffer::invalidate(const std::initializer_list<InvalidationAttachment>
#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

26
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
};

26
src/Magnum/GL/Implementation/BufferState.h

@ -64,24 +64,24 @@ struct BufferState {
void(*bindRangesImplementation)(Buffer::Target, UnsignedInt, Containers::ArrayView<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>>);
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<const void>, Buffer::StorageFlags);
void(*storageImplementation)(Buffer&, Containers::ArrayView<const void>, 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 */

55
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*);

20
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))

9
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&);
};
}}}

2
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

9
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 */

94
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<AbstractTexture* const>);
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))

17
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<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>>);
void(TransformFeedback::*attachBasesImplementation)(GLuint, Containers::ArrayView<Buffer* const>);
void(*createImplementation)(TransformFeedback&);
void(*attachRangeImplementation)(TransformFeedback&, GLuint, Buffer&, GLintptr, GLsizeiptr);
void(*attachBaseImplementation)(TransformFeedback&, GLuint, Buffer&);
void(*attachRangesImplementation)(TransformFeedback&, GLuint, Containers::ArrayView<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>>);
void(*attachBasesImplementation)(TransformFeedback&, GLuint, Containers::ArrayView<Buffer* const>);
};
}}}

218
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<const UnsignedInt>& 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<const UnsignedInt>& counts,
}
}
(this->*state.unbindImplementation)();
state.unbindImplementation(*this);
}
#ifdef MAGNUM_TARGET_GLES
@ -483,7 +483,7 @@ void Mesh::drawInternal(const Containers::ArrayView<const UnsignedInt>& 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<const UnsignedInt>& 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<AttributeLayout>),
"attribute storage buffer size too small");
new(&_attributes) std::vector<AttributeLayout>;
_constructed = true;
new(&self._attributes) std::vector<AttributeLayout>;
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<Buffer>),
"attribute storage buffer size too small");
new(&_attributes) std::vector<Buffer>;
_constructed = true;
new(&self._attributes) std::vector<Buffer>;
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<Buffer>),
"attribute storage buffer size too small");
new(&_attributes) std::vector<Buffer>;
_constructed = true;
new(&self._attributes) std::vector<Buffer>;
self._constructed = true;
}
#endif
void Mesh::moveConstructImplementationDefault(Mesh&& other) {
new(&_attributes) std::vector<AttributeLayout>{std::move(*reinterpret_cast<std::vector<AttributeLayout>*>(&other._attributes))};
_constructed = true;
void Mesh::moveConstructImplementationDefault(Mesh& self, Mesh&& other) {
new(&self._attributes) std::vector<AttributeLayout>{std::move(*reinterpret_cast<std::vector<AttributeLayout>*>(&other._attributes))};
self._constructed = true;
}
void Mesh::moveConstructImplementationVAO(Mesh&& other) {
new(&_attributes) std::vector<Buffer>{std::move(*reinterpret_cast<std::vector<Buffer>*>(&other._attributes))};
_constructed = true;
void Mesh::moveConstructImplementationVAO(Mesh& self, Mesh&& other) {
new(&self._attributes) std::vector<Buffer>{std::move(*reinterpret_cast<std::vector<Buffer>*>(&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<std::vector<AttributeLayout>*>(&_attributes),
void Mesh::moveAssignImplementationDefault(Mesh& self, Mesh&& other) {
if(self._constructed && other._constructed)
std::swap(*reinterpret_cast<std::vector<AttributeLayout>*>(&self._attributes),
*reinterpret_cast<std::vector<AttributeLayout>*>(&other._attributes));
else if(_constructed && !other._constructed) {
else if(self._constructed && !other._constructed) {
other._constructed = true;
new(&other._attributes) std::vector<AttributeLayout>{std::move(*reinterpret_cast<std::vector<AttributeLayout>*>(&_attributes))};
} else if(!_constructed && other._constructed) {
_constructed = true;
new(&_attributes) std::vector<AttributeLayout>{std::move(*reinterpret_cast<std::vector<AttributeLayout>*>(&other._attributes))};
new(&other._attributes) std::vector<AttributeLayout>{std::move(*reinterpret_cast<std::vector<AttributeLayout>*>(&self._attributes))};
} else if(!self._constructed && other._constructed) {
self._constructed = true;
new(&self._attributes) std::vector<AttributeLayout>{std::move(*reinterpret_cast<std::vector<AttributeLayout>*>(&other._attributes))};
}
}
void Mesh::moveAssignImplementationVAO(Mesh&& other) {
if(_constructed && other._constructed)
std::swap(*reinterpret_cast<std::vector<Buffer>*>(&_attributes),
void Mesh::moveAssignImplementationVAO(Mesh& self, Mesh&& other) {
if(self._constructed && other._constructed)
std::swap(*reinterpret_cast<std::vector<Buffer>*>(&self._attributes),
*reinterpret_cast<std::vector<Buffer>*>(&other._attributes));
else if(_constructed && !other._constructed) {
else if(self._constructed && !other._constructed) {
other._constructed = true;
new(&other._attributes) std::vector<Buffer>{std::move(*reinterpret_cast<std::vector<Buffer>*>(&_attributes))};
} else if(!_constructed && other._constructed) {
_constructed = true;
new(&_attributes) std::vector<Buffer>{std::move(*reinterpret_cast<std::vector<Buffer>*>(&other._attributes))};
new(&other._attributes) std::vector<Buffer>{std::move(*reinterpret_cast<std::vector<Buffer>*>(&self._attributes))};
} else if(!self._constructed && other._constructed) {
self._constructed = true;
new(&self._attributes) std::vector<Buffer>{std::move(*reinterpret_cast<std::vector<Buffer>*>(&other._attributes))};
}
}
void Mesh::destroyImplementationDefault(bool) {
reinterpret_cast<std::vector<AttributeLayout>*>(&_attributes)->~vector();
void Mesh::destroyImplementationDefault(Mesh& self, bool) {
reinterpret_cast<std::vector<AttributeLayout>*>(&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<std::vector<Buffer>*>(&_attributes)->~vector();
reinterpret_cast<std::vector<Buffer>*>(&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<std::vector<AttributeLayout>*>(&_attributes)->push_back(std::move(attribute));
reinterpret_cast<std::vector<AttributeLayout>*>(&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<std::vector<AttributeLayout>*>(&_attributes);
auto& attributes = *reinterpret_cast<std::vector<AttributeLayout>*>(&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<std::vector<Buffer>*>(&_attributes)->emplace_back(std::move(buffer));
reinterpret_cast<std::vector<Buffer>*>(&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<std::vector<AttributeLayout>*>(&_attributes))
vertexAttribPointer(attribute);
for(AttributeLayout& attribute: *reinterpret_cast<std::vector<AttributeLayout>*>(&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<std::vector<AttributeLayout>*>(&_attributes)) {
void Mesh::unbindImplementationDefault(Mesh& self) {
for(const AttributeLayout& attribute: *reinterpret_cast<std::vector<AttributeLayout>*>(&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))

58
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))

40
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

16
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();

10
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

4
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);

54
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<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> 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<Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> 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<Buffer* const> 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<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
bindInternal();
void TransformFeedback::attachImplementationFallback(TransformFeedback& self, const GLuint firstIndex, Containers::ArrayView<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> 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<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
void TransformFeedback::attachImplementationDSA(TransformFeedback& self, const GLuint firstIndex, Containers::ArrayView<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> 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<Buffer* const> buffers) {
bindInternal();
void TransformFeedback::attachImplementationFallback(TransformFeedback& self, const GLuint firstIndex, Containers::ArrayView<Buffer* const> 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<Buffer* const> buffers) {
void TransformFeedback::attachImplementationDSA(TransformFeedback& self, const GLuint firstIndex, Containers::ArrayView<Buffer* const> 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

20
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<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> buffers);
void MAGNUM_GL_LOCAL attachImplementationFallback(GLuint firstIndex, Containers::ArrayView<Buffer* const> buffers);
static void MAGNUM_GL_LOCAL attachImplementationFallback(TransformFeedback& self, GLuint firstIndex, Containers::ArrayView<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> buffers);
static void MAGNUM_GL_LOCAL attachImplementationFallback(TransformFeedback& self, GLuint firstIndex, Containers::ArrayView<Buffer* const> buffers);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint firstIndex, Containers::ArrayView<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> buffers);
void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint firstIndex, Containers::ArrayView<Buffer* const> buffers);
static void MAGNUM_GL_LOCAL attachImplementationDSA(TransformFeedback& self, GLuint firstIndex, Containers::ArrayView<const Containers::Triple<Buffer*, GLintptr, GLsizeiptr>> buffers);
static void MAGNUM_GL_LOCAL attachImplementationDSA(TransformFeedback& self, GLuint firstIndex, Containers::ArrayView<Buffer* const> buffers);
#endif
GLuint _id;

Loading…
Cancel
Save