diff --git a/doc/changelog.dox b/doc/changelog.dox index 0b45bbee3..e70fd33da 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -1467,6 +1467,8 @@ See also: @ref GL::Buffer::setLabel() "setLabel()" APIs now work with a @relativeref{Corrade,Containers::StringView} / @relativeref{Corrade,Containers::String} instead of a @ref std::string + - @ref GL::version(Version) now returns a + @relativeref{Corrade,Containers::Pair} instead of a @ref std::pair - @ref MeshTools::compressIndices(), @ref MeshTools::removeDuplicates() and related APIs now return a @relativeref{Corrade,Containers::Pair} instead of a @ref std::pair diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index 4d81498ad..c6f0c2406 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -920,9 +920,9 @@ bool Context::tryCreate(const Configuration& configuration) { #endif { #ifndef MAGNUM_TARGET_GLES - Error{} << "GL::Context: unsupported OpenGL version" << std::make_pair(majorVersion, minorVersion); + Error{} << "GL::Context: unsupported OpenGL version" << Containers::pair(majorVersion, minorVersion); #else - Error{} << "GL::Context: unsupported OpenGL ES version" << std::make_pair(majorVersion, minorVersion); + Error{} << "GL::Context: unsupported OpenGL ES version" << Containers::pair(majorVersion, minorVersion); #endif /* Reset the version so the context is not marked as successfully created */ diff --git a/src/Magnum/GL/Test/VersionTest.cpp b/src/Magnum/GL/Test/VersionTest.cpp index 2ecee5f0f..ec29a97d1 100644 --- a/src/Magnum/GL/Test/VersionTest.cpp +++ b/src/Magnum/GL/Test/VersionTest.cpp @@ -24,6 +24,7 @@ */ #include +#include #include #include @@ -76,15 +77,15 @@ void VersionTest::fromNumber() { void VersionTest::toNumber() { #ifndef MAGNUM_TARGET_GLES - CORRADE_COMPARE(version(Version::GL430), std::make_pair(4, 3)); + CORRADE_COMPARE(version(Version::GL430), Containers::pair(4, 3)); #else - CORRADE_COMPARE(version(Version::GLES300), std::make_pair(3, 0)); + CORRADE_COMPARE(version(Version::GLES300), Containers::pair(3, 0)); #endif } #ifndef MAGNUM_TARGET_GLES void VersionTest::toNumberES() { - CORRADE_COMPARE(version(Version::GLES310), std::make_pair(3, 1)); + CORRADE_COMPARE(version(Version::GLES310), Containers::pair(3, 1)); } #endif diff --git a/src/Magnum/GL/Version.cpp b/src/Magnum/GL/Version.cpp index eacf89d33..0061b518f 100644 --- a/src/Magnum/GL/Version.cpp +++ b/src/Magnum/GL/Version.cpp @@ -25,10 +25,20 @@ #include "Version.h" +#include #include namespace Magnum { namespace GL { +Containers::Pair version(const Version version) { + const Int v = Int(version) + #ifndef MAGNUM_TARGET_GLES + & ~Implementation::VersionESMask + #endif + ; + return {v/100, (v%100)/10}; +} + #ifndef DOXYGEN_GENERATING_OUTPUT Debug& operator<<(Debug& debug, const Version value) { switch(value) { diff --git a/src/Magnum/GL/Version.h b/src/Magnum/GL/Version.h index ee57d5777..a89737f02 100644 --- a/src/Magnum/GL/Version.h +++ b/src/Magnum/GL/Version.h @@ -29,11 +29,14 @@ * @brief Enum @ref Magnum::GL::Version, function @ref Magnum::GL::version(), @ref Magnum::GL::isVersionES() */ -#include /* std::pair */ - #include "Magnum/Magnum.h" #include "Magnum/GL/visibility.h" +#ifdef MAGNUM_BUILD_DEPRECATED +/* version() returned std::pair before */ +#include +#endif + namespace Magnum { namespace GL { #ifndef MAGNUM_TARGET_GLES @@ -135,14 +138,7 @@ constexpr Version version(Int major, Int minor) { @see @ref isVersionES() */ -inline std::pair version(Version version) { - const Int v = Int(version) - #ifndef MAGNUM_TARGET_GLES - & ~Implementation::VersionESMask - #endif - ; - return {v/100, (v%100)/10}; -} +MAGNUM_GL_EXPORT Containers::Pair version(Version version); /** @brief Whether given version is OpenGL ES or WebGL diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 1f97ff697..45fd61e51 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -28,7 +28,6 @@ #include "GlfwApplication.h" -#include #include #include #include @@ -463,10 +462,9 @@ bool GlfwApplication::tryCreate(const Configuration& configuration, const GLConf /* Set context version, if requested */ if(glConfiguration.version() != GL::Version::None) { - Int major, minor; - std::tie(major, minor) = version(glConfiguration.version()); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor); + const Containers::Pair versionMajorMinor = version(glConfiguration.version()); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, versionMajorMinor.first()); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, versionMajorMinor.second()); #ifndef MAGNUM_TARGET_GLES if(glConfiguration.version() >= GL::Version::GL320) { glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); diff --git a/src/Magnum/Platform/Implementation/EglContextHandler.cpp b/src/Magnum/Platform/Implementation/EglContextHandler.cpp index ed1435d9d..ff678f668 100644 --- a/src/Magnum/Platform/Implementation/EglContextHandler.cpp +++ b/src/Magnum/Platform/Implementation/EglContextHandler.cpp @@ -25,7 +25,6 @@ #include "EglContextHandler.h" -#include #include #include @@ -112,13 +111,12 @@ void EglContextHandler::createContext(const AbstractXApplication::GLConfiguratio EGL_KHR_create_context. */ /** @todo Test for presence of EGL_KHR_create_context extension */ if(glConfiguration.version() != GL::Version::None) { - Int major, minor; - std::tie(major, minor) = version(glConfiguration.version()); + const Containers::Pair versionMajorMinor = version(glConfiguration.version()); attributes[0] = EGL_CONTEXT_MAJOR_VERSION_KHR; - attributes[1] = major; + attributes[1] = versionMajorMinor.first(); attributes[2] = EGL_CONTEXT_MINOR_VERSION_KHR; - attributes[3] = minor; + attributes[3] = versionMajorMinor.second(); #ifndef MAGNUM_TARGET_GLES if(glConfiguration.version() >= GL::Version::GL310) { diff --git a/src/Magnum/Platform/Implementation/GlxContextHandler.cpp b/src/Magnum/Platform/Implementation/GlxContextHandler.cpp index f49d0da55..62d64d0c8 100644 --- a/src/Magnum/Platform/Implementation/GlxContextHandler.cpp +++ b/src/Magnum/Platform/Implementation/GlxContextHandler.cpp @@ -26,7 +26,6 @@ #include "GlxContextHandler.h" #include -#include #include #include @@ -86,13 +85,12 @@ void GlxContextHandler::createContext(const AbstractXApplication::GLConfiguratio /* Set context version, if requested */ if(glConfiguration.version() != GL::Version::None) { - Int major, minor; - std::tie(major, minor) = version(glConfiguration.version()); + const Containers::Pair versionMajorMinor = version(glConfiguration.version()); attributes[0] = GLX_CONTEXT_MAJOR_VERSION_ARB; - attributes[1] = major; + attributes[1] = versionMajorMinor.first(); attributes[2] = GLX_CONTEXT_MINOR_VERSION_ARB; - attributes[3] = minor; + attributes[3] = versionMajorMinor.second(); #ifndef MAGNUM_TARGET_GLES if(glConfiguration.version() >= GL::Version::GL310) { diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 86b9d6e2b..f2224a068 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -38,9 +38,7 @@ #ifdef CORRADE_TARGET_CLANG_CL #pragma clang diagnostic pop #endif -#ifndef CORRADE_TARGET_EMSCRIPTEN -#include -#else +#ifdef CORRADE_TARGET_EMSCRIPTEN #include #include #endif @@ -515,10 +513,9 @@ bool Sdl2Application::tryCreate(const Configuration& configuration, const GLConf /* Set context version, if user-specified */ if(glConfiguration.version() != GL::Version::None) { - Int major, minor; - std::tie(major, minor) = version(glConfiguration.version()); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor); + const Containers::Pair versionMajorMinor = version(glConfiguration.version()); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, versionMajorMinor.first()); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, versionMajorMinor.second()); #ifndef MAGNUM_TARGET_GLES SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, glConfiguration.version() >= GL::Version::GL310 ?