From e2023ab2785f165d9f0794cf5ec05df734d61e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 2 Nov 2012 12:32:52 +0100 Subject: [PATCH] Updated OpenGL ES support in Context and related files. --- src/Context.cpp | 28 +++++++++++++++++++++++++++- src/Context.h | 29 ++++++++++++++++++++++++++--- src/Extensions.h | 2 ++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index a9afef9f9..eab210cba 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -36,6 +36,7 @@ const std::vector& Extension::extensions(Version version) { #define _extension(prefix, vendor, extension) \ {Extensions::prefix::vendor::extension::Index, Extensions::prefix::vendor::extension::requiredVersion(), Extensions::prefix::vendor::extension::coreVersion(), Extensions::prefix::vendor::extension::string()} static const std::vector empty; + #ifndef MAGNUM_TARGET_GLES static const std::vector extensions{ _extension(GL,EXT,texture_filter_anisotropic)}; static const std::vector extensions300{ @@ -126,18 +127,30 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,ARB,texture_storage)}; static const std::vector extensions430; #undef _extension + #else + static const std::vector extensions; + static const std::vector extensionsES200; + static const std::vector extensionsES300; + #endif switch(version) { case Version::None: return extensions; + #ifndef MAGNUM_TARGET_GLES case Version::GL210: return empty; case Version::GL300: return extensions300; case Version::GL310: return extensions310; case Version::GL320: return extensions320; case Version::GL330: return extensions330; case Version::GL400: return extensions400; + /* case Version::GLES200: */ case Version::GL410: return extensions410; case Version::GL420: return extensions420; + /* case Version::GLES300: */ case Version::GL430: return extensions430; + #else + case Version::GLES200: return extensionsES200; + case Version::GLES300: return extensionsES300; + #endif } return empty; @@ -153,6 +166,7 @@ Context::Context() { /* Get first future (not supported) version */ vector versions{ + #ifndef MAGNUM_TARGET_GLES Version::GL300, Version::GL310, Version::GL320, @@ -161,6 +175,10 @@ Context::Context() { Version::GL410, Version::GL420, Version::GL430, + #else + Version::GLES200, + Version::GLES300, + #endif Version::None }; size_t future = 0; @@ -176,7 +194,12 @@ Context::Context() { futureExtensions.insert(make_pair(extension._string, extension)); /* Check for presence of extensions in future versions */ + #ifndef MAGNUM_TARGET_GLES if(isVersionSupported(Version::GL300)) { + #else + if(isVersionSupported(Version::GLES300)) { + #endif + #ifndef MAGNUM_TARGET_GLES2 GLuint index = 0; const char* extension; while((extension = reinterpret_cast(glGetStringi(GL_EXTENSIONS, index++)))) { @@ -186,8 +209,9 @@ Context::Context() { extensionStatus.set(found->second._index); } } + #endif - /* OpenGL 2.1 doesn't have glGetStringi() */ + /* OpenGL 2.1 / OpenGL ES 2.0 doesn't have glGetStringi() */ } else { vector extensions = Corrade::Utility::split(reinterpret_cast(glGetString(GL_EXTENSIONS)), ' '); for(const string& extension: extensions) { @@ -210,7 +234,9 @@ Context::Context() { AbstractShaderProgram::initializeContextBasedFunctionality(this); AbstractTexture::initializeContextBasedFunctionality(this); Buffer::initializeContextBasedFunctionality(this); + #ifndef MAGNUM_TARGET_GLES BufferedTexture::initializeContextBasedFunctionality(this); + #endif IndexedMesh::initializeContextBasedFunctionality(this); Mesh::initializeContextBasedFunctionality(this); } diff --git a/src/Context.h b/src/Context.h index 3ac3de27e..3443cf0dc 100644 --- a/src/Context.h +++ b/src/Context.h @@ -46,10 +46,33 @@ enum class Version: GLint { GL400 = 400, /**< @brief OpenGL 4.0, GLSL 4.00 */ GL410 = 410, /**< @brief OpenGL 4.1, GLSL 4.10 */ GL420 = 420, /**< @brief OpenGL 4.2, GLSL 4.20 */ - GL430 = 430 /**< @brief OpenGL 4.3, GLSL 4.30 */ + GL430 = 430, /**< @brief OpenGL 4.3, GLSL 4.30 */ + #endif + + /** + * @brief OpenGL ES 2.0, GLSL ES 1.00 + * + * All the functionality is present in OpenGL 4.2 (extension + * @extension{ARB,ES2_compatibility}), so on desktop OpenGL this is + * equivalent to @ref Version "Version::GL410". + */ + #ifndef MAGNUM_TARGET_GLES + GLES200 = 410, + #else + GLES200 = 200, + #endif + + /** + * @brief OpenGL ES 3.0, GLSL ES 3.00 + * + * All the functionality is present in OpenGL 4.3 (extension + * @extension{ARB,ES3_compatibility}), so on desktop OpenGL this is the + * equivalent to @ref Version "Version::GL430". + */ + #ifndef MAGNUM_TARGET_GLES + GLES300 = 430, #else - GLES200 = 200, /**< @brief OpenGL ES 2.0, GLSL ES 1.00 */ - GLES300 = 300 /**< @brief OpenGL ES 3.0, GLSL ES 3.00 */ + GLES300 = 300 #endif }; diff --git a/src/Extensions.h b/src/Extensions.h index e656bc447..8f7438cf2 100644 --- a/src/Extensions.h +++ b/src/Extensions.h @@ -35,6 +35,7 @@ example usage. */ namespace Extensions { +#ifndef MAGNUM_TARGET_GLES #ifndef DOXYGEN_GENERATING_OUTPUT #define _extension(prefix, vendor, extension, _requiredVersion, _coreVersion) \ struct extension { \ @@ -139,6 +140,7 @@ namespace GL { } #undef _extension #endif +#endif }