diff --git a/src/AbstractObject.cpp b/src/AbstractObject.cpp index 6b5d9265b..74b2df9ba 100644 --- a/src/AbstractObject.cpp +++ b/src/AbstractObject.cpp @@ -26,6 +26,7 @@ #include +#include "Context.h" #include "Extensions.h" #include "Implementation/State.h" #include "Implementation/DebugState.h" diff --git a/src/AbstractShaderProgram.cpp b/src/AbstractShaderProgram.cpp index 53da8b755..dc01a1f84 100644 --- a/src/AbstractShaderProgram.cpp +++ b/src/AbstractShaderProgram.cpp @@ -25,6 +25,7 @@ #include "AbstractShaderProgram.h" #include "Math/RectangularMatrix.h" +#include "Context.h" #include "Extensions.h" #include "Shader.h" #include "Implementation/DebugState.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d1265f6d7..0b36a263b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -75,6 +75,7 @@ set(Magnum_SRCS Sampler.cpp Shader.cpp Timeline.cpp + Version.cpp Implementation/BufferState.cpp Implementation/DebugState.cpp @@ -143,6 +144,7 @@ set(Magnum_HEADERS TextureFormat.h Timeline.h Types.h + Version.h magnumVisibility.h) diff --git a/src/Context.cpp b/src/Context.cpp index 158073f7b..7c7d31929 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -45,33 +45,6 @@ namespace Magnum { -#ifndef DOXYGEN_GENERATING_OUTPUT -Debug operator<<(Debug debug, Version value) { - switch(value) { - #define _c(value, string) case Version::value: return debug << string; - _c(None, "None") - #ifndef MAGNUM_TARGET_GLES - _c(GL210, "OpenGL 2.1") - _c(GL300, "OpenGL 3.0") - _c(GL310, "OpenGL 3.1") - _c(GL320, "OpenGL 3.2") - _c(GL330, "OpenGL 3.3") - _c(GL400, "OpenGL 4.0") - _c(GL410, "OpenGL 4.1") - _c(GL420, "OpenGL 4.2") - _c(GL430, "OpenGL 4.3") - _c(GL440, "OpenGL 4.4") - #else - _c(GLES200, "OpenGL ES 2.0") - _c(GLES300, "OpenGL ES 3.0") - #endif - #undef _c - } - - return debug << "Invalid"; -} -#endif - 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()} diff --git a/src/Context.h b/src/Context.h index 0dbeff1e8..e6837c6bb 100644 --- a/src/Context.h +++ b/src/Context.h @@ -25,7 +25,7 @@ */ /** @file /Context.h - * @brief Class @ref Magnum::Context, @ref Magnum::Extension, enum @ref Magnum::Version, macro @ref MAGNUM_ASSERT_VERSION_SUPPORTED(), @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() + * @brief Class @ref Magnum::Context, @ref Magnum::Extension, macro @ref MAGNUM_ASSERT_VERSION_SUPPORTED(), @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() */ #include @@ -45,56 +45,6 @@ namespace Implementation { struct State; } -/** -@brief OpenGL version - -@see @ref Context, @ref MAGNUM_ASSERT_VERSION_SUPPORTED() -*/ -enum class Version: Int { - None = 0xFFFF, /**< @brief Unspecified */ - #ifndef MAGNUM_TARGET_GLES - GL210 = 210, /**< @brief OpenGL 2.1 / GLSL 1.20 */ - GL300 = 300, /**< @brief OpenGL 3.0 / GLSL 1.30 */ - GL310 = 310, /**< @brief OpenGL 3.1 / GLSL 1.40 */ - GL320 = 320, /**< @brief OpenGL 3.2 / GLSL 1.50 */ - GL330 = 330, /**< @brief OpenGL 3.3, GLSL 3.30 */ - 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 */ - GL440 = 440, /**< @brief OpenGL 4.4, GLSL 4.40 */ - #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::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::GL430. - */ - #ifndef MAGNUM_TARGET_GLES - GLES300 = 430 - #else - GLES300 = 300 - #endif -}; - -/** @debugoperator{Magnum::Context} */ -Debug MAGNUM_EXPORT operator<<(Debug debug, Version value); - /** @brief Run-time information about OpenGL extension diff --git a/src/Extensions.h b/src/Extensions.h index 4ae0faf3e..a9df50b48 100644 --- a/src/Extensions.h +++ b/src/Extensions.h @@ -28,7 +28,7 @@ * @brief Namespace Magnum::Extensions */ -#include "Context.h" +#include "Version.h" namespace Magnum { diff --git a/src/MeshTools/FullScreenTriangle.cpp b/src/MeshTools/FullScreenTriangle.cpp index 80d7ca37f..14ba470d1 100644 --- a/src/MeshTools/FullScreenTriangle.cpp +++ b/src/MeshTools/FullScreenTriangle.cpp @@ -29,6 +29,7 @@ #include "Buffer.h" #include "Context.h" #include "Mesh.h" +#include "Version.h" namespace Magnum { namespace MeshTools { diff --git a/src/Shader.cpp b/src/Shader.cpp index c841841f5..22a204b49 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -28,6 +28,7 @@ #include #include +#include "Context.h" #include "Extensions.h" #include "Implementation/DebugState.h" #include "Implementation/State.h" diff --git a/src/Shader.h b/src/Shader.h index 6764fde00..57680b960 100644 --- a/src/Shader.h +++ b/src/Shader.h @@ -32,8 +32,7 @@ #include #include "AbstractObject.h" -#include "Context.h" - +#include "Magnum.h" #include "magnumVisibility.h" namespace Magnum { diff --git a/src/Shaders/Flat.cpp b/src/Shaders/Flat.cpp index d729f85ed..97ef51c2f 100644 --- a/src/Shaders/Flat.cpp +++ b/src/Shaders/Flat.cpp @@ -26,6 +26,7 @@ #include +#include "Context.h" #include "Extensions.h" #include "Shader.h" diff --git a/src/Shaders/Phong.cpp b/src/Shaders/Phong.cpp index c352fc98a..78f0f844f 100644 --- a/src/Shaders/Phong.cpp +++ b/src/Shaders/Phong.cpp @@ -26,6 +26,7 @@ #include +#include "Context.h" #include "Extensions.h" #include "Shader.h" diff --git a/src/Shaders/VertexColor.cpp b/src/Shaders/VertexColor.cpp index a91dad60a..ce36675d6 100644 --- a/src/Shaders/VertexColor.cpp +++ b/src/Shaders/VertexColor.cpp @@ -26,6 +26,7 @@ #include +#include "Context.h" #include "Extensions.h" #include "Shader.h" diff --git a/src/Text/DistanceFieldGlyphCache.cpp b/src/Text/DistanceFieldGlyphCache.cpp index 9110108d4..64fc47517 100644 --- a/src/Text/DistanceFieldGlyphCache.cpp +++ b/src/Text/DistanceFieldGlyphCache.cpp @@ -27,6 +27,7 @@ #ifndef CORRADE_NO_ASSERT #include "ColorFormat.h" #endif +#include "Context.h" #include "Extensions.h" #include "ImageReference.h" #include "TextureFormat.h" diff --git a/src/Text/GlyphCache.cpp b/src/Text/GlyphCache.cpp index 75e82b236..b5f1beab3 100644 --- a/src/Text/GlyphCache.cpp +++ b/src/Text/GlyphCache.cpp @@ -24,6 +24,7 @@ #include "GlyphCache.h" +#include "Context.h" #include "Extensions.h" #include "Image.h" #include "TextureFormat.h" diff --git a/src/TextureTools/DistanceField.cpp b/src/TextureTools/DistanceField.cpp index 52e75465f..107d7d033 100644 --- a/src/TextureTools/DistanceField.cpp +++ b/src/TextureTools/DistanceField.cpp @@ -29,6 +29,7 @@ #include "Math/Range.h" #include "AbstractShaderProgram.h" #include "Buffer.h" +#include "Context.h" #include "Extensions.h" #include "Framebuffer.h" #include "Mesh.h" diff --git a/src/Version.cpp b/src/Version.cpp new file mode 100644 index 000000000..57cdd543b --- /dev/null +++ b/src/Version.cpp @@ -0,0 +1,58 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "Version.h" + +#include + +namespace Magnum { + +#ifndef DOXYGEN_GENERATING_OUTPUT +Debug operator<<(Debug debug, Version value) { + switch(value) { + #define _c(value, string) case Version::value: return debug << string; + _c(None, "None") + #ifndef MAGNUM_TARGET_GLES + _c(GL210, "OpenGL 2.1") + _c(GL300, "OpenGL 3.0") + _c(GL310, "OpenGL 3.1") + _c(GL320, "OpenGL 3.2") + _c(GL330, "OpenGL 3.3") + _c(GL400, "OpenGL 4.0") + _c(GL410, "OpenGL 4.1") + _c(GL420, "OpenGL 4.2") + _c(GL430, "OpenGL 4.3") + _c(GL440, "OpenGL 4.4") + #else + _c(GLES200, "OpenGL ES 2.0") + _c(GLES300, "OpenGL ES 3.0") + #endif + #undef _c + } + + return debug << "Invalid"; +} +#endif + +} diff --git a/src/Version.h b/src/Version.h new file mode 100644 index 000000000..ba2ed5b7d --- /dev/null +++ b/src/Version.h @@ -0,0 +1,88 @@ +#ifndef Magnum_Version_h +#define Magnum_Version_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "Magnum.h" +#include "magnumVisibility.h" + +/** @file Version.h + * Enum @ref Magnum::Version + */ + +namespace Magnum { + +/** +@brief OpenGL version + +@see @ref Context, @ref MAGNUM_ASSERT_VERSION_SUPPORTED() +*/ +enum class Version: Int { + None = 0xFFFF, /**< @brief Unspecified */ + #ifndef MAGNUM_TARGET_GLES + GL210 = 210, /**< @brief OpenGL 2.1 / GLSL 1.20 */ + GL300 = 300, /**< @brief OpenGL 3.0 / GLSL 1.30 */ + GL310 = 310, /**< @brief OpenGL 3.1 / GLSL 1.40 */ + GL320 = 320, /**< @brief OpenGL 3.2 / GLSL 1.50 */ + GL330 = 330, /**< @brief OpenGL 3.3, GLSL 3.30 */ + 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 */ + GL440 = 440, /**< @brief OpenGL 4.4, GLSL 4.40 */ + #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::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::GL430. + */ + #ifndef MAGNUM_TARGET_GLES + GLES300 = 430 + #else + GLES300 = 300 + #endif +}; + +/** @debugoperator{Magnum::Context} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, Version value); + +} + +#endif