diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index 0977ab649..504ef9d06 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -361,6 +361,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { /* GL_FIXED not supported */ + #ifndef MAGNUM_TARGET_GLES2 /** * Unsigned 2.10.10.10 packed integer. Only for * four-component float vector attribute type. @@ -377,6 +378,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @requires_gles30 (no extension providing this functionality) */ Int2101010REV = GL_INT_2_10_10_10_REV + #endif }; #else typedef typename Implementation::Attribute::DataType DataType; @@ -465,6 +467,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { bool use(); protected: + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Allow retrieving program binary * @@ -478,6 +481,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { inline void setRetrievableBinary(bool enabled) { glProgramParameteri(_id, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, enabled ? GL_TRUE : GL_FALSE); } + #endif /** * @brief Allow the program to be bound to individual pipeline stages @@ -1101,12 +1105,16 @@ template<> struct Attribute> { UnsignedInt = GL_UNSIGNED_INT, Int = GL_INT, Half = GL_HALF_FLOAT, - Float = GL_FLOAT, + Float = GL_FLOAT #ifndef MAGNUM_TARGET_GLES - Double = GL_DOUBLE, + , + Double = GL_DOUBLE #endif + #ifndef MAGNUM_TARGET_GLES2 + , UnsignedAlpha2RGB10 = GL_UNSIGNED_INT_2_10_10_10_REV, Alpha2RGB10 = GL_INT_2_10_10_10_REV + #endif }; enum class DataOption: std::uint8_t { diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp index 8012626b7..41fb407e6 100644 --- a/src/AbstractTexture.cpp +++ b/src/AbstractTexture.cpp @@ -312,6 +312,7 @@ void AbstractTexture::subImageImplementationDSA(GLenum target, GLint mipLevel, c } #endif +#ifndef MAGNUM_TARGET_GLES2 AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components components, AbstractTexture::ComponentType type) { #ifndef MAGNUM_TARGET_GLES #define internalFormatSwitch(c) switch(type) { \ @@ -374,6 +375,7 @@ AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components comp internalFormatSwitch(RGBA) #undef internalFormatSwitch } +#endif #ifndef DOXYGEN_GENERATING_OUTPUT void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture* texture, const Math::Vector2& wrapping) { diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 35abf4823..f9581dd02 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -141,6 +141,7 @@ class MAGNUM_EXPORT AbstractTexture { /** @{ @name Internal texture formats */ + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Color components * @@ -253,6 +254,7 @@ class MAGNUM_EXPORT AbstractTexture { NormalizedShort #endif }; + #endif /** * @brief Internal format @@ -261,6 +263,7 @@ class MAGNUM_EXPORT AbstractTexture { * normalization see enums Components and ComponentType. */ enum class Format: GLenum { + #ifndef MAGNUM_TARGET_GLES2 /** * One-component (red channel), unsigned normalized, probably * 8bit. @@ -276,6 +279,7 @@ class MAGNUM_EXPORT AbstractTexture { * @requires_gles30 (no extension providing this functionality) */ RedGreen = GL_RG, + #endif /** * Three-component RGB, unsigned normalized, each component @@ -311,6 +315,7 @@ class MAGNUM_EXPORT AbstractTexture { BGRA = GL_BGRA, #endif + #ifndef MAGNUM_TARGET_GLES2 /** * Four-component sRGBA, unsigned normalized, each component * 8bit, 32bit total. @@ -339,6 +344,7 @@ class MAGNUM_EXPORT AbstractTexture { * @requires_gles30 (no extension providing this functionality) */ RGB10Alpha2Unsigned = GL_RGB10_A2UI, + #endif /** * Four-component RGBA, unsigned normalized, each RGB component @@ -352,6 +358,7 @@ class MAGNUM_EXPORT AbstractTexture { */ RGBA4 = GL_RGBA4, + #ifndef MAGNUM_TARGET_GLES2 /** * Three-component RGB, float, red and green 11bit, blue 10bit, * 32bit total. @@ -359,6 +366,7 @@ class MAGNUM_EXPORT AbstractTexture { * @requires_gles30 (no extension providing this functionality) */ RG11B10Float = GL_R11F_G11F_B10F, + #endif /* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is GL_ARB_ES2_compatibility */ @@ -367,9 +375,11 @@ class MAGNUM_EXPORT AbstractTexture { * Three-component RGB, unsigned normalized, red and blue 5bit, * green 6bit, 16bit total. */ - RGB565 = GL_RGB565, + RGB565 = GL_RGB565 #endif + #ifndef MAGNUM_TARGET_GLES2 + , /** * Three-component RGB, unsigned with exponent, each component * 9bit, exponent 5bit, 32bit total. @@ -377,6 +387,7 @@ class MAGNUM_EXPORT AbstractTexture { * @requires_gles30 (no extension providing this functionality) */ RGB9Exponent5 = GL_RGB9_E5, + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -487,6 +498,7 @@ class MAGNUM_EXPORT AbstractTexture { DepthStencil = GL_DEPTH_STENCIL, #endif + #ifndef MAGNUM_TARGET_GLES2 /** * 16bit depth component. * @requires_gles30 (no extension providing this functionality) @@ -519,6 +531,7 @@ class MAGNUM_EXPORT AbstractTexture { * @requires_gles30 (no extension providing this functionality) */ Depth32FloatStencil8 = GL_DEPTH32F_STENCIL8 + #endif }; /** @@ -539,12 +552,14 @@ class MAGNUM_EXPORT AbstractTexture { */ class MAGNUM_EXPORT InternalFormat { public: + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Constructor from component count and data type per component * * @requires_gles30 (no extension providing this functionality) */ InternalFormat(Components components, ComponentType type); + #endif /** @brief Constructor from named internal format */ inline constexpr InternalFormat(Format format): internalFormat(static_cast(format)) {} @@ -791,6 +806,7 @@ class MAGNUM_EXPORT AbstractTexture { GLuint _id; }; +#ifndef MAGNUM_TARGET_GLES2 /** @relates AbstractTexture @brief Convertor of component count and data type to InternalFormat @@ -806,6 +822,7 @@ inline AbstractTexture::InternalFormat operator|(AbstractTexture::Components com inline AbstractTexture::InternalFormat operator|(AbstractTexture::ComponentType type, AbstractTexture::Components components) { return AbstractTexture::InternalFormat(components, type); } +#endif #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_TARGET_GLES diff --git a/src/Buffer.h b/src/Buffer.h index 5efa508a2..bf426f2d4 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -105,6 +105,7 @@ class MAGNUM_EXPORT Buffer { AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, #endif + #ifndef MAGNUM_TARGET_GLES2 /** * Source for copies. See copy(). * @requires_gl31 Extension @extension{ARB,copy_buffer} @@ -120,6 +121,7 @@ class MAGNUM_EXPORT Buffer { * 2.0. */ CopyWrite = GL_COPY_WRITE_BUFFER, + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -138,7 +140,10 @@ class MAGNUM_EXPORT Buffer { #endif /** Used for storing vertex indices. */ - ElementArray = GL_ELEMENT_ARRAY_BUFFER, + ElementArray = GL_ELEMENT_ARRAY_BUFFER + + #ifndef MAGNUM_TARGET_GLES2 + , /** * Target for pixel pack operations. @@ -153,6 +158,7 @@ class MAGNUM_EXPORT Buffer { * OpenGL ES 2.0. */ PixelUnpack = GL_PIXEL_UNPACK_BUFFER, + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -170,6 +176,7 @@ class MAGNUM_EXPORT Buffer { Texture = GL_TEXTURE_BUFFER, #endif + #ifndef MAGNUM_TARGET_GLES2 /** * Target for transform feedback. * @requires_gl30 Extension @extension{EXT,transform_feedback} @@ -185,6 +192,7 @@ class MAGNUM_EXPORT Buffer { * 2.0. */ Uniform = GL_UNIFORM_BUFFER + #endif }; /** @@ -198,6 +206,7 @@ class MAGNUM_EXPORT Buffer { */ StreamDraw = GL_STREAM_DRAW, + #ifndef MAGNUM_TARGET_GLES2 /** * Set once as output from an OpenGL command and used infequently * for drawing. @@ -213,12 +222,14 @@ class MAGNUM_EXPORT Buffer { * is available in OpenGL ES 2.0. */ StreamCopy = GL_STREAM_COPY, + #endif /** * Set once by the application and used frequently for drawing. */ StaticDraw = GL_STATIC_DRAW, + #ifndef MAGNUM_TARGET_GLES2 /** * Set once as output from an OpenGL command and queried many * times by the application. @@ -234,12 +245,16 @@ class MAGNUM_EXPORT Buffer { * is available in OpenGL ES 2.0. */ StaticCopy = GL_STATIC_COPY, + #endif /** * Updated frequently by the application and used frequently * for drawing or copying to other images. */ - DynamicDraw = GL_DYNAMIC_DRAW, + DynamicDraw = GL_DYNAMIC_DRAW + + #ifndef MAGNUM_TARGET_GLES2 + , /** * Updated frequently as output from OpenGL command and queried @@ -256,6 +271,7 @@ class MAGNUM_EXPORT Buffer { * is available in OpenGL ES 2.0. */ DynamicCopy = GL_DYNAMIC_COPY + #endif }; /** diff --git a/src/BufferedImage.cpp b/src/BufferedImage.cpp index 54fdeb03a..f75688054 100644 --- a/src/BufferedImage.cpp +++ b/src/BufferedImage.cpp @@ -17,6 +17,7 @@ namespace Magnum { +#ifndef MAGNUM_TARGET_GLES2 template void BufferedImage::setData(const typename DimensionTraits::VectorType& size, Components components, ComponentType type, const GLvoid* data, Buffer::Usage usage) { _components = components; _type = type; @@ -27,5 +28,6 @@ template void BufferedImage::setData(const template class BufferedImage<1>; template class BufferedImage<2>; template class BufferedImage<3>; +#endif } diff --git a/src/BufferedImage.h b/src/BufferedImage.h index 0831f653b..bcc10c985 100644 --- a/src/BufferedImage.h +++ b/src/BufferedImage.h @@ -15,9 +15,11 @@ GNU Lesser General Public License version 3 for more details. */ +#ifndef MAGNUM_TARGET_GLES2 /** @file * @brief Class Magnum::BufferedImage, typedef Magnum::BufferedImage1D, Magnum::BufferedImage2D, Magnum::BufferedImage3D */ +#endif #include "Math/Vector3.h" #include "AbstractImage.h" @@ -27,6 +29,7 @@ namespace Magnum { +#ifndef MAGNUM_TARGET_GLES2 /** @brief %Buffered image @@ -117,6 +120,7 @@ typedef BufferedImage<2> BufferedImage2D; /** @brief Three-dimensional buffered image */ typedef BufferedImage<3> BufferedImage3D; +#endif } diff --git a/src/Context.cpp b/src/Context.cpp index d26f2a97f..2b2eddd68 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -160,8 +160,13 @@ Context* Context::_current = nullptr; Context::Context() { /* Version */ + #ifndef MAGNUM_TARGET_GLES2 glGetIntegerv(GL_MAJOR_VERSION, &_majorVersion); glGetIntegerv(GL_MINOR_VERSION, &_minorVersion); + #else + _majorVersion = 2; + _minorVersion = 0; + #endif _version = static_cast(_majorVersion*100+_minorVersion*10); /* Get first future (not supported) version */ diff --git a/src/Framebuffer.cpp b/src/Framebuffer.cpp index c545c0dc6..f63c9915f 100644 --- a/src/Framebuffer.cpp +++ b/src/Framebuffer.cpp @@ -51,6 +51,7 @@ void Framebuffer::read(const Math::Vector2& offset, const Math::Vector2setData(size, components, type, data); } +#ifndef MAGNUM_TARGET_GLES2 void Framebuffer::read(const Math::Vector2& offset, const Math::Vector2& size, AbstractImage::Components components, AbstractImage::ComponentType type, BufferedImage2D* image, Buffer::Usage usage) { /* If the buffer doesn't have sufficient size, resize it */ /** @todo Explicitly reset also when buffer usage changes */ @@ -60,5 +61,6 @@ void Framebuffer::read(const Math::Vector2& offset, const Math::Vector2buffer()->bind(Buffer::Target::PixelPack); glReadPixels(offset.x(), offset.y(), size.x(), size.y(), static_cast(components), static_cast(type), nullptr); } +#endif } diff --git a/src/Framebuffer.h b/src/Framebuffer.h index 3edfac3fa..26c2aed44 100644 --- a/src/Framebuffer.h +++ b/src/Framebuffer.h @@ -29,12 +29,16 @@ namespace Magnum { +#ifndef MAGNUM_TARGET_GLES2 template class BufferedImage; +#endif template class Image; +#ifndef MAGNUM_TARGET_GLES2 typedef BufferedImage<1> BufferedImage1D; typedef BufferedImage<2> BufferedImage2D; typedef BufferedImage<3> BufferedImage3D; +#endif typedef Image<1> Image1D; typedef Image<2> Image2D; typedef Image<3> Image3D; @@ -433,8 +437,10 @@ class MAGNUM_EXPORT Framebuffer { enum class BlendEquation: GLenum { Add = GL_FUNC_ADD, /**< `source + destination` */ Subtract = GL_FUNC_SUBTRACT, /**< `source - destination` */ - ReverseSubtract = GL_FUNC_REVERSE_SUBTRACT, /**< `destination - source` */ + ReverseSubtract = GL_FUNC_REVERSE_SUBTRACT /**< `destination - source` */ + #ifndef MAGNUM_TARGET_GLES2 + , /** * `min(source, destination)` * @requires_gles30 %Extension @es_extension2{EXT,blend_minmax,blend_minmax} @@ -446,6 +452,7 @@ class MAGNUM_EXPORT Framebuffer { * @requires_gles30 %Extension @es_extension2{EXT,blend_minmax,blend_minmax} */ Max = GL_MAX + #endif }; /** @@ -1262,6 +1269,7 @@ class MAGNUM_EXPORT Framebuffer { */ static void read(const Math::Vector2& offset, const Math::Vector2& size, AbstractImage::Components components, AbstractImage::ComponentType type, Image2D* image); + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Read block of pixels from framebuffer to buffered image * @param offset Offset in the framebuffer @@ -1276,6 +1284,7 @@ class MAGNUM_EXPORT Framebuffer { * @requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0. */ static void read(const Math::Vector2& offset, const Math::Vector2& size, AbstractImage::Components components, AbstractImage::ComponentType type, BufferedImage2D* image, Buffer::Usage usage); + #endif /*@}*/ diff --git a/src/Implementation/BufferState.cpp b/src/Implementation/BufferState.cpp index b8ef09cd4..229be3504 100644 --- a/src/Implementation/BufferState.cpp +++ b/src/Implementation/BufferState.cpp @@ -21,14 +21,18 @@ namespace Magnum { namespace Implementation { const Buffer::Target BufferState::targetForIndex[] = { Buffer::Target::Array, + Buffer::Target::ElementArray + #ifndef MAGNUM_TARGET_GLES2 + , Buffer::Target::CopyRead, Buffer::Target::CopyWrite, - Buffer::Target::ElementArray, Buffer::Target::PixelPack, Buffer::Target::PixelUnpack, Buffer::Target::TransformFeedback, - Buffer::Target::Uniform, + Buffer::Target::Uniform + #endif #ifndef MAGNUM_TARGET_GLES + , Buffer::Target::AtomicCounter, Buffer::Target::DispatchIndirect, Buffer::Target::DrawIndirect, @@ -40,13 +44,15 @@ const Buffer::Target BufferState::targetForIndex[] = { std::size_t BufferState::indexForTarget(Buffer::Target target) { switch(target) { case Buffer::Target::Array: return 1; - case Buffer::Target::CopyRead: return 2; - case Buffer::Target::CopyWrite: return 3; - case Buffer::Target::ElementArray: return 4; + case Buffer::Target::ElementArray: return 2; + #ifndef MAGNUM_TARGET_GLES2 + case Buffer::Target::CopyRead: return 3; + case Buffer::Target::CopyWrite: return 4; case Buffer::Target::PixelPack: return 5; case Buffer::Target::PixelUnpack: return 6; case Buffer::Target::TransformFeedback: return 7; case Buffer::Target::Uniform: return 8; + #endif #ifndef MAGNUM_TARGET_GLES case Buffer::Target::AtomicCounter: return 9; case Buffer::Target::DispatchIndirect: return 10; diff --git a/src/Implementation/BufferState.h b/src/Implementation/BufferState.h index 3ea1e551b..097d3ea56 100644 --- a/src/Implementation/BufferState.h +++ b/src/Implementation/BufferState.h @@ -25,7 +25,11 @@ struct BufferState { #ifndef MAGNUM_TARGET_GLES static const std::size_t TargetCount = 13+1; #else + #ifndef MAGNUM_TARGET_GLES2 static const std::size_t TargetCount = 8+1; + #else + static const std::size_t TargetCount = 2+1; + #endif #endif /* Target <-> index mapping */ diff --git a/src/Renderbuffer.cpp b/src/Renderbuffer.cpp index aa08c7b63..bb5be459b 100644 --- a/src/Renderbuffer.cpp +++ b/src/Renderbuffer.cpp @@ -17,6 +17,7 @@ namespace Magnum { +#ifndef MAGNUM_TARGET_GLES2 Renderbuffer::InternalFormat::InternalFormat(Components components, ComponentType type) { #ifndef MAGNUM_TARGET_GLES #define internalFormatSwitch(c) switch(type) { \ @@ -71,5 +72,6 @@ Renderbuffer::InternalFormat::InternalFormat(Components components, ComponentTyp internalFormatSwitch(RGBA) #undef internalFormatSwitch } +#endif } diff --git a/src/Renderbuffer.h b/src/Renderbuffer.h index a2da42736..23b03e657 100644 --- a/src/Renderbuffer.h +++ b/src/Renderbuffer.h @@ -42,6 +42,7 @@ class Renderbuffer { public: /** @{ @name Internal renderbuffer formats */ + #ifndef MAGNUM_TARGET_GLES2 /** * @copybrief AbstractTexture::Components * @@ -67,6 +68,7 @@ class Renderbuffer { , NormalizedUnsignedShort #endif }; + #endif /** * @copybrief AbstractTexture::Format @@ -76,15 +78,27 @@ class Renderbuffer { * compressed formats, but with added separate stencil index. */ enum class Format: GLenum { - Red = GL_RED, RedGreen = GL_RG, RGBA = GL_RGBA, + #ifndef MAGNUM_TARGET_GLES2 + Red = GL_RED, RedGreen = GL_RG, + #endif + + RGBA = GL_RGBA, #ifndef MAGNUM_TARGET_GLES BGRA = GL_BGRA, #endif + #ifndef MAGNUM_TARGET_GLES2 SRGBA = GL_SRGB8_ALPHA8, RGB10Alpha2 = GL_RGB10_A2, - RGB10AlphaUnsigned2 = GL_RGB10_A2UI, RGB5Alpha1 = GL_RGB5_A1, - RGBA4 = GL_RGBA4, RFloat11GFloat11BFloat10 = GL_R11F_G11F_B10F, + RGB10AlphaUnsigned2 = GL_RGB10_A2UI, + #endif + + RGB5Alpha1 = GL_RGB5_A1, + RGBA4 = GL_RGBA4, + + #ifndef MAGNUM_TARGET_GLES2 + RFloat11GFloat11BFloat10 = GL_R11F_G11F_B10F, + #endif /* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is GL_ARB_ES2_compatibility */ @@ -156,8 +170,10 @@ class Renderbuffer { /** @copydoc AbstractTexture::InternalFormat */ class MAGNUM_EXPORT InternalFormat { public: + #ifndef MAGNUM_TARGET_GLES2 /** @copydoc AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components, AbstractTexture::ComponentType) */ InternalFormat(Components components, ComponentType type); + #endif /** @copydoc AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Format) */ inline constexpr InternalFormat(Format format): internalFormat(static_cast(format)) {} @@ -223,6 +239,7 @@ class Renderbuffer { GLuint renderbuffer; }; +#ifndef MAGNUM_TARGET_GLES2 /** @relates Renderbuffer @brief Convertor of component count and data type to InternalFormat @@ -237,6 +254,7 @@ inline Renderbuffer::InternalFormat operator|(Renderbuffer::Components component inline Renderbuffer::InternalFormat operator|(Renderbuffer::ComponentType type, Renderbuffer::Components components) { return Renderbuffer::InternalFormat(components, type); } +#endif }