diff --git a/doc/changelog.dox b/doc/changelog.dox index b29041dd2..39c4375f0 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -56,6 +56,8 @@ See also: which is from 2011) has been dropped from @ref Platform::AndroidApplication. - Support for SDL2 older than 2.0.6 (released in 2017) has been dropped from @ref Platform::Sdl2Application. +- Support for GLFW older than 3.2 (released in 2016) has been dropped from + @ref Platform::GlfwApplication. @subsection changelog-latest-new New features diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 441a7ac59..acce4b083 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -265,7 +265,6 @@ void GlfwApplication::setWindowTitle(const Containers::StringView title) { glfwSetWindowTitle(_window, Containers::String::nullTerminatedView(title).data()); } -#if GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 void GlfwApplication::setWindowIcon(const ImageView2D& image) { setWindowIcon({&image, 1}); } @@ -325,14 +324,10 @@ void GlfwApplication::setWindowIcon(const Containers::ArrayView images) { setWindowIcon(Containers::arrayView(images)); } -#endif bool GlfwApplication::tryCreate(const Configuration& configuration) { #ifdef MAGNUM_TARGET_GL - #ifdef GLFW_NO_API - if(!(configuration.windowFlags() & Configuration::WindowFlag::Contextless)) - #endif - { + if(!(configuration.windowFlags() & Configuration::WindowFlag::Contextless)) { return tryCreate(configuration, GLConfiguration{}); } #endif @@ -355,17 +350,13 @@ bool GlfwApplication::tryCreate(const Configuration& configuration) { glfwWindowHint(GLFW_DECORATED, !(flags >= Configuration::WindowFlag::Borderless)); glfwWindowHint(GLFW_RESIZABLE, flags >= Configuration::WindowFlag::Resizable); glfwWindowHint(GLFW_VISIBLE, !(flags >= Configuration::WindowFlag::Hidden)); - #ifdef GLFW_MAXIMIZED glfwWindowHint(GLFW_MAXIMIZED, flags >= Configuration::WindowFlag::Maximized); - #endif glfwWindowHint(GLFW_FLOATING, flags >= Configuration::WindowFlag::AlwaysOnTop); } glfwWindowHint(GLFW_FOCUSED, configuration.windowFlags() >= Configuration::WindowFlag::Focused); - #ifdef GLFW_NO_API /* Disable implicit GL context creation */ glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - #endif /* Create the window */ CORRADE_INTERNAL_ASSERT(configuration.title().flags() & Containers::StringViewFlag::NullTerminated); @@ -437,9 +428,7 @@ bool GlfwApplication::tryCreate(const Configuration& configuration, const GLConf glfwWindowHint(GLFW_DECORATED, !(flags >= Configuration::WindowFlag::Borderless)); glfwWindowHint(GLFW_RESIZABLE, flags >= Configuration::WindowFlag::Resizable); glfwWindowHint(GLFW_VISIBLE, !(flags >= Configuration::WindowFlag::Hidden)); - #ifdef GLFW_MAXIMIZED glfwWindowHint(GLFW_MAXIMIZED, flags >= Configuration::WindowFlag::Maximized); - #endif glfwWindowHint(GLFW_FLOATING, flags >= Configuration::WindowFlag::AlwaysOnTop); } glfwWindowHint(GLFW_FOCUSED, configuration.windowFlags() >= Configuration::WindowFlag::Focused); @@ -459,14 +448,10 @@ bool GlfwApplication::tryCreate(const Configuration& configuration, const GLConf GLConfiguration::Flags glFlags = glConfiguration.flags(); if((glFlags & GLConfiguration::Flag::GpuValidation) || (_context->configurationFlags() & GL::Context::Configuration::Flag::GpuValidation)) glFlags |= GLConfiguration::Flag::Debug; - #ifdef GLFW_CONTEXT_NO_ERROR else if((glFlags & GLConfiguration::Flag::GpuValidationNoError) || (_context->configurationFlags() & GL::Context::Configuration::Flag::GpuValidationNoError)) glFlags |= GLConfiguration::Flag::NoError; - #endif - #ifdef GLFW_CONTEXT_NO_ERROR glfwWindowHint(GLFW_CONTEXT_NO_ERROR, glFlags >= GLConfiguration::Flag::NoError); - #endif glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, glFlags >= GLConfiguration::Flag::Debug); glfwWindowHint(GLFW_STEREO, glFlags >= GLConfiguration::Flag::Stereo); @@ -771,7 +756,6 @@ void GlfwApplication::setWindowSize(const Vector2i& size) { glfwSetWindowSize(_window, newSize.x(), newSize.y()); } -#if GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 void GlfwApplication::setMinWindowSize(const Vector2i& size) { CORRADE_ASSERT(_window, "Platform::GlfwApplication::setMinWindowSize(): no window opened", ); @@ -787,7 +771,6 @@ void GlfwApplication::setMaxWindowSize(const Vector2i& size) { glfwSetWindowSizeLimits(_window, _minWindowSize.x(), _minWindowSize.y(), newSize.x(), newSize.y()); _maxWindowSize = newSize; } -#endif #ifdef MAGNUM_TARGET_GL Vector2i GlfwApplication::framebufferSize() const { @@ -1124,7 +1107,6 @@ GlfwApplication::Configuration::Configuration(): GlfwApplication::Configuration::~Configuration() = default; -#if defined(DOXYGEN_GENERATING_OUTPUT) || GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 Containers::StringView GlfwApplication::KeyEvent::keyName(const Key key) { return glfwGetKeyName(int(key), 0); } @@ -1132,7 +1114,6 @@ Containers::StringView GlfwApplication::KeyEvent::keyName(const Key key) { Containers::StringView GlfwApplication::KeyEvent::keyName() const { return keyName(_key); } -#endif GlfwApplication::Pointers GlfwApplication::PointerMoveEvent::pointers() { if(!_pointers) diff --git a/src/Magnum/Platform/GlfwApplication.h b/src/Magnum/Platform/GlfwApplication.h index 91487b9f0..9e240c25a 100644 --- a/src/Magnum/Platform/GlfwApplication.h +++ b/src/Magnum/Platform/GlfwApplication.h @@ -100,8 +100,8 @@ See @ref cmake for more information. @section Platform-GlfwApplication-usage General usage -This application library depends on the [GLFW](http://glfw.org) library and is -built if `MAGNUM_WITH_GLFWAPPLICATION` is enabled when building Magnum. To use +This application library depends on [GLFW](http://glfw.org) 3.2 and newer and +is built if `MAGNUM_WITH_GLFWAPPLICATION` is enabled when building Magnum. To use this library with CMake, request the `GlfwApplication` component of the `Magnum` package and link to the `Magnum::GlfwApplication` target: @@ -121,7 +121,7 @@ necessary. @code{.cmake} set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) -# These two will be off-by-default when GLFW 3.4 gets released +# These two are be off-by-default and thus no longer needed with GLFW 3.4+ set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) add_subdirectory(glfw EXCLUDE_FROM_ALL) @@ -419,7 +419,6 @@ class GlfwApplication { */ void setWindowSize(const Vector2i& size); - #if GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 || defined(DOXYGEN_GENERATING_OUTPUT) /** * @brief Set window minimum size * @param size The minimum size, in screen coordinates @@ -429,7 +428,6 @@ class GlfwApplication { * corresponding limit. To make the sizing work independently of the * display DPI, @p size is internally multiplied with @ref dpiScaling() * before getting applied. Expects that a window is already created. - * @note Supported since GLFW 3.2. * @see @ref setMaxWindowSize(), @ref setWindowSize() */ void setMinWindowSize(const Vector2i& size = {-1, -1}); @@ -443,11 +441,9 @@ class GlfwApplication { * corresponding limit. To make the sizing work independently of the * display DPI, @p size is internally multiplied with @ref dpiScaling() * before getting applied. Expects that a window is already created. - * @note Supported since GLFW 3.2. * @see @ref setMinWindowSize(), @ref setMaxWindowSize() */ void setMaxWindowSize(const Vector2i& size = {-1, -1}); - #endif #if defined(MAGNUM_TARGET_GL) || defined(DOXYGEN_GENERATING_OUTPUT) /** @@ -497,7 +493,6 @@ class GlfwApplication { */ void setWindowTitle(Containers::StringView title); - #if GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 || defined(DOXYGEN_GENERATING_OUTPUT) /** * @brief Set window icon * @m_since_latest @@ -508,8 +503,8 @@ class GlfwApplication { * @ref PixelFormat::RGBA8Unorm or @ref PixelFormat::RGBA8Srgb formats. * If you have just one image, you can use * @ref setWindowIcon(const ImageView2D&) instead. - * @note Available since GLFW 3.2. The function has no effect on macOS - * / Wayland, see @m_class{m-doc-external} [glfwSetWindowIcon()](https://www.glfw.org/docs/latest/group__window.html#gadd7ccd39fe7a7d1f0904666ae5932dc5) + * @note The function has no effect on macOS / Wayland, see + * @m_class{m-doc-external} [glfwSetWindowIcon()](https://www.glfw.org/docs/latest/group__window.html#gadd7ccd39fe7a7d1f0904666ae5932dc5) * for more information. * @see @ref platform-windows-icon "Excecutable icon on Windows", * @ref Trade::IcoImporter "IcoImporter" @@ -527,7 +522,6 @@ class GlfwApplication { * @m_since{2020,06} */ void setWindowIcon(const ImageView2D& image); - #endif /** * @brief Swap buffers @@ -1058,7 +1052,6 @@ class GlfwApplication::GLConfiguration: public GL::Context::Configuration { ForwardCompatible = 1 << 0, #endif - #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(GLFW_CONTEXT_NO_ERROR) /** * Context without error reporting. Might result in better * performance, but situations that would have generated errors @@ -1066,11 +1059,8 @@ class GlfwApplication::GLConfiguration: public GL::Context::Configuration { * supported by the driver and the @ref Flag::GpuValidationNoError * flag is set or if the `--magnum-gpu-validation` @ref GL-Context-usage-command-line "command-line option" * is set to `no-error`. - * - * @note Supported since GLFW 3.2. */ NoError = 1 << 1, - #endif /** * Debug context. Enabled automatically if supported by the driver @@ -1313,15 +1303,7 @@ class GlfwApplication::Configuration { Resizable = 1 << 2, /**< Resizable window */ Hidden = 1 << 3, /**< Hidden window */ - - #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(GLFW_MAXIMIZED) - /** - * Maximized window - * - * @note Supported since GLFW 3.2. - */ - Maximized = 1 << 4, - #endif + Maximized = 1 << 4, /**< Maximized window */ Minimized = 1 << 5, /**< Minimized window */ @@ -1352,7 +1334,6 @@ class GlfwApplication::Configuration { */ Focused = 1 << 8, - #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(GLFW_NO_API) /** * Do not create any GPU context. Use together with * @ref GlfwApplication(const Arguments&, const Configuration&), @@ -1362,11 +1343,8 @@ class GlfwApplication::Configuration { * @ref GlfwApplication(const Arguments&, const Configuration&, const GLConfiguration&), * @ref create(const Configuration&, const GLConfiguration&) or * @ref tryCreate(const Configuration&, const GLConfiguration&). - * - * @note Supported since GLFW 3.2. */ Contextless = 1 << 9 - #endif }; /** @@ -2097,7 +2075,6 @@ class GlfwApplication::KeyEvent: public GlfwApplication::InputEvent { NumEqual = GLFW_KEY_KP_EQUAL /**< Numpad equal */ }; - #if defined(DOXYGEN_GENERATING_OUTPUT) || GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 /** * @brief Name for given key * @@ -2108,15 +2085,12 @@ class GlfwApplication::KeyEvent: public GlfwApplication::InputEvent { * and is valid until the keyboard layout is changed or the application * exits. * @see @ref keyName(Key) - * @note Supported since GLFW 3.2. */ static Containers::StringView keyName(Key key); - #endif /** @copydoc Sdl2Application::KeyEvent::key() */ Key key() const { return _key; } - #if defined(DOXYGEN_GENERATING_OUTPUT) || GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 /** * @brief Key name * @@ -2128,10 +2102,8 @@ class GlfwApplication::KeyEvent: public GlfwApplication::InputEvent { * is valid until the keyboard layout is changed or the application * exits. * @see @ref keyName(Key) - * @note Supported since GLFW 3.2. */ Containers::StringView keyName() const; - #endif /** @brief Modifiers */ Modifiers modifiers() const { return _modifiers; } diff --git a/src/Magnum/Platform/Test/GlfwApplicationTest.cpp b/src/Magnum/Platform/Test/GlfwApplicationTest.cpp index 7ba653a9f..0b2390146 100644 --- a/src/Magnum/Platform/Test/GlfwApplicationTest.cpp +++ b/src/Magnum/Platform/Test/GlfwApplicationTest.cpp @@ -299,11 +299,7 @@ struct GlfwApplicationTest: Platform::Application { } void keyPressEvent(KeyEvent& event) override { - Debug{} << "key press:" << event.key() << int(event.key()) - #if GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 - << event.keyName() - #endif - << event.modifiers(); + Debug{} << "key press:" << event.key() << int(event.key()) << event.keyName() << event.modifiers(); if(event.key() == KeyEvent::Key::F1) { Debug{} << "starting text input"; @@ -325,14 +321,10 @@ struct GlfwApplicationTest: Platform::Application { } else if(event.key() == KeyEvent::Key::S) { Debug{} << "setting window size, which should trigger a viewport event"; setWindowSize(Vector2i{300, 200}); - } - #if GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 - else if(event.key() == KeyEvent::Key::W) { + } else if(event.key() == KeyEvent::Key::W) { Debug{} << "setting max window size, which should trigger a viewport event if the size changes"; setMaxWindowSize(Vector2i{700, 500}); - } - #endif - else if(event.key() == KeyEvent::Key::H) { + } else if(event.key() == KeyEvent::Key::H) { Debug{} << "toggling hand cursor"; setCursor(cursor() == Cursor::Arrow ? Cursor::Hand : Cursor::Arrow); } else if(event.key() == KeyEvent::Key::L) { @@ -345,11 +337,7 @@ struct GlfwApplicationTest: Platform::Application { } void keyReleaseEvent(KeyEvent& event) override { - Debug{} << "key release:" << event.key() << int(event.key()) - #if GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 - << event.keyName() - #endif - << event.modifiers(); + Debug{} << "key release:" << event.key() << int(event.key()) << event.keyName() << event.modifiers(); } /* Set to 0 to test the deprecated mouse events instead */ @@ -453,7 +441,6 @@ GlfwApplicationTest::GlfwApplicationTest(const Arguments& arguments): Platform:: #endif << dpiScaling(); - #if GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 Utility::Resource rs{"icons"}; PluginManager::Manager manager; Containers::Pointer importer; @@ -463,9 +450,6 @@ GlfwApplicationTest::GlfwApplicationTest(const Arguments& arguments): Platform:: importer->openData(rs.getRaw("icon-32.tga")) && (image32 = importer->image2D(0)) && importer->openData(rs.getRaw("icon-64.tga")) && (image64 = importer->image2D(0))) setWindowIcon({*image16, *image32, *image64}); else Warning{} << "Can't load the plugin / images, not setting window icon"; - #else - Debug{} << "GLFW too old, can't set window icon"; - #endif } }}}}