diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 45647eeed..777d0b06b 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -24,11 +24,14 @@ namespace Magnum { +#ifndef MAGNUM_TARGET_GLES2 Buffer::CopyImplementation Buffer::copyImplementation = &Buffer::copyImplementationDefault; +#endif Buffer::SetDataImplementation Buffer::setDataImplementation = &Buffer::setDataImplementationDefault; Buffer::SetSubDataImplementation Buffer::setSubDataImplementation = &Buffer::setSubDataImplementationDefault; void Buffer::initializeContextBasedFunctionality(Context* context) { + #ifndef MAGNUM_TARGET_GLES if(context->isExtensionSupported()) { Debug() << "Buffer: using" << Extensions::GL::EXT::direct_state_access::string() << "features"; @@ -36,6 +39,9 @@ void Buffer::initializeContextBasedFunctionality(Context* context) { setDataImplementation = &Buffer::setDataImplementationDSA; setSubDataImplementation = &Buffer::setSubDataImplementationDSA; } + #else + static_cast(context); + #endif } Buffer::~Buffer() { @@ -76,28 +82,36 @@ Buffer::Target Buffer::bindInternal(Target hint) { return hint; } +#ifndef MAGNUM_TARGET_GLES2 void Buffer::copyImplementationDefault(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { glCopyBufferSubData(static_cast(read->bindInternal(Target::CopyRead)), static_cast(write->bindInternal(Target::CopyWrite)), readOffset, writeOffset, size); } +#ifndef MAGNUM_TARGET_GLES void Buffer::copyImplementationDSA(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { glNamedCopyBufferSubDataEXT(read->_id, write->_id, readOffset, writeOffset, size); } +#endif +#endif void Buffer::setDataImplementationDefault(GLsizeiptr size, const GLvoid* data, Buffer::Usage usage) { glBufferData(static_cast(bindInternal(_targetHint)), size, data, static_cast(usage)); } +#ifndef MAGNUM_TARGET_GLES void Buffer::setDataImplementationDSA(GLsizeiptr size, const GLvoid* data, Buffer::Usage usage) { glNamedBufferDataEXT(_id, size, data, static_cast(usage)); } +#endif void Buffer::setSubDataImplementationDefault(GLintptr offset, GLsizeiptr size, const GLvoid* data) { glBufferSubData(static_cast(bindInternal(_targetHint)), offset, size, data); } +#ifndef MAGNUM_TARGET_GLES void Buffer::setSubDataImplementationDSA(GLintptr offset, GLsizeiptr size, const GLvoid* data) { glNamedBufferSubDataEXT(_id, offset, size, data); } +#endif } diff --git a/src/Buffer.h b/src/Buffer.h index 6df02acad..5efa508a2 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -100,7 +100,7 @@ class MAGNUM_EXPORT Buffer { /** * Used for storing atomic counters. * @requires_gl42 Extension @extension{ARB,shader_atomic_counters} - * @requires_gl + * @requires_gl Atomic counters are not available in OpenGL ES. */ AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, #endif @@ -108,14 +108,16 @@ class MAGNUM_EXPORT Buffer { /** * Source for copies. See copy(). * @requires_gl31 Extension @extension{ARB,copy_buffer} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Buffer copying is not available in OpenGL ES + * 2.0. */ CopyRead = GL_COPY_READ_BUFFER, /** * Target for copies. See copy(). * @requires_gl31 Extension @extension{ARB,copy_buffer} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Buffer copying is not available in OpenGL ES + * 2.0. */ CopyWrite = GL_COPY_WRITE_BUFFER, @@ -123,14 +125,14 @@ class MAGNUM_EXPORT Buffer { /** * Indirect compute dispatch commands. * @requires_gl43 Extension @extension{ARB,compute_shader} - * @requires_gl + * @requires_gl Compute shaders are not available in OpenGL ES. */ DispatchIndirect = GL_DISPATCH_INDIRECT_BUFFER, /** - * Used for supplying arguments for instanced drawing. - * @requires_gl + * Used for supplying arguments for indirect drawing. * @requires_gl40 Extension @extension{ARB,draw_indirect} + * @requires_gl Indirect drawing not available in OpenGL ES. */ DrawIndirect = GL_DRAW_INDIRECT_BUFFER, #endif @@ -140,13 +142,15 @@ class MAGNUM_EXPORT Buffer { /** * Target for pixel pack operations. - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Pixel buffer objects are not available in + * OpenGL ES 2.0. */ PixelPack = GL_PIXEL_PACK_BUFFER, /** * Source for texture update operations. - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Pixel buffer objects are not available in + * OpenGL ES 2.0. */ PixelUnpack = GL_PIXEL_UNPACK_BUFFER, @@ -154,14 +158,14 @@ class MAGNUM_EXPORT Buffer { /** * Used for shader storage. * @requires_gl43 Extension @extension{ARB,shader_storage_buffer_object} - * @requires_gl + * @requires_gl Shader storage is not available in OpenGL ES. */ ShaderStorage = GL_SHADER_STORAGE_BUFFER, /** * Source for texel fetches. See BufferedTexture. - * @requires_gl * @requires_gl31 Extension @extension{ARB,texture_buffer_object} + * @requires_gl Texture buffers are not available in OpenGL ES. */ Texture = GL_TEXTURE_BUFFER, #endif @@ -169,14 +173,16 @@ class MAGNUM_EXPORT Buffer { /** * Target for transform feedback. * @requires_gl30 Extension @extension{EXT,transform_feedback} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Transform feedback is not available in OpenGL + * ES 2.0. */ TransformFeedback = GL_TRANSFORM_FEEDBACK_BUFFER, /** * Used for storing uniforms. * @requires_gl31 Extension @extension{ARB,uniform_buffer_object} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Uniform buffers are not available in OpenGL ES + * 2.0. */ Uniform = GL_UNIFORM_BUFFER }; @@ -195,14 +201,16 @@ class MAGNUM_EXPORT Buffer { /** * Set once as output from an OpenGL command and used infequently * for drawing. - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StreamDraw" + * is available in OpenGL ES 2.0. */ StreamRead = GL_STREAM_READ, /** * Set once as output from an OpenGL command and used infrequently * for drawing or copying to other buffers. - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StreamDraw" + * is available in OpenGL ES 2.0. */ StreamCopy = GL_STREAM_COPY, @@ -214,14 +222,16 @@ class MAGNUM_EXPORT Buffer { /** * Set once as output from an OpenGL command and queried many * times by the application. - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StaticDraw" + * is available in OpenGL ES 2.0. */ StaticRead = GL_STATIC_READ, /** * Set once as output from an OpenGL command and used frequently * for drawing or copying to other buffers. - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StaticDraw" + * is available in OpenGL ES 2.0. */ StaticCopy = GL_STATIC_COPY, @@ -234,14 +244,16 @@ class MAGNUM_EXPORT Buffer { /** * Updated frequently as output from OpenGL command and queried * many times from the application. - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::DynamicDraw" + * is available in OpenGL ES 2.0. */ DynamicRead = GL_DYNAMIC_READ, /** * Updated frequently as output from OpenGL command and used * frequently for drawing or copying to other images. - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::DynamicCopy" + * is available in OpenGL ES 2.0. */ DynamicCopy = GL_DYNAMIC_COPY }; @@ -254,6 +266,7 @@ class MAGNUM_EXPORT Buffer { */ inline static void unbind(Target target) { bind(target, 0); } + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Copy one buffer to another * @param read %Buffer from which to read @@ -267,13 +280,14 @@ class MAGNUM_EXPORT Buffer { * `Target::CopyRead` and `Target::CopyWrite` before the copy is * performed. * @requires_gl31 Extension @extension{ARB,copy_buffer} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Buffer copying is not available in OpenGL ES 2.0. * @see @fn_gl{BindBuffer} and @fn_gl{CopyBufferSubData} or * @fn_gl_extension{NamedCopyBufferSubData,EXT,direct_state_access} */ inline static void copy(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { copyImplementation(read, write, readOffset, writeOffset, size); } + #endif /** * @brief Constructor @@ -419,19 +433,27 @@ class MAGNUM_EXPORT Buffer { static void bind(Target hint, GLuint id); Target MAGNUM_LOCAL bindInternal(Target hint); + #ifndef MAGNUM_TARGET_GLES2 typedef void(*CopyImplementation)(Buffer*, Buffer*, GLintptr, GLintptr, GLsizeiptr); static void MAGNUM_LOCAL copyImplementationDefault(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + #ifndef MAGNUM_TARGET_GLES static void MAGNUM_LOCAL copyImplementationDSA(Buffer* read, Buffer* write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + #endif static CopyImplementation copyImplementation; + #endif typedef void(Buffer::*SetDataImplementation)(GLsizeiptr, const GLvoid*, Usage); void MAGNUM_LOCAL setDataImplementationDefault(GLsizeiptr size, const GLvoid* data, Usage usage); + #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL setDataImplementationDSA(GLsizeiptr size, const GLvoid* data, Usage usage); + #endif static SetDataImplementation setDataImplementation; typedef void(Buffer::*SetSubDataImplementation)(GLintptr, GLsizeiptr, const GLvoid*); void MAGNUM_LOCAL setSubDataImplementationDefault(GLintptr offset, GLsizeiptr size, const GLvoid* data); + #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL setSubDataImplementationDSA(GLintptr offset, GLsizeiptr size, const GLvoid* data); + #endif static SetSubDataImplementation setSubDataImplementation; GLuint _id; diff --git a/src/BufferedImage.h b/src/BufferedImage.h index b3c60244a..0831f653b 100644 --- a/src/BufferedImage.h +++ b/src/BufferedImage.h @@ -34,7 +34,7 @@ Class for storing image data in GPU memory. Can be replaced with Image, which stores image data in client memory, ImageWrapper, or for example with Trade::ImageData. @see BufferedImage1D, BufferedImage2D, BufferedImage3D, Buffer -@requires_gles30 (no extension providing this functionality) +@requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0. */ template class MAGNUM_EXPORT BufferedImage: public AbstractImage { public: diff --git a/src/BufferedTexture.cpp b/src/BufferedTexture.cpp index aefb40905..862f1f97a 100644 --- a/src/BufferedTexture.cpp +++ b/src/BufferedTexture.cpp @@ -15,6 +15,7 @@ #include "BufferedTexture.h" +#ifndef MAGNUM_TARGET_GLES #include "Buffer.h" #include "Context.h" #include "Extensions.h" @@ -40,7 +41,6 @@ void BufferedTexture::setBufferImplementationDSA(BufferedTexture::InternalFormat glTextureBufferEXT(id(), GL_TEXTURE_BUFFER, internalFormat, buffer->id()); } -#ifndef MAGNUM_TARGET_GLES BufferedTexture::InternalFormat::InternalFormat(Components components, ComponentType type) { #define internalFormatSwitch(c) switch(type) { \ case ComponentType::UnsignedByte: \ @@ -72,6 +72,6 @@ BufferedTexture::InternalFormat::InternalFormat(Components components, Component internalFormatSwitch(RGBA) #undef internalFormatSwitch } -#endif } +#endif diff --git a/src/BufferedTexture.h b/src/BufferedTexture.h index ae483585e..170f606b9 100644 --- a/src/BufferedTexture.h +++ b/src/BufferedTexture.h @@ -15,18 +15,20 @@ GNU Lesser General Public License version 3 for more details. */ +#ifndef MAGNUM_TARGET_GLES /** @file * @brief Class Magnum::BufferedTexture */ +#endif #include "AbstractTexture.h" +#ifndef MAGNUM_TARGET_GLES namespace Magnum { class Buffer; class Context; -#ifndef MAGNUM_TARGET_GLES /** @brief Buffered texture @@ -46,8 +48,8 @@ uses DSA function to avoid unnecessary calls to @fn_gl{ActiveTexture} and "relevant section in AbstractTexture documentation" and respective function documentation for more information. -@requires_gl @requires_gl31 Extension @extension{ARB,texture_buffer_object} +@requires_gl Texture buffers are not available in OpenGL ES. */ class MAGNUM_EXPORT BufferedTexture: private AbstractTexture { friend class Context; @@ -169,8 +171,8 @@ inline BufferedTexture::InternalFormat operator|(BufferedTexture::Components com inline BufferedTexture::InternalFormat operator|(BufferedTexture::ComponentType type, BufferedTexture::Components components) { return BufferedTexture::InternalFormat(components, type); } -#endif } +#endif #endif