From 45a236fb072923d8d4b4d918b6f6546d26ba0bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 10 Nov 2012 20:29:03 +0100 Subject: [PATCH] Temporary workaround for extension-only functionality in ES 2.0. Will be re-enabled when some solution for extensions is done. --- src/Framebuffer.h | 27 +++++++++++++++++++++++++++ src/Query.h | 14 ++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/Framebuffer.h b/src/Framebuffer.h index 26c2aed44..77b1a1746 100644 --- a/src/Framebuffer.h +++ b/src/Framebuffer.h @@ -945,7 +945,12 @@ class MAGNUM_EXPORT Framebuffer { */ inline static void mapDefaultForRead(DefaultReadAttachment attachment) { bindDefault(Target::Read); + /** @todo Get some extension wrangler instead to avoid undeclared glReadBuffer() on ES2 */ + #ifndef MAGNUM_TARGET_GLES2 glReadBuffer(static_cast(attachment)); + #else + static_cast(attachment); + #endif } /** @@ -960,7 +965,12 @@ class MAGNUM_EXPORT Framebuffer { */ inline void mapForRead(std::uint8_t colorAttachment) { bind(Target::Read); + /** @todo Get some extension wrangler instead to avoid undeclared glReadBuffer() on ES2 */ + #ifndef MAGNUM_TARGET_GLES2 glReadBuffer(GL_COLOR_ATTACHMENT0 + colorAttachment); + #else + static_cast(colorAttachment); + #endif } /*@}*/ @@ -1232,7 +1242,17 @@ class MAGNUM_EXPORT Framebuffer { * @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} */ inline static void blit(const Math::Vector2& bottomLeft, const Math::Vector2& topRight, const Math::Vector2& destinationBottomLeft, const Math::Vector2& destinationTopRight, BlitMask blitMask, AbstractTexture::Filter filter) { + /** @todo Get some extension wrangler instead to avoid undeclared glBlitFramebuffer() on ES2 */ + #ifndef MAGNUM_TARGET_GLES2 glBlitFramebuffer(bottomLeft.x(), bottomLeft.y(), topRight.x(), topRight.y(), destinationBottomLeft.x(), destinationBottomLeft.y(), destinationTopRight.x(), destinationTopRight.y(), static_cast(blitMask), static_cast(filter)); + #else + static_cast(bottomLeft); + static_cast(topRight); + static_cast(destinationBottomLeft); + static_cast(destinationTopRight); + static_cast(blitMask); + static_cast(filter); + #endif } /** @@ -1253,7 +1273,14 @@ class MAGNUM_EXPORT Framebuffer { * @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} */ inline static void blit(const Math::Vector2& bottomLeft, const Math::Vector2& topRight, BlitMask blitMask) { + /** @todo Get some extension wrangler instead to avoid undeclared glBlitFramebuffer() on ES2 */ + #ifndef MAGNUM_TARGET_GLES2 glBlitFramebuffer(bottomLeft.x(), bottomLeft.y(), topRight.x(), topRight.y(), bottomLeft.x(), bottomLeft.y(), topRight.x(), topRight.y(), static_cast(blitMask), static_cast(AbstractTexture::Filter::NearestNeighbor)); + #else + static_cast(bottomLeft); + static_cast(topRight); + static_cast(blitMask); + #endif } /** diff --git a/src/Query.h b/src/Query.h index 4657775c4..4816ba2a7 100644 --- a/src/Query.h +++ b/src/Query.h @@ -40,7 +40,12 @@ class MAGNUM_EXPORT AbstractQuery { * Generates one OpenGL query. * @see @fn_gl{GenQueries} */ - inline AbstractQuery() { glGenQueries(1, &_id); } + inline AbstractQuery() { + /** @todo Get some extension wrangler instead to avoid undeclared glGenQueries() on ES2 */ + #ifndef MAGNUM_TARGET_GLES2 + glGenQueries(1, &_id); + #endif + } /** * @brief Destructor @@ -48,7 +53,12 @@ class MAGNUM_EXPORT AbstractQuery { * Deletes assigned OpenGL query. * @see @fn_gl{DeleteQueries} */ - virtual inline ~AbstractQuery() { glDeleteQueries(1, &_id); } + virtual inline ~AbstractQuery() { + /** @todo Get some extension wrangler instead to avoid undeclared glGenQueries() on ES2 */ + #ifndef MAGNUM_TARGET_GLES2 + glDeleteQueries(1, &_id); + #endif + } /** @brief OpenGL query ID */ inline GLuint id() const { return _id; }