Browse Source

First-class WebGL support, part 3: reduced buffer functionality.

pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
af9ef80c91
  1. 74
      src/Magnum/Buffer.cpp
  2. 220
      src/Magnum/Buffer.h
  3. 1
      src/Magnum/BufferImage.h
  4. 11
      src/Magnum/Implementation/BufferState.cpp
  5. 6
      src/Magnum/Implementation/BufferState.h

74
src/Magnum/Buffer.cpp

@ -53,6 +53,7 @@ Int Buffer::minMapAlignment() {
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_WEBGL
Int Buffer::maxAtomicCounterBindings() { Int Buffer::maxAtomicCounterBindings() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shader_atomic_counters>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shader_atomic_counters>())
@ -84,36 +85,39 @@ Int Buffer::maxShaderStorageBindings() {
return value; return value;
} }
#endif
Int Buffer::shaderStorageOffsetAlignment() { Int Buffer::uniformOffsetAlignment() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shader_storage_buffer_object>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::uniform_buffer_object>())
#else
if(!Context::current()->isVersionSupported(Version::GLES310))
#endif
return 1; return 1;
#endif
GLint& value = Context::current()->state().buffer->shaderStorageOffsetAlignment; GLint& value = Context::current()->state().buffer->uniformOffsetAlignment;
if(value == 0) if(value == 0)
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &value); glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &value);
return value; return value;
} }
Int Buffer::uniformOffsetAlignment() { #ifndef MAGNUM_TARGET_WEBGL
Int Buffer::shaderStorageOffsetAlignment() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::uniform_buffer_object>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shader_storage_buffer_object>())
return 1; #else
if(!Context::current()->isVersionSupported(Version::GLES310))
#endif #endif
return 1;
GLint& value = Context::current()->state().buffer->uniformOffsetAlignment; GLint& value = Context::current()->state().buffer->shaderStorageOffsetAlignment;
if(value == 0) if(value == 0)
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &value); glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &value);
return value; return value;
} }
#endif
Int Buffer::maxUniformBindings() { Int Buffer::maxUniformBindings() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -131,14 +135,22 @@ Int Buffer::maxUniformBindings() {
void Buffer::unbind(const Target target, const UnsignedInt index) { void Buffer::unbind(const Target target, const UnsignedInt index) {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform); CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform);
#else
CORRADE_INTERNAL_ASSERT(target == Target::Uniform);
#endif
#endif #endif
glBindBufferBase(GLenum(target), index, 0); glBindBufferBase(GLenum(target), index, 0);
} }
void Buffer::unbind(const Target target, const UnsignedInt firstIndex, const std::size_t count) { void Buffer::unbind(const Target target, const UnsignedInt firstIndex, const std::size_t count) {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform); CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform);
#else
CORRADE_INTERNAL_ASSERT(target == Target::Uniform);
#endif
#endif #endif
Context::current()->state().buffer->bindBasesImplementation(target, firstIndex, {nullptr, count}); Context::current()->state().buffer->bindBasesImplementation(target, firstIndex, {nullptr, count});
} }
@ -146,7 +158,11 @@ void Buffer::unbind(const Target target, const UnsignedInt firstIndex, const std
/** @todoc const std::initializer_list makes Doxygen grumpy */ /** @todoc const std::initializer_list makes Doxygen grumpy */
void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) { void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER); CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER);
#else
CORRADE_INTERNAL_ASSERT(target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER);
#endif
#endif #endif
Context::current()->state().buffer->bindRangesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); Context::current()->state().buffer->bindRangesImplementation(target, firstIndex, {buffers.begin(), buffers.size()});
} }
@ -154,7 +170,11 @@ void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initia
/** @todoc const std::initializer_list makes Doxygen grumpy */ /** @todoc const std::initializer_list makes Doxygen grumpy */
void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) { void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER); CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER);
#else
CORRADE_INTERNAL_ASSERT(target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER);
#endif
#endif #endif
Context::current()->state().buffer->bindBasesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); Context::current()->state().buffer->bindBasesImplementation(target, firstIndex, {buffers.begin(), buffers.size()});
} }
@ -266,7 +286,11 @@ auto Buffer::bindSomewhereInternal(const TargetHint hint) -> TargetHint {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer& Buffer::bind(const Target target, const UnsignedInt index, const GLintptr offset, const GLsizeiptr size) { Buffer& Buffer::bind(const Target target, const UnsignedInt index, const GLintptr offset, const GLsizeiptr size) {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER); CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER);
#else
CORRADE_INTERNAL_ASSERT(target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER);
#endif
#endif #endif
glBindBufferRange(GLenum(target), index, _id, offset, size); glBindBufferRange(GLenum(target), index, _id, offset, size);
return *this; return *this;
@ -274,7 +298,11 @@ Buffer& Buffer::bind(const Target target, const UnsignedInt index, const GLintpt
Buffer& Buffer::bind(const Target target, const UnsignedInt index) { Buffer& Buffer::bind(const Target target, const UnsignedInt index) {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER); CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER);
#else
CORRADE_INTERNAL_ASSERT(target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER);
#endif
#endif #endif
glBindBufferBase(GLenum(target), index, _id); glBindBufferBase(GLenum(target), index, _id);
return *this; return *this;
@ -311,6 +339,7 @@ Buffer& Buffer::invalidateSubData(const GLintptr offset, const GLsizeiptr length
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_WEBGL
void* Buffer::map(const MapAccess access) { void* Buffer::map(const MapAccess access) {
return (this->*Context::current()->state().buffer->mapImplementation)(access); return (this->*Context::current()->state().buffer->mapImplementation)(access);
} }
@ -351,6 +380,7 @@ void Buffer::unmapSub() {
#endif #endif
} }
#endif #endif
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void Buffer::subDataInternal(GLintptr offset, GLsizeiptr size, GLvoid* data) { void Buffer::subDataInternal(GLintptr offset, GLsizeiptr size, GLvoid* data) {
@ -508,10 +538,11 @@ void Buffer::invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length)
} }
#endif #endif
#ifndef MAGNUM_TARGET_WEBGL
void* Buffer::mapImplementationDefault(MapAccess access) { void* Buffer::mapImplementationDefault(MapAccess access) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
return glMapBuffer(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); return glMapBuffer(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access));
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #elif !defined(CORRADE_TARGET_NACL)
return glMapBufferOES(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); return glMapBufferOES(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access));
#else #else
static_cast<void>(access); static_cast<void>(access);
@ -533,7 +564,7 @@ void* Buffer::mapImplementationDSAEXT(MapAccess access) {
void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access) { void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
return glMapBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); return glMapBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access));
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #elif !defined(CORRADE_TARGET_NACL)
return glMapBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); return glMapBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access));
#else #else
static_cast<void>(offset); static_cast<void>(offset);
@ -557,7 +588,7 @@ void* Buffer::mapRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr length, M
void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length) { void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glFlushMappedBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length); glFlushMappedBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length);
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #elif !defined(CORRADE_TARGET_NACL)
glFlushMappedBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length); glFlushMappedBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length);
#else #else
static_cast<void>(offset); static_cast<void>(offset);
@ -580,7 +611,7 @@ void Buffer::flushMappedRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr le
bool Buffer::unmapImplementationDefault() { bool Buffer::unmapImplementationDefault() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
return glUnmapBuffer(GLenum(bindSomewhereInternal(_targetHint))); return glUnmapBuffer(GLenum(bindSomewhereInternal(_targetHint)));
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #elif !defined(CORRADE_TARGET_NACL)
return glUnmapBufferOES(GLenum(bindSomewhereInternal(_targetHint))); return glUnmapBufferOES(GLenum(bindSomewhereInternal(_targetHint)));
#else #else
CORRADE_ASSERT_UNREACHABLE(); CORRADE_ASSERT_UNREACHABLE();
@ -597,6 +628,7 @@ bool Buffer::unmapImplementationDSAEXT() {
return glUnmapNamedBufferEXT(_id); return glUnmapNamedBufferEXT(_id);
} }
#endif #endif
#endif
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
Debug operator<<(Debug debug, Buffer::TargetHint value) { Debug operator<<(Debug debug, Buffer::TargetHint value) {
@ -604,18 +636,24 @@ Debug operator<<(Debug debug, Buffer::TargetHint value) {
#define _c(value) case Buffer::TargetHint::value: return debug << "Buffer::TargetHint::" #value; #define _c(value) case Buffer::TargetHint::value: return debug << "Buffer::TargetHint::" #value;
_c(Array) _c(Array)
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_WEBGL
_c(AtomicCounter) _c(AtomicCounter)
#endif
_c(CopyRead) _c(CopyRead)
_c(CopyWrite) _c(CopyWrite)
#ifndef MAGNUM_TARGET_WEBGL
_c(DispatchIndirect) _c(DispatchIndirect)
_c(DrawIndirect) _c(DrawIndirect)
#endif #endif
#endif
_c(ElementArray) _c(ElementArray)
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
_c(PixelPack) _c(PixelPack)
_c(PixelUnpack) _c(PixelUnpack)
#ifndef MAGNUM_TARGET_WEBGL
_c(ShaderStorage) _c(ShaderStorage)
#endif #endif
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
_c(Texture) _c(Texture)
#endif #endif
@ -636,8 +674,10 @@ Debug operator<<(Debug debug, Buffer::Target value) {
switch(value) { switch(value) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#define _c(value) case Buffer::Target::value: return debug << "Buffer::Target::" #value; #define _c(value) case Buffer::Target::value: return debug << "Buffer::Target::" #value;
#ifndef MAGNUM_TARGET_WEBGL
_c(AtomicCounter) _c(AtomicCounter)
_c(ShaderStorage) _c(ShaderStorage)
#endif
_c(Uniform) _c(Uniform)
#undef _c #undef _c
#endif #endif
@ -647,9 +687,11 @@ Debug operator<<(Debug debug, Buffer::Target value) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case Buffer::Target::CopyRead: case Buffer::Target::CopyRead:
case Buffer::Target::CopyWrite: case Buffer::Target::CopyWrite:
#ifndef MAGNUM_TARGET_WEBGL
case Buffer::Target::DispatchIndirect: case Buffer::Target::DispatchIndirect:
case Buffer::Target::DrawIndirect: case Buffer::Target::DrawIndirect:
#endif #endif
#endif
case Buffer::Target::ElementArray: case Buffer::Target::ElementArray:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case Buffer::Target::PixelPack: case Buffer::Target::PixelPack:

220
src/Magnum/Buffer.h

@ -60,6 +60,8 @@ enum class BufferUsage: GLenum {
* drawing. * drawing.
* @requires_gles30 Only @ref BufferUsage::StreamDraw is available in * @requires_gles30 Only @ref BufferUsage::StreamDraw is available in
* OpenGL ES 2.0. * OpenGL ES 2.0.
* @requires_webgl20 Only @ref BufferUsage::StreamDraw is available in
* WebGL 1.0.
*/ */
StreamRead = GL_STREAM_READ, StreamRead = GL_STREAM_READ,
@ -68,6 +70,8 @@ enum class BufferUsage: GLenum {
* drawing or copying to other buffers. * drawing or copying to other buffers.
* @requires_gles30 Only @ref BufferUsage::StreamDraw is available in * @requires_gles30 Only @ref BufferUsage::StreamDraw is available in
* OpenGL ES 2.0. * OpenGL ES 2.0.
* @requires_webgl20 Only @ref BufferUsage::StreamDraw is available in
* WebGL 1.0.
*/ */
StreamCopy = GL_STREAM_COPY, StreamCopy = GL_STREAM_COPY,
#endif #endif
@ -81,6 +85,8 @@ enum class BufferUsage: GLenum {
* application. * application.
* @requires_gles30 Only @ref BufferUsage::StaticDraw is available in * @requires_gles30 Only @ref BufferUsage::StaticDraw is available in
* OpenGL ES 2.0. * OpenGL ES 2.0.
* @requires_webgl20 Only @ref BufferUsage::StaticDraw is available in
* WebGL 1.0.
*/ */
StaticRead = GL_STATIC_READ, StaticRead = GL_STATIC_READ,
@ -89,6 +95,8 @@ enum class BufferUsage: GLenum {
* drawing or copying to other buffers. * drawing or copying to other buffers.
* @requires_gles30 Only @ref BufferUsage::StaticDraw is available in * @requires_gles30 Only @ref BufferUsage::StaticDraw is available in
* OpenGL ES 2.0. * OpenGL ES 2.0.
* @requires_webgl20 Only @ref BufferUsage::StaticDraw is available in
* WebGL 1.0.
*/ */
StaticCopy = GL_STATIC_COPY, StaticCopy = GL_STATIC_COPY,
#endif #endif
@ -105,6 +113,8 @@ enum class BufferUsage: GLenum {
* from the application. * from the application.
* @requires_gles30 Only @ref BufferUsage::DynamicDraw is available in * @requires_gles30 Only @ref BufferUsage::DynamicDraw is available in
* OpenGL ES 2.0. * OpenGL ES 2.0.
* @requires_webgl20 Only @ref BufferUsage::DynamicDraw is available in
* WebGL 1.0.
*/ */
DynamicRead = GL_DYNAMIC_READ, DynamicRead = GL_DYNAMIC_READ,
@ -113,6 +123,8 @@ enum class BufferUsage: GLenum {
* drawing or copying to other images. * drawing or copying to other images.
* @requires_gles30 Only @ref BufferUsage::DynamicDraw is available in * @requires_gles30 Only @ref BufferUsage::DynamicDraw is available in
* OpenGL ES 2.0. * OpenGL ES 2.0.
* @requires_webgl20 Only @ref BufferUsage::DynamicDraw is available in
* WebGL 1.0.
*/ */
DynamicCopy = GL_DYNAMIC_COPY DynamicCopy = GL_DYNAMIC_COPY
#endif #endif
@ -199,8 +211,8 @@ rebinding. Buffer limits and implementation-defined values (such as
@ref maxUniformBindings()) are cached, so repeated queries don't result in @ref maxUniformBindings()) are cached, so repeated queries don't result in
repeated @fn_gl{Get} calls. repeated @fn_gl{Get} calls.
If on desktop GL and either @extension{ARB,direct_state_access} (part of OpenGL If either @extension{ARB,direct_state_access} (part of OpenGL 4.5) or
4.5) or @extension{EXT,direct_state_access} is available, functions @extension{EXT,direct_state_access} desktop extension is available, functions
@ref copy(), @ref size(), @ref data(), @ref subData(), @ref setData(), @ref copy(), @ref size(), @ref data(), @ref subData(), @ref setData(),
@ref setSubData(), @ref map(), @ref flushMappedRange() and @ref unmap() use DSA @ref setSubData(), @ref map(), @ref flushMappedRange() and @ref unmap() use DSA
functions to avoid unnecessary calls to @fn_gl{BindBuffer}. See their functions to avoid unnecessary calls to @fn_gl{BindBuffer}. See their
@ -226,19 +238,23 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
Array = GL_ARRAY_BUFFER, Array = GL_ARRAY_BUFFER,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_WEBGL
/** /**
* Used for storing atomic counters. * Used for storing atomic counters.
* @requires_gl42 Extension @extension{ARB,shader_atomic_counters} * @requires_gl42 Extension @extension{ARB,shader_atomic_counters}
* @requires_gles31 Atomic counters are not available in OpenGL ES * @requires_gles31 Atomic counters are not available in OpenGL ES
* 3.0 and older. * 3.0 and older.
* @requires_gles Atomic counters are not available in WebGL.
*/ */
AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, AtomicCounter = GL_ATOMIC_COUNTER_BUFFER,
#endif
/** /**
* Source for copies. See @ref copy(). * Source for copies. See @ref copy().
* @requires_gl31 Extension @extension{ARB,copy_buffer} * @requires_gl31 Extension @extension{ARB,copy_buffer}
* @requires_gles30 Buffer copying is not available in OpenGL ES * @requires_gles30 Buffer copying is not available in OpenGL ES
* 2.0. * 2.0.
* @requires_webgl20 Buffer copying is not available in WebGL 1.0.
*/ */
CopyRead = GL_COPY_READ_BUFFER, CopyRead = GL_COPY_READ_BUFFER,
@ -247,25 +263,30 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_gl31 Extension @extension{ARB,copy_buffer} * @requires_gl31 Extension @extension{ARB,copy_buffer}
* @requires_gles30 Buffer copying is not available in OpenGL ES * @requires_gles30 Buffer copying is not available in OpenGL ES
* 2.0. * 2.0.
* @requires_webgl20 Buffer copying is not available in WebGL 1.0.
*/ */
CopyWrite = GL_COPY_WRITE_BUFFER, CopyWrite = GL_COPY_WRITE_BUFFER,
#ifndef MAGNUM_TARGET_WEBGL
/** /**
* Indirect compute dispatch commands. * Indirect compute dispatch commands.
* @requires_gl43 Extension @extension{ARB,compute_shader} * @requires_gl43 Extension @extension{ARB,compute_shader}
* @requires_gles31 Compute shaders are not available in OpenGL ES * @requires_gles31 Compute shaders are not available in OpenGL ES
* 3.0 and older. * 3.0 and older.
* @requires_gles Compute shaders are not available in WebGL.
*/ */
DispatchIndirect = GL_DISPATCH_INDIRECT_BUFFER, DispatchIndirect = GL_DISPATCH_INDIRECT_BUFFER,
/** /**
* Used for supplying arguments for indirect drawing. * Used for supplying arguments for indirect drawing.
* @requires_gl40 Extension @extension{ARB,draw_indirect} * @requires_gl40 Extension @extension{ARB,draw_indirect}
* @requires_gles31 Indirect drawing not available in OpenGL ES 3.0 * @requires_gles31 Indirect drawing is not available in OpenGL ES
* and older. * 3.0 and older.
* @requires_gles Indirect drawing is not available in WebGL.
*/ */
DrawIndirect = GL_DRAW_INDIRECT_BUFFER, DrawIndirect = GL_DRAW_INDIRECT_BUFFER,
#endif #endif
#endif
/** Used for storing vertex indices. */ /** Used for storing vertex indices. */
ElementArray = GL_ELEMENT_ARRAY_BUFFER, ElementArray = GL_ELEMENT_ARRAY_BUFFER,
@ -275,6 +296,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* Target for pixel pack operations. * Target for pixel pack operations.
* @requires_gles30 Pixel buffer objects are not available in * @requires_gles30 Pixel buffer objects are not available in
* OpenGL ES 2.0. * OpenGL ES 2.0.
* @requires_webgl20 Pixel buffer objects are not available in
* WebGL 1.0.
*/ */
PixelPack = GL_PIXEL_PACK_BUFFER, PixelPack = GL_PIXEL_PACK_BUFFER,
@ -282,23 +305,29 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* Source for texture update operations. * Source for texture update operations.
* @requires_gles30 Pixel buffer objects are not available in * @requires_gles30 Pixel buffer objects are not available in
* OpenGL ES 2.0. * OpenGL ES 2.0.
* @requires_webgl20 Pixel buffer objects are not available in
* WebGL 1.0.
*/ */
PixelUnpack = GL_PIXEL_UNPACK_BUFFER, PixelUnpack = GL_PIXEL_UNPACK_BUFFER,
#ifndef MAGNUM_TARGET_WEBGL
/** /**
* Used for shader storage. * Used for shader storage.
* @requires_gl43 Extension @extension{ARB,shader_storage_buffer_object} * @requires_gl43 Extension @extension{ARB,shader_storage_buffer_object}
* @requires_gles31 Shader storage is not available in OpenGL ES * @requires_gles31 Shader storage is not available in OpenGL ES
* 3.0 and older. * 3.0 and older.
* @requires_gles Shader storage is not available in WebGL.
*/ */
ShaderStorage = GL_SHADER_STORAGE_BUFFER, ShaderStorage = GL_SHADER_STORAGE_BUFFER,
#endif #endif
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
/** /**
* Source for texel fetches. See @ref BufferTexture. * Source for texel fetches. See @ref BufferTexture.
* @requires_gl31 Extension @extension{ARB,texture_buffer_object} * @requires_gl31 Extension @extension{ARB,texture_buffer_object}
* @requires_gl Texture buffers are not available in OpenGL ES. * @requires_gl Texture buffers are not available in OpenGL ES or
* WebGL.
*/ */
Texture = GL_TEXTURE_BUFFER, Texture = GL_TEXTURE_BUFFER,
#endif #endif
@ -309,6 +338,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_gl30 Extension @extension{EXT,transform_feedback} * @requires_gl30 Extension @extension{EXT,transform_feedback}
* @requires_gles30 Transform feedback is not available in OpenGL * @requires_gles30 Transform feedback is not available in OpenGL
* ES 2.0. * ES 2.0.
* @requires_webgl20 Transform feedback is not available in WebGL
* 1.0.
*/ */
TransformFeedback = GL_TRANSFORM_FEEDBACK_BUFFER, TransformFeedback = GL_TRANSFORM_FEEDBACK_BUFFER,
@ -317,6 +348,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_gl31 Extension @extension{ARB,uniform_buffer_object} * @requires_gl31 Extension @extension{ARB,uniform_buffer_object}
* @requires_gles30 Uniform buffers are not available in OpenGL ES * @requires_gles30 Uniform buffers are not available in OpenGL ES
* 2.0. * 2.0.
* @requires_webgl20 Uniform buffers are not available in WebGL
* 1.0.
*/ */
Uniform = GL_UNIFORM_BUFFER Uniform = GL_UNIFORM_BUFFER
#endif #endif
@ -338,12 +371,13 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
Array = GL_ARRAY_BUFFER, Array = GL_ARRAY_BUFFER,
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
/** /**
* Atomic counter binding * Atomic counter binding
* @requires_gl42 Extension @extension{ARB,shader_atomic_counters} * @requires_gl42 Extension @extension{ARB,shader_atomic_counters}
* @requires_gles31 Atomic counters are not available in OpenGL ES * @requires_gles31 Atomic counters are not available in OpenGL ES
* 3.0 and older * 3.0 and older.
* @requires_gles Atomic counters are not available in WebGL.
*/ */
AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, AtomicCounter = GL_ATOMIC_COUNTER_BUFFER,
#endif #endif
@ -365,7 +399,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
CopyWrite = GL_COPY_WRITE_BUFFER, CopyWrite = GL_COPY_WRITE_BUFFER,
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
/** /**
* @copydoc TargetHint::DispatchIndirect * @copydoc TargetHint::DispatchIndirect
* @deprecated For @ref setTargetHint() only, use * @deprecated For @ref setTargetHint() only, use
@ -405,12 +439,13 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
#endif #endif
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
/** /**
* Shader storage binding * Shader storage binding
* @requires_gl43 Extension @extension{ARB,shader_storage_buffer_object} * @requires_gl43 Extension @extension{ARB,shader_storage_buffer_object}
* @requires_gles31 Shader storage is not available in OpenGL ES * @requires_gles31 Shader storage is not available in OpenGL ES
* 3.0 and older * 3.0 and older.
* @requires_gles Shader storage is not available in WebGL.
*/ */
ShaderStorage = GL_SHADER_STORAGE_BUFFER, ShaderStorage = GL_SHADER_STORAGE_BUFFER,
#endif #endif
@ -438,7 +473,9 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* Uniform binding * Uniform binding
* @requires_gl31 Extension @extension{ARB,uniform_buffer_object} * @requires_gl31 Extension @extension{ARB,uniform_buffer_object}
* @requires_gles30 Uniform buffers are not available in OpenGL ES * @requires_gles30 Uniform buffers are not available in OpenGL ES
* 2.0 * 2.0.
* @requires_webgl20 Uniform buffers are not available in WebGL
* 1.0.
*/ */
Uniform = GL_UNIFORM_BUFFER Uniform = GL_UNIFORM_BUFFER
#endif #endif
@ -453,12 +490,14 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
typedef CORRADE_DEPRECATED("use BufferUsage instead") BufferUsage Usage; typedef CORRADE_DEPRECATED("use BufferUsage instead") BufferUsage Usage;
#endif #endif
#ifndef MAGNUM_TARGET_WEBGL
/** /**
* @brief Memory mapping access * @brief Memory mapping access
* *
* @see @ref map(MapAccess), @ref mapSub() * @see @ref map(MapAccess), @ref mapSub()
* @requires_es_extension Extension @es_extension{OES,mapbuffer} or * @requires_es_extension Extension @es_extension{OES,mapbuffer} or
* @es_extension{CHROMIUM,map_sub} * @es_extension{CHROMIUM,map_sub}
* @requires_gles Buffer mapping is not available in WebGL.
* @deprecated_gl Prefer to use @ref map(GLintptr, GLsizeiptr, MapFlags) * @deprecated_gl Prefer to use @ref map(GLintptr, GLsizeiptr, MapFlags)
* instead, as it has more complete set of features. * instead, as it has more complete set of features.
*/ */
@ -493,7 +532,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @see @ref MapFlags, @ref map(GLintptr, GLsizeiptr, MapFlags) * @see @ref MapFlags, @ref map(GLintptr, GLsizeiptr, MapFlags)
* @requires_gl30 Extension @extension{ARB,map_buffer_range} * @requires_gl30 Extension @extension{ARB,map_buffer_range}
* @requires_gles30 Extension @es_extension{EXT,map_buffer_range} in * @requires_gles30 Extension @es_extension{EXT,map_buffer_range} in
* OpenGL ES 2.0 * OpenGL ES 2.0.
* @requires_gles Buffer mapping is not available in WebGL.
*/ */
enum class MapFlag: GLbitfield { enum class MapFlag: GLbitfield {
/** Map buffer for reading. */ /** Map buffer for reading. */
@ -560,9 +600,11 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @see @ref map(GLintptr, GLsizeiptr, MapFlags) * @see @ref map(GLintptr, GLsizeiptr, MapFlags)
* @requires_gl30 Extension @extension{ARB,map_buffer_range} * @requires_gl30 Extension @extension{ARB,map_buffer_range}
* @requires_gles30 Extension @es_extension{EXT,map_buffer_range} in * @requires_gles30 Extension @es_extension{EXT,map_buffer_range} in
* OpenGL ES 2.0 * OpenGL ES 2.0.
* @requires_gles Buffer mapping is not available in WebGL.
*/ */
typedef Containers::EnumSet<MapFlag> MapFlags; typedef Containers::EnumSet<MapFlag> MapFlags;
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
/** /**
@ -572,12 +614,14 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* OpenGL calls. If extension @extension{ARB,map_buffer_alignment} * OpenGL calls. If extension @extension{ARB,map_buffer_alignment}
* (part of OpenGL 4.2) is not available, returns `1`. * (part of OpenGL 4.2) is not available, returns `1`.
* @see @ref map(), @fn_gl{Get} with @def_gl{MIN_MAP_BUFFER_ALIGNMENT} * @see @ref map(), @fn_gl{Get} with @def_gl{MIN_MAP_BUFFER_ALIGNMENT}
* @requires_gl No minimal value is specified for OpenGL ES. * @requires_gl No minimal value is specified for OpenGL ES. Buffer
* mapping is not available in WebGL.
*/ */
static Int minMapAlignment(); static Int minMapAlignment();
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_WEBGL
/** /**
* @brief Max supported atomic counter buffer binding count * @brief Max supported atomic counter buffer binding count
* *
@ -586,7 +630,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* (part of OpenGL 4.2) nor OpenGL ES 3.1 is available, returns `0`. * (part of OpenGL 4.2) nor OpenGL ES 3.1 is available, returns `0`.
* @see @ref bind(), @ref unbind(), @fn_gl{Get} with * @see @ref bind(), @ref unbind(), @fn_gl{Get} with
* @def_gl{MAX_ATOMIC_COUNTER_BUFFER_BINDINGS} * @def_gl{MAX_ATOMIC_COUNTER_BUFFER_BINDINGS}
* @requires_gles30 Not defined in OpenGL ES 2.0 * @requires_gles30 Not defined in OpenGL ES 2.0.
* @requires_gles Atomic counters are not available in WebGL.
*/ */
static Int maxAtomicCounterBindings(); static Int maxAtomicCounterBindings();
@ -598,9 +643,11 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `0`. * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `0`.
* @see @ref bind(), @ref unbind(), @fn_gl{Get} with * @see @ref bind(), @ref unbind(), @fn_gl{Get} with
* @def_gl{MAX_SHADER_STORAGE_BUFFER_BINDINGS} * @def_gl{MAX_SHADER_STORAGE_BUFFER_BINDINGS}
* @requires_gles30 Not defined in OpenGL ES 2.0 * @requires_gles30 Not defined in OpenGL ES 2.0.
* @requires_gles Shader storage is not available in WebGL.
*/ */
static Int maxShaderStorageBindings(); static Int maxShaderStorageBindings();
#endif
/** /**
* @brief Alignment of uniform buffer binding offset * @brief Alignment of uniform buffer binding offset
@ -609,10 +656,12 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* OpenGL calls. If extension @extension{ARB,uniform_buffer_object} * OpenGL calls. If extension @extension{ARB,uniform_buffer_object}
* (part of OpenGL 3.1) is not available, returns `1`. * (part of OpenGL 3.1) is not available, returns `1`.
* @see @ref bind(), @fn_gl{Get} with @def_gl{UNIFORM_BUFFER_OFFSET_ALIGNMENT} * @see @ref bind(), @fn_gl{Get} with @def_gl{UNIFORM_BUFFER_OFFSET_ALIGNMENT}
* @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0 * @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0.
* @requires_webgl20 Uniform buffers are not available in WebGL 1.0.
*/ */
static Int uniformOffsetAlignment(); static Int uniformOffsetAlignment();
#ifndef MAGNUM_TARGET_WEBGL
/** /**
* @brief Alignment of shader storage buffer binding offset * @brief Alignment of shader storage buffer binding offset
* *
@ -620,9 +669,11 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* OpenGL calls. If neither extension @extension{ARB,shader_storage_buffer_object} * OpenGL calls. If neither extension @extension{ARB,shader_storage_buffer_object}
* (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `1`. * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `1`.
* @see @ref bind(), @fn_gl{Get} with @def_gl{SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT} * @see @ref bind(), @fn_gl{Get} with @def_gl{SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT}
* @requires_gles30 Not defined in OpenGL ES 2.0 * @requires_gles30 Not defined in OpenGL ES 2.0.
* @requires_gles Shader storage is not available in WebGL.
*/ */
static Int shaderStorageOffsetAlignment(); static Int shaderStorageOffsetAlignment();
#endif
/** /**
* @brief Max supported uniform buffer binding count * @brief Max supported uniform buffer binding count
@ -632,7 +683,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* (part of OpenGL 3.1) is not available, returns `0`. * (part of OpenGL 3.1) is not available, returns `0`.
* @see @ref bind(), @ref unbind(), @fn_gl{Get} with * @see @ref bind(), @ref unbind(), @fn_gl{Get} with
* @def_gl{MAX_UNIFORM_BUFFER_BINDINGS} * @def_gl{MAX_UNIFORM_BUFFER_BINDINGS}
* @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0 * @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0.
* @requires_webgl20 Uniform buffers are not available in WebGL 1.0.
*/ */
static Int maxUniformBindings(); static Int maxUniformBindings();
@ -652,6 +704,9 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_gles30 No form of indexed buffer binding is available in * @requires_gles30 No form of indexed buffer binding is available in
* OpenGL ES 2.0, see particular @ref Target values for version * OpenGL ES 2.0, see particular @ref Target values for version
* requirements. * requirements.
* @requires_webgl20 No form of indexed buffer binding is available in
* WebGL 1.0, see particular @ref Target values for version
* requirements.
*/ */
static void unbind(Target target, UnsignedInt index); static void unbind(Target target, UnsignedInt index);
@ -675,6 +730,9 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_gles30 No form of indexed buffer binding is available in * @requires_gles30 No form of indexed buffer binding is available in
* OpenGL ES 2.0, see particular @ref Target values for version * OpenGL ES 2.0, see particular @ref Target values for version
* requirements. * requirements.
* @requires_webgl20 No form of indexed buffer binding is available in
* WebGL 1.0, see particular @ref Target values for version
* requirements.
*/ */
static void unbind(Target target, UnsignedInt firstIndex, std::size_t count); static void unbind(Target target, UnsignedInt firstIndex, std::size_t count);
@ -705,6 +763,9 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_gles30 No form of indexed buffer binding is available in * @requires_gles30 No form of indexed buffer binding is available in
* OpenGL ES 2.0, see particular @ref Target values for version * OpenGL ES 2.0, see particular @ref Target values for version
* requirements. * requirements.
* @requires_webgl20 No form of indexed buffer binding is available in
* WebGL 1.0, see particular @ref Target values for version
* requirements.
*/ */
static void bind(Target target, UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers); static void bind(Target target, UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers);
@ -731,6 +792,9 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_gles30 No form of indexed buffer binding is available in * @requires_gles30 No form of indexed buffer binding is available in
* OpenGL ES 2.0, see particular @ref Target values for version * OpenGL ES 2.0, see particular @ref Target values for version
* requirements. * requirements.
* @requires_webgl20 No form of indexed buffer binding is available in
* WebGL 1.0, see particular @ref Target values for version
* requirements.
*/ */
static void bind(Target target, UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers); static void bind(Target target, UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers);
@ -742,15 +806,16 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @param writeOffset Offset in the write buffer * @param writeOffset Offset in the write buffer
* @param size Data size * @param size Data size
* *
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, * nor @extension{EXT,direct_state_access} desktop extension is
* @p read buffer is bound for reading and @p write buffer is bound for * available, @p read buffer is bound for reading and @p write buffer
* writing before the copy is performed (if not already). * is bound for writing before the copy is performed (if not already).
* @see @fn_gl2{CopyNamedBufferSubData,CopyBufferSubData}, * @see @fn_gl2{CopyNamedBufferSubData,CopyBufferSubData},
* @fn_gl_extension{NamedCopyBufferSubData,EXT,direct_state_access}, * @fn_gl_extension{NamedCopyBufferSubData,EXT,direct_state_access},
* eventually @fn_gl{BindBuffer} and @fn_gl{CopyBufferSubData} * eventually @fn_gl{BindBuffer} and @fn_gl{CopyBufferSubData}
* @requires_gl31 Extension @extension{ARB,copy_buffer} * @requires_gl31 Extension @extension{ARB,copy_buffer}
* @requires_gles30 Buffer copying is not available in OpenGL ES 2.0. * @requires_gles30 Buffer copying is not available in OpenGL ES 2.0.
* @requires_webgl20 Buffer copying is not available in WebGL 1.0.
*/ */
static void copy(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); static void copy(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
#endif #endif
@ -761,7 +826,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* information * information
* *
* Creates new OpenGL buffer object. If @extension{ARB,direct_state_access} * Creates new OpenGL buffer object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not supported, the buffer is created on * (part of OpenGL 4.5) is not available, the buffer is created on
* first use. * first use.
* @see @fn_gl{CreateBuffers}, eventually @fn_gl{GenBuffers} * @see @fn_gl{CreateBuffers}, eventually @fn_gl{GenBuffers}
*/ */
@ -842,12 +907,12 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @brief Set target hint * @brief Set target hint
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, * nor @extension{EXT,direct_state_access} desktop extension is
* the buffer needs to be internally bound to some target before any * available, the buffer needs to be internally bound to some target
* operation. You can specify target which will always be used when * before any operation. You can specify target which will always be
* binding the buffer internally, possibly saving some calls to * used when binding the buffer internally, possibly saving some calls
* @fn_gl{BindBuffer}. Default target hint is @ref Target::Array. * to @fn_gl{BindBuffer}. Default target hint is @ref Target::Array.
* @see @ref setData(), @ref setSubData() * @see @ref setData(), @ref setSubData()
* @todo Target::ElementArray cannot be used when no VAO is bound - * @todo Target::ElementArray cannot be used when no VAO is bound -
* http://www.opengl.org/wiki/Vertex_Specification#Index_buffers * http://www.opengl.org/wiki/Vertex_Specification#Index_buffers
@ -890,6 +955,9 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_gles30 No form of indexed buffer binding is available in * @requires_gles30 No form of indexed buffer binding is available in
* OpenGL ES 2.0, see particular @ref Target values for version * OpenGL ES 2.0, see particular @ref Target values for version
* requirements. * requirements.
* @requires_webgl20 No form of indexed buffer binding is available in
* WebGL 1.0, see particular @ref Target values for version
* requirements.
* @todo State tracking for indexed binding * @todo State tracking for indexed binding
*/ */
Buffer& bind(Target target, UnsignedInt index, GLintptr offset, GLsizeiptr size); Buffer& bind(Target target, UnsignedInt index, GLintptr offset, GLsizeiptr size);
@ -912,6 +980,9 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_gles30 No form of indexed buffer binding is available in * @requires_gles30 No form of indexed buffer binding is available in
* OpenGL ES 2.0, see particular @ref Target values for version * OpenGL ES 2.0, see particular @ref Target values for version
* requirements. * requirements.
* @requires_webgl20 No form of indexed buffer binding is available in
* WebGL 1.0, see particular @ref Target values for version
* requirements.
*/ */
Buffer& bind(Target target, UnsignedInt index); Buffer& bind(Target target, UnsignedInt index);
#endif #endif
@ -919,10 +990,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
/** /**
* @brief Buffer size * @brief Buffer size
* *
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, * nor @extension{EXT,direct_state_access} desktop extension is
* the buffer is bound to hinted target before the operation (if not * available, the buffer is bound to hinted target before the operation
* already). * (if not already).
* @see @ref setTargetHint(), @fn_gl2{GetNamedBufferParameter,GetBufferParameter}, * @see @ref setTargetHint(), @fn_gl2{GetNamedBufferParameter,GetBufferParameter},
* @fn_gl_extension{GetNamedBufferParameter,EXT,direct_state_access}, * @fn_gl_extension{GetNamedBufferParameter,EXT,direct_state_access},
* eventually @fn_gl{BindBuffer} and @fn_gl{GetBufferParameter} * eventually @fn_gl{BindBuffer} and @fn_gl{GetBufferParameter}
@ -944,8 +1015,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* with @def_gl{BUFFER_SIZE}, then @fn_gl2{GetNamedBufferSubData,GetBufferSubData}, * with @def_gl{BUFFER_SIZE}, then @fn_gl2{GetNamedBufferSubData,GetBufferSubData},
* @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access}, * @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access},
* eventually @fn_gl{GetBufferSubData} * eventually @fn_gl{GetBufferSubData}
* @requires_gl Buffer data queries are not available in OpenGL ES. Use * @requires_gl Buffer data queries are not available in OpenGL ES and
* @ref map() instead. * WebGL. Use @ref map() in OpenGL ES instead.
*/ */
template<class T = char> Containers::Array<T> data(); template<class T = char> Containers::Array<T> data();
@ -962,8 +1033,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @fn_gl2{GetNamedBufferSubData,GetBufferSubData}, * @fn_gl2{GetNamedBufferSubData,GetBufferSubData},
* @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access}, * @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access},
* eventually @fn_gl{BindBuffer} and @fn_gl{GetBufferSubData} * eventually @fn_gl{BindBuffer} and @fn_gl{GetBufferSubData}
* @requires_gl Buffer data queries are not available in OpenGL ES. Use * @requires_gl Buffer data queries are not available in OpenGL ES and
* @ref map() instead. * WebGL. Use @ref map() in OpenGL ES instead.
*/ */
template<class T = char> Containers::Array<T> subData(GLintptr offset, GLsizeiptr size); template<class T = char> Containers::Array<T> subData(GLintptr offset, GLsizeiptr size);
#endif #endif
@ -974,10 +1045,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @param usage Buffer usage * @param usage Buffer usage
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, * nor @extension{EXT,direct_state_access} desktop extension is
* the buffer is bound to hinted target before the operation (if not * available, the buffer is bound to hinted target before the operation
* already). * (if not already).
* @see @ref setTargetHint(), @fn_gl2{NamedBufferData,BufferData}, * @see @ref setTargetHint(), @fn_gl2{NamedBufferData,BufferData},
* @fn_gl_extension{NamedBufferData,EXT,direct_state_access}, * @fn_gl_extension{NamedBufferData,EXT,direct_state_access},
* eventually @fn_gl{BindBuffer} and @fn_gl{BufferData} * eventually @fn_gl{BindBuffer} and @fn_gl{BufferData}
@ -1002,10 +1073,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @param data Data * @param data Data
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, * nor @extension{EXT,direct_state_access} desktop extension is
* the buffer is bound to hinted target before the operation (if not * available, the buffer is bound to hinted target before the operation
* already). * (if not already).
* @see @ref setTargetHint(), @fn_gl2{NamedBufferSubData,BufferSubData}, * @see @ref setTargetHint(), @fn_gl2{NamedBufferSubData,BufferSubData},
* @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access}, * @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access},
* eventually @fn_gl{BindBuffer} and @fn_gl{BufferSubData} * eventually @fn_gl{BindBuffer} and @fn_gl{BufferSubData}
@ -1046,15 +1117,16 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
*/ */
Buffer& invalidateSubData(GLintptr offset, GLsizeiptr length); Buffer& invalidateSubData(GLintptr offset, GLsizeiptr length);
#ifndef MAGNUM_TARGET_WEBGL
/** /**
* @brief Map buffer to client memory * @brief Map buffer to client memory
* @param access Access * @param access Access
* @return Pointer to buffer data * @return Pointer to buffer data
* *
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, * nor @extension{EXT,direct_state_access} desktop extension is
* the buffer is bound to hinted target before the operation (if not * available, the buffer is bound to hinted target before the operation
* already). * (if not already).
* @see @ref minMapAlignment(), @ref unmap(), @ref setTargetHint(), * @see @ref minMapAlignment(), @ref unmap(), @ref setTargetHint(),
* @fn_gl2{MapNamedBuffer,MapBuffer}, * @fn_gl2{MapNamedBuffer,MapBuffer},
* @fn_gl_extension{MapNamedBuffer,EXT,direct_state_access}, * @fn_gl_extension{MapNamedBuffer,EXT,direct_state_access},
@ -1062,6 +1134,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @requires_es_extension Extension @es_extension{OES,mapbuffer} in * @requires_es_extension Extension @es_extension{OES,mapbuffer} in
* OpenGL ES 2.0, use @ref map(GLintptr, GLsizeiptr, MapFlags) in * OpenGL ES 2.0, use @ref map(GLintptr, GLsizeiptr, MapFlags) in
* OpenGL ES 3.0 instead. * OpenGL ES 3.0 instead.
* @requires_gles Buffer mapping is not available in WebGL.
* @deprecated_gl Prefer to use @ref map(GLintptr, GLsizeiptr, MapFlags) * @deprecated_gl Prefer to use @ref map(GLintptr, GLsizeiptr, MapFlags)
* instead, as it has more complete set of features. * instead, as it has more complete set of features.
*/ */
@ -1084,9 +1157,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* already). * already).
* @see @ref unmapSub(), @ref setTargetHint(), * @see @ref unmapSub(), @ref setTargetHint(),
* @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub} * @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub}
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use * @requires_gles20 Available only in NaCl build. Use
* @ref map(GLintptr, GLsizeiptr, MapFlags) instead. * @ref map(GLintptr, GLsizeiptr, MapFlags) elsewhere.
* @requires_es_extension Extension @es_extension{CHROMIUM,map_sub} * @requires_es_extension Extension @es_extension{CHROMIUM,map_sub}
* @requires_gles Buffer mapping is not available in WebGL.
* @deprecated_gl Prefer to use @ref map(GLintptr, GLsizeiptr, MapFlags) * @deprecated_gl Prefer to use @ref map(GLintptr, GLsizeiptr, MapFlags)
* instead, as it has more complete set of features. * instead, as it has more complete set of features.
*/ */
@ -1106,10 +1180,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @ref MapFlag::Write must be specified. * @ref MapFlag::Write must be specified.
* @return Pointer to buffer data * @return Pointer to buffer data
* *
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, * nor @extension{EXT,direct_state_access} desktop extension is
* the buffer is bound to hinted target before the operation (if not * available, the buffer is bound to hinted target before the operation
* already). * (if not already).
* @see @ref minMapAlignment(), @ref flushMappedRange(), @ref unmap(), * @see @ref minMapAlignment(), @ref flushMappedRange(), @ref unmap(),
* @ref map(MapAccess), @ref setTargetHint(), * @ref map(MapAccess), @ref setTargetHint(),
* @fn_gl2{MapNamedBufferRange,MapBufferRange}, * @fn_gl2{MapNamedBufferRange,MapBufferRange},
@ -1117,7 +1191,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* eventually @fn_gl{BindBuffer} and @fn_gl{MapBufferRange} * eventually @fn_gl{BindBuffer} and @fn_gl{MapBufferRange}
* @requires_gl30 Extension @extension{ARB,map_buffer_range} * @requires_gl30 Extension @extension{ARB,map_buffer_range}
* @requires_gles30 Extension @es_extension{EXT,map_buffer_range} in * @requires_gles30 Extension @es_extension{EXT,map_buffer_range} in
* OpenGL ES 2.0 * OpenGL ES 2.0.
* @requires_gles Buffer mapping is not available in WebGL.
*/ */
void* map(GLintptr offset, GLsizeiptr length, MapFlags flags); void* map(GLintptr offset, GLsizeiptr length, MapFlags flags);
@ -1136,16 +1211,17 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* @ref map() with @ref MapFlag::FlushExplicit flag. See * @ref map() with @ref MapFlag::FlushExplicit flag. See
* @ref Buffer-data-mapping "class documentation" for usage example. * @ref Buffer-data-mapping "class documentation" for usage example.
* *
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, * nor @extension{EXT,direct_state_access} desktop extension is
* the buffer is bound to hinted target before the operation (if not * available, the buffer is bound to hinted target before the operation
* already). * (if not already).
* @see @ref setTargetHint(), @fn_gl2{FlushMappedNamedBufferRange,FlushMappedBufferRange}, * @see @ref setTargetHint(), @fn_gl2{FlushMappedNamedBufferRange,FlushMappedBufferRange},
* @fn_gl_extension{FlushMappedNamedBufferRange,EXT,direct_state_access}, * @fn_gl_extension{FlushMappedNamedBufferRange,EXT,direct_state_access},
* eventually @fn_gl{BindBuffer} and @fn_gl{FlushMappedBufferRange} * eventually @fn_gl{BindBuffer} and @fn_gl{FlushMappedBufferRange}
* @requires_gl30 Extension @extension{ARB,map_buffer_range} * @requires_gl30 Extension @extension{ARB,map_buffer_range}
* @requires_gles30 Extension @es_extension{EXT,map_buffer_range} in * @requires_gles30 Extension @es_extension{EXT,map_buffer_range} in
* OpenGL ES 2.0 * OpenGL ES 2.0.
* @requires_gles Buffer mapping is not available in WebGL.
*/ */
Buffer& flushMappedRange(GLintptr offset, GLsizeiptr length); Buffer& flushMappedRange(GLintptr offset, GLsizeiptr length);
@ -1156,15 +1232,17 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* otherwise. * otherwise.
* *
* Unmaps buffer previously mapped with @ref map(), invalidating the * Unmaps buffer previously mapped with @ref map(), invalidating the
* pointer returned by these functions. If on OpenGL ES or neither * pointer returned by these functions. If neither
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor * @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor
* @extension{EXT,direct_state_access} is available, the buffer is * @extension{EXT,direct_state_access} desktop extension is available,
* bound to hinted target before the operation (if not already). * the buffer is bound to hinted target before the operation (if not
* already).
* @see @ref setTargetHint(), @fn_gl2{UnmapNamedBuffer,UnmapBuffer}, * @see @ref setTargetHint(), @fn_gl2{UnmapNamedBuffer,UnmapBuffer},
* @fn_gl_extension{UnmapNamedBuffer,EXT,direct_state_access}, * @fn_gl_extension{UnmapNamedBuffer,EXT,direct_state_access},
* eventually @fn_gl{BindBuffer} and @fn_gl{UnmapBuffer} * eventually @fn_gl{BindBuffer} and @fn_gl{UnmapBuffer}
* @requires_gles30 Extension @es_extension{OES,mapbuffer} in OpenGL * @requires_gles30 Extension @es_extension{OES,mapbuffer} in OpenGL
* ES 2.0 * ES 2.0.
* @requires_gles Buffer mapping is not available in WebGL.
*/ */
bool unmap(); bool unmap();
@ -1175,12 +1253,14 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* Unmaps portion of buffer previously mapped with @ref mapSub(), * Unmaps portion of buffer previously mapped with @ref mapSub(),
* invalidating the pointer returned by the function. * invalidating the pointer returned by the function.
* @see @fn_gl_extension{UnmapBufferSubData,CHROMIUM,map_sub} * @see @fn_gl_extension{UnmapBufferSubData,CHROMIUM,map_sub}
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use * @requires_gles20 Available only in NaCl build. Use
* @ref map(GLintptr, GLsizeiptr, MapFlags) instead. * @ref map(GLintptr, GLsizeiptr, MapFlags) elsewhere.
* @requires_es_extension Extension @es_extension{CHROMIUM,map_sub} * @requires_es_extension Extension @es_extension{CHROMIUM,map_sub}
* @requires_gles Buffer mapping is not available in WebGL.
*/ */
void unmapSub(); void unmapSub();
#endif #endif
#endif
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
private: private:
@ -1263,6 +1343,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
void MAGNUM_LOCAL invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length); void MAGNUM_LOCAL invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length);
#endif #endif
#ifndef MAGNUM_TARGET_WEBGL
void MAGNUM_LOCAL * mapImplementationDefault(MapAccess access); void MAGNUM_LOCAL * mapImplementationDefault(MapAccess access);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL * mapImplementationDSA(MapAccess access); void MAGNUM_LOCAL * mapImplementationDSA(MapAccess access);
@ -1286,6 +1367,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
bool MAGNUM_LOCAL unmapImplementationDSA(); bool MAGNUM_LOCAL unmapImplementationDSA();
bool MAGNUM_LOCAL unmapImplementationDSAEXT(); bool MAGNUM_LOCAL unmapImplementationDSAEXT();
#endif #endif
#endif
GLuint _id; GLuint _id;
TargetHint _targetHint; TargetHint _targetHint;
@ -1295,7 +1377,9 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
bool _created; /* see createIfNotAlready() for details */ bool _created; /* see createIfNotAlready() for details */
}; };
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_ENUMSET_OPERATORS(Buffer::MapFlags) CORRADE_ENUMSET_OPERATORS(Buffer::MapFlags)
#endif
/** @debugoperatorclassenum{Magnum::Buffer,Magnum::Buffer::TargetHint} */ /** @debugoperatorclassenum{Magnum::Buffer,Magnum::Buffer::TargetHint} */
Debug MAGNUM_EXPORT operator<<(Debug debug, Buffer::TargetHint value); Debug MAGNUM_EXPORT operator<<(Debug debug, Buffer::TargetHint value);

1
src/Magnum/BufferImage.h

@ -46,6 +46,7 @@ Stores image data in GPU memory. Interchangeable with @ref Image,
@ref ImageReference or @ref Trade::ImageData. @ref ImageReference or @ref Trade::ImageData.
@see @ref BufferImage1D, @ref BufferImage2D, @ref BufferImage3D, @ref Buffer @see @ref BufferImage1D, @ref BufferImage2D, @ref BufferImage3D, @ref Buffer
@requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0. @requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0.
@requires_webgl20 Pixel buffer objects are not available in WebGL 1.0.
*/ */
template<UnsignedInt dimensions> class BufferImage: public AbstractImage { template<UnsignedInt dimensions> class BufferImage: public AbstractImage {
public: public:

11
src/Magnum/Implementation/BufferState.cpp

@ -44,10 +44,12 @@ const Buffer::TargetHint BufferState::targetForIndex[] = {
Buffer::TargetHint::PixelUnpack, Buffer::TargetHint::PixelUnpack,
Buffer::TargetHint::TransformFeedback, Buffer::TargetHint::TransformFeedback,
Buffer::TargetHint::Uniform, Buffer::TargetHint::Uniform,
#ifndef MAGNUM_TARGET_WEBGL
Buffer::TargetHint::AtomicCounter, Buffer::TargetHint::AtomicCounter,
Buffer::TargetHint::DispatchIndirect, Buffer::TargetHint::DispatchIndirect,
Buffer::TargetHint::DrawIndirect, Buffer::TargetHint::DrawIndirect,
Buffer::TargetHint::ShaderStorage, Buffer::TargetHint::ShaderStorage,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Buffer::TargetHint::Texture Buffer::TargetHint::Texture
#endif #endif
@ -65,10 +67,12 @@ std::size_t BufferState::indexForTarget(Buffer::TargetHint target) {
case Buffer::TargetHint::PixelUnpack: return 6; case Buffer::TargetHint::PixelUnpack: return 6;
case Buffer::TargetHint::TransformFeedback: return 7; case Buffer::TargetHint::TransformFeedback: return 7;
case Buffer::TargetHint::Uniform: return 8; case Buffer::TargetHint::Uniform: return 8;
#ifndef MAGNUM_TARGET_WEBGL
case Buffer::TargetHint::AtomicCounter: return 9; case Buffer::TargetHint::AtomicCounter: return 9;
case Buffer::TargetHint::DispatchIndirect: return 10; case Buffer::TargetHint::DispatchIndirect: return 10;
case Buffer::TargetHint::DrawIndirect: return 11; case Buffer::TargetHint::DrawIndirect: return 11;
case Buffer::TargetHint::ShaderStorage: return 12; case Buffer::TargetHint::ShaderStorage: return 12;
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case Buffer::TargetHint::Texture: return 13; case Buffer::TargetHint::Texture: return 13;
#endif #endif
@ -83,7 +87,10 @@ BufferState::BufferState(Context& context, std::vector<std::string>& extensions)
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
, minMapAlignment(0) , minMapAlignment(0)
#endif #endif
, maxAtomicCounterBindings{0}, maxShaderStorageBindings{0}, shaderStorageOffsetAlignment{0}, uniformOffsetAlignment{0}, maxUniformBindings{0} #ifndef MAGNUM_TARGET_WEBGL
, maxAtomicCounterBindings{0}, maxShaderStorageBindings{0}, shaderStorageOffsetAlignment{0}
#endif
, uniformOffsetAlignment{0}, maxUniformBindings{0}
#endif #endif
{ {
/* Create implementation */ /* Create implementation */
@ -135,10 +142,12 @@ BufferState::BufferState(Context& context, std::vector<std::string>& extensions)
#endif #endif
dataImplementation = &Buffer::dataImplementationDefault; dataImplementation = &Buffer::dataImplementationDefault;
subDataImplementation = &Buffer::subDataImplementationDefault; subDataImplementation = &Buffer::subDataImplementationDefault;
#ifndef MAGNUM_TARGET_WEBGL
mapImplementation = &Buffer::mapImplementationDefault; mapImplementation = &Buffer::mapImplementationDefault;
mapRangeImplementation = &Buffer::mapRangeImplementationDefault; mapRangeImplementation = &Buffer::mapRangeImplementationDefault;
flushMappedRangeImplementation = &Buffer::flushMappedRangeImplementationDefault; flushMappedRangeImplementation = &Buffer::flushMappedRangeImplementationDefault;
unmapImplementation = &Buffer::unmapImplementationDefault; unmapImplementation = &Buffer::unmapImplementationDefault;
#endif
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

6
src/Magnum/Implementation/BufferState.h

@ -32,6 +32,8 @@ namespace Magnum { namespace Implementation {
struct BufferState { struct BufferState {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
static const std::size_t TargetCount = 13+1; static const std::size_t TargetCount = 13+1;
#elif !defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)
static const std::size_t TargetCount = 8+1;
#elif !defined(MAGNUM_TARGET_GLES2) #elif !defined(MAGNUM_TARGET_GLES2)
static const std::size_t TargetCount = 12+1; static const std::size_t TargetCount = 12+1;
#else #else
@ -60,10 +62,12 @@ struct BufferState {
void(Buffer::*subDataImplementation)(GLintptr, GLsizeiptr, const GLvoid*); void(Buffer::*subDataImplementation)(GLintptr, GLsizeiptr, const GLvoid*);
void(Buffer::*invalidateImplementation)(); void(Buffer::*invalidateImplementation)();
void(Buffer::*invalidateSubImplementation)(GLintptr, GLsizeiptr); void(Buffer::*invalidateSubImplementation)(GLintptr, GLsizeiptr);
#ifndef MAGNUM_TARGET_WEBGL
void*(Buffer::*mapImplementation)(Buffer::MapAccess); void*(Buffer::*mapImplementation)(Buffer::MapAccess);
void*(Buffer::*mapRangeImplementation)(GLintptr, GLsizeiptr, Buffer::MapFlags); void*(Buffer::*mapRangeImplementation)(GLintptr, GLsizeiptr, Buffer::MapFlags);
void(Buffer::*flushMappedRangeImplementation)(GLintptr, GLsizeiptr); void(Buffer::*flushMappedRangeImplementation)(GLintptr, GLsizeiptr);
bool(Buffer::*unmapImplementation)(); bool(Buffer::*unmapImplementation)();
#endif
/* Currently bound buffer for all targets */ /* Currently bound buffer for all targets */
GLuint bindings[TargetCount]; GLuint bindings[TargetCount];
@ -74,9 +78,11 @@ struct BufferState {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
minMapAlignment, minMapAlignment,
#endif #endif
#ifndef MAGNUM_TARGET_WEBGL
maxAtomicCounterBindings, maxAtomicCounterBindings,
maxShaderStorageBindings, maxShaderStorageBindings,
shaderStorageOffsetAlignment, shaderStorageOffsetAlignment,
#endif
uniformOffsetAlignment, uniformOffsetAlignment,
maxUniformBindings; maxUniformBindings;
#endif #endif

Loading…
Cancel
Save