Browse Source

Merge 17c74b23d7 into 4c65e22acc

pull/168/merge
Vladimír Vondruš 2 years ago committed by GitHub
parent
commit
7a266cd422
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 31
      doc/changelog-old.dox
  2. 57
      doc/changelog.dox
  3. 6
      doc/platform.dox
  4. 4
      src/Magnum/Platform/AndroidApplication.h
  5. 18
      src/Magnum/Platform/Screen.h
  6. 917
      src/Magnum/Platform/Sdl2Application.cpp
  7. 2071
      src/Magnum/Platform/Sdl2Application.h
  8. 112
      src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp
  9. 2
      src/Magnum/SceneGraph/Camera.h

31
doc/changelog-old.dox

@ -108,7 +108,7 @@ Released 2018-05-01, tagged as
- Ability to create @ref Platform::Sdl2Application and - Ability to create @ref Platform::Sdl2Application and
@ref Platform::GlfwApplication classes without implicitly created OpenGL @ref Platform::GlfwApplication classes without implicitly created OpenGL
context by passing @ref Platform::Sdl2Application::Configuration::WindowFlag::Contextless "Configuration::WindowFlag::Contextless" context by passing @cpp Configuration::WindowFlag::Contextless @ce
to them. These two can be now also built completely without the GL library. to them. These two can be now also built completely without the GL library.
- Added @ref Platform::AndroidApplication::windowSize() - Added @ref Platform::AndroidApplication::windowSize()
- Added @ref Platform::AndroidApplication::nativeActivity() to access - Added @ref Platform::AndroidApplication::nativeActivity() to access
@ -157,10 +157,9 @@ Released 2018-05-01, tagged as
@subsubsection changelog-2018-04-changes-platform Platform libraries @subsubsection changelog-2018-04-changes-platform Platform libraries
- Separated @ref Platform::Sdl2Application::Configuration "Platform::*Application::Configuration" - Separated @cpp Platform::*Application::Configuration @ce
into @ref Platform::Sdl2Application::Configuration "Configuration" and into @cpp Configuration @ce and @cpp GLConfiguration @ce to allow creation
@ref Platform::Sdl2Application::GLConfiguration "GLConfiguration" to allow of non-GL application instances in the future
creation of non-GL application instances in the future
@subsubsection changelog-2018-04-changes-plugins Plugins @subsubsection changelog-2018-04-changes-plugins Plugins
@ -753,10 +752,10 @@ a high-level overview.
possible possible
- Ported @ref magnum-gl-info "magnum-info" to Emscripten - Ported @ref magnum-gl-info "magnum-info" to Emscripten
- First-class support for scroll events in - First-class support for scroll events in
@ref Platform::Sdl2Application::MouseScrollEvent (see @cpp Platform::Sdl2Application::MouseScrollEvent @ce
[mosra/magnum#157](https://github.com/mosra/magnum/pull/157)) (see [mosra/magnum#157](https://github.com/mosra/magnum/pull/157))
- Added @ref Platform::Sdl2Application::MouseEvent::clickCount() - Added @cpp Platform::Sdl2Application::MouseEvent::clickCount() @ce
- Added @ref Platform::Sdl2Application::multiGestureEvent() - Added @cpp Platform::Sdl2Application::multiGestureEvent() @ce
- Exposing key repeat in - Exposing key repeat in
@ref Platform::Sdl2Application::KeyEvent::isRepeated() "Platform::*Application::KeyEvent::isRepeated()" @ref Platform::Sdl2Application::KeyEvent::isRepeated() "Platform::*Application::KeyEvent::isRepeated()"
(see [mosra/magnum#161](https://github.com/mosra/magnum/issues/161), (see [mosra/magnum#161](https://github.com/mosra/magnum/issues/161),
@ -773,8 +772,8 @@ a high-level overview.
version is not what the application wants (as opposed to just aborting the version is not what the application wants (as opposed to just aborting the
application) (see [mosra/magnum#105](https://github.com/mosra/magnum/issues/105)) application) (see [mosra/magnum#105](https://github.com/mosra/magnum/issues/105))
- Added @cpp Platform::Sdl2Application::Configuration::setSRGBCapable() @ce - Added @cpp Platform::Sdl2Application::Configuration::setSRGBCapable() @ce
- Added @ref Platform::Sdl2Application::Configuration::WindowFlag::Borderless - Added @cpp Platform::Sdl2Application::Configuration::WindowFlag::Borderless @ce
and `Platform::Sdl2Application::Configuration::WindowFlag::AllowHighDpi` and @cpp Platform::Sdl2Application::Configuration::WindowFlag::AllowHighDpi @ce
for iOS and macOS for iOS and macOS
- Added @ref Platform::WindowlessGlxApplication::Configuration::setFlags() "Platform::Windowless*Application::Configuration::setFlags()" with - Added @ref Platform::WindowlessGlxApplication::Configuration::setFlags() "Platform::Windowless*Application::Configuration::setFlags()" with
@ref Platform::WindowlessGlxApplication::Configuration::Flag::Debug "Flag::Debug" @ref Platform::WindowlessGlxApplication::Configuration::Flag::Debug "Flag::Debug"
@ -786,7 +785,7 @@ a high-level overview.
with @ref Platform::GlfwApplication with @ref Platform::GlfwApplication
- Added modifier keys to - Added modifier keys to
@ref Platform::Sdl2Application::KeyEvent::Key "Platform::*Application::KeyEvent::Key" @ref Platform::Sdl2Application::KeyEvent::Key "Platform::*Application::KeyEvent::Key"
- Added @ref Platform::Sdl2Application::InputEvent::Modifier::Super to be - Added @cpp Platform::Sdl2Application::InputEvent::Modifier::Super @ce to be
consistent with @ref Platform::GlfwApplication (see consistent with @ref Platform::GlfwApplication (see
[mosra/magnum#159](https://github.com/mosra/magnum/pull/159)) [mosra/magnum#159](https://github.com/mosra/magnum/pull/159))
- Added @ref Platform::Sdl2Application::KeyEvent::keyName() "Platform::*Application::KeyEvent::keyName()" - Added @ref Platform::Sdl2Application::KeyEvent::keyName() "Platform::*Application::KeyEvent::keyName()"
@ -1102,10 +1101,10 @@ a high-level overview.
`Platform::GlfwApplication::MouseEvent::Button::WheelDown` mouse events are `Platform::GlfwApplication::MouseEvent::Button::WheelDown` mouse events are
deprecated, use @ref Platform::Sdl2Application::mouseScrollEvent() / deprecated, use @ref Platform::Sdl2Application::mouseScrollEvent() /
@ref Platform::GlfwApplication::mouseScrollEvent() and @ref Platform::GlfwApplication::mouseScrollEvent() and
@ref Platform::Sdl2Application::MouseScrollEvent / @cpp Platform::Sdl2Application::MouseScrollEvent @ce /
@ref Platform::GlfwApplication::MouseScrollEvent instead @ref Platform::GlfwApplication::MouseScrollEvent instead
- @ref Platform::Sdl2Application::Sdl2Application() "Platform::*Application::*Application()" - @cpp Platform::*Application::*Application() @ce and
and @ref Platform::WindowlessGlxApplication::WindowlessGlxApplication() "Platform::Windowless*Application::Windowless*Application()" @ref Platform::WindowlessGlxApplication::WindowlessGlxApplication() "Platform::Windowless*Application::Windowless*Application()"
constructors taking @cpp nullptr @ce are deprecated, use constructors constructors taking @cpp nullptr @ce are deprecated, use constructors
taking @ref NoCreateT instead to create an application without creating taking @ref NoCreateT instead to create an application without creating
OpenGL context OpenGL context
@ -1844,7 +1843,7 @@ for a high-level overview.
purely integral coordinates, useful e.g. for UI or 2D platformers. purely integral coordinates, useful e.g. for UI or 2D platformers.
- Detailed collision queries and new `InvertedSphere` shape in Shapes library - Detailed collision queries and new `InvertedSphere` shape in Shapes library
- Texture support in @cpp Shaders::Flat @ce - Texture support in @cpp Shaders::Flat @ce
- Mouse button queries in @ref Platform::Sdl2Application::MouseMoveEvent "Platform::*Application::MouseMoveEvent" - Mouse button queries in @cpp Platform::*Application::MouseMoveEvent @ce
@subsection changelog-2013-10-changes Changes @subsection changelog-2013-10-changes Changes

57
doc/changelog.dox

@ -762,13 +762,13 @@ See also:
- Added @ref Platform::EmscriptenApplication::Configuration::addWindowFlags() - Added @ref Platform::EmscriptenApplication::Configuration::addWindowFlags()
and @ref Platform::EmscriptenApplication::Configuration::clearWindowFlags() and @ref Platform::EmscriptenApplication::Configuration::clearWindowFlags()
for consistency with other application implementations for consistency with other application implementations
- Added @ref Platform::Sdl2Application::KeyEvent::Key::CapsLock, - Added @ref Platform::Sdl2ApplicationWindow::KeyEvent::Key::CapsLock,
@relativeref{Platform::Sdl2Application::KeyEvent::Key,ScrollLock}, @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,ScrollLock},
@relativeref{Platform::Sdl2Application::KeyEvent::Key,NumLock}, @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,NumLock},
@relativeref{Platform::Sdl2Application::KeyEvent::Key,PrintScreen}, @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,PrintScreen},
@relativeref{Platform::Sdl2Application::KeyEvent::Key,Pause} and @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,Pause} and
@relativeref{Platform::Sdl2Application::KeyEvent::Key,Menu} for consistency @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,Menu} for
with @ref Platform::EmscriptenApplication and consistency with @ref Platform::EmscriptenApplication and
@ref Platform::GlfwApplication (see [mosra/magnum#547](https://github.com/mosra/magnum/pull/547)) @ref Platform::GlfwApplication (see [mosra/magnum#547](https://github.com/mosra/magnum/pull/547))
- @ref Platform::Sdl2Application now overrides SDL's default behavior that - @ref Platform::Sdl2Application now overrides SDL's default behavior that
prevents computer from entering a power-saving mode while the application prevents computer from entering a power-saving mode while the application
@ -1160,9 +1160,9 @@ See also:
destroyed could fail with an error saying "cannot make the previous context destroyed could fail with an error saying "cannot make the previous context
current" on certain system. This was due to EGL not destroying the context current" on certain system. This was due to EGL not destroying the context
if it's still made current. if it's still made current.
- Fixed handling of @ref Platform::Sdl2Application::InputEvent::Modifier::Super, - Fixed handling of @ref Platform::Sdl2ApplicationWindow::InputEvent::Modifier::Super,
which was misreported as @relativeref{Platform::Sdl2Application::InputEvent::Modifier,Alt} (see which was misreported as @relativeref{Platform::Sdl2ApplicationWindow::InputEvent::Modifier,Alt}
[mosra/magnum#547](https://github.com/mosra/magnum/pull/547)) (see [mosra/magnum#547](https://github.com/mosra/magnum/pull/547))
- For meshes with multiple sets of vertex attributes (such as texture - For meshes with multiple sets of vertex attributes (such as texture
coordinates), @ref MeshTools::compile() should be using only the first set coordinates), @ref MeshTools::compile() should be using only the first set
but it wasn't. but it wasn't.
@ -1345,6 +1345,10 @@ See also:
performance and a default, use @relativeref{Platform::EmscriptenApplication::GLConfiguration,Flag::PowerPreferenceLowPower} performance and a default, use @relativeref{Platform::EmscriptenApplication::GLConfiguration,Flag::PowerPreferenceLowPower}
or @relativeref{Platform::EmscriptenApplication::GLConfiguration,Flag::PowerPreferenceHighPerformance} or @relativeref{Platform::EmscriptenApplication::GLConfiguration,Flag::PowerPreferenceHighPerformance}
instead instead
- GPU-context-related flags were moved from
@ref Platform::Sdl2Application::Configuration::WindowFlag to a new
@ref Platform::Sdl2Application::Configuration::Flag enum, as they're set
globally for all application windows and can't differ per-window
- @cpp Shaders::DistanceFieldVector @ce, @cpp Shaders::Flat @ce, - @cpp Shaders::DistanceFieldVector @ce, @cpp Shaders::Flat @ce,
@cpp Shaders::Generic @ce, @cpp Shaders::MeshVisualizer2D @ce, @cpp Shaders::Generic @ce, @cpp Shaders::MeshVisualizer2D @ce,
@cpp Shaders::MeshVisualizer3D @ce, @cpp Shaders::Phong @ce, @cpp Shaders::MeshVisualizer3D @ce, @cpp Shaders::Phong @ce,
@ -2048,12 +2052,12 @@ Released 2020-06-27, tagged as
@ref Platform::AbstractXApplication::mainLoopIteration() for consistency @ref Platform::AbstractXApplication::mainLoopIteration() for consistency
with @ref Platform::Sdl2Application (see with @ref Platform::Sdl2Application (see
[mosra/magnum#387](https://github.com/mosra/magnum/pull/387)) [mosra/magnum#387](https://github.com/mosra/magnum/pull/387))
- Added @ref Platform::Sdl2Application::KeyEvent::Key::Quote "Key::Quote", - Added @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::Quote},
@ref Platform::Sdl2Application::KeyEvent::Key::LeftBracket "Key::LeftBracket", @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::LeftBracket},
@ref Platform::Sdl2Application::KeyEvent::Key::RightBracket "Key::RightBracket", @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::RightBracket},
@ref Platform::Sdl2Application::KeyEvent::Key::Backslash "Key::Backslash" and @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::Backslash} and
@ref Platform::Sdl2Application::KeyEvent::Key::Backquote "Key::Backquote" @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::Backquote}
keys to @ref Platform::Sdl2Application::KeyEvent and keys to @cpp Platform::Sdl2Application::KeyEvent @ce and
@ref Platform::GlfwApplication::KeyEvent @ref Platform::GlfwApplication::KeyEvent
- Added @ref Platform::GlfwApplication::KeyEvent::Key::World1 and - Added @ref Platform::GlfwApplication::KeyEvent::Key::World1 and
@ref Platform::GlfwApplication::KeyEvent::Key::World2 @ref Platform::GlfwApplication::KeyEvent::Key::World2
@ -2071,12 +2075,9 @@ Released 2020-06-27, tagged as
- CUDA device selection in @ref Platform::WindowlessEglApplication (see - CUDA device selection in @ref Platform::WindowlessEglApplication (see
[mosra/magnum#449](https://github.com/mosra/magnum/pull/449)) [mosra/magnum#449](https://github.com/mosra/magnum/pull/449))
- Added @ref Platform::GlfwApplication::Configuration::WindowFlag::Borderless - Added @ref Platform::GlfwApplication::Configuration::WindowFlag::Borderless
- Added @ref Platform::Sdl2Application::Configuration::WindowFlag::FullscreenDesktop, - Added @cpp Platform::Sdl2Application::Configuration::WindowFlag::FullscreenDesktop @ce,
@ref Platform::Sdl2Application::Configuration::WindowFlag::AlwaysOnTop "AlwaysOnTop", @cpp AlwaysOnTop @ce, @cpp SkipTaskbar @ce, @cpp Utility @ce,
@ref Platform::Sdl2Application::Configuration::WindowFlag::SkipTaskbar "SkipTaskbar", @cpp Tooltip @ce and @cpp PopupMenu @ce
@ref Platform::Sdl2Application::Configuration::WindowFlag::Utility "Utility",
@ref Platform::Sdl2Application::Configuration::WindowFlag::Tooltip "Tooltip"
and @ref Platform::Sdl2Application::Configuration::WindowFlag::PopupMenu "PopupMenu"
- Added @ref Platform::Sdl2Application::Configuration::addWindowFlags() and - Added @ref Platform::Sdl2Application::Configuration::addWindowFlags() and
@ref Platform::Sdl2Application::Configuration::clearWindowFlags() "clearWindowFlags()" @ref Platform::Sdl2Application::Configuration::clearWindowFlags() "clearWindowFlags()"
for consistency with similar functions in for consistency with similar functions in
@ -2378,7 +2379,7 @@ Released 2020-06-27, tagged as
- The @ref Primitives::cylinderSolid() and @ref Primitives::coneSolid() - The @ref Primitives::cylinderSolid() and @ref Primitives::coneSolid()
primitives were missing a face when both caps and texture coordinates were primitives were missing a face when both caps and texture coordinates were
enabled (see [mosra/magnum#386](https://github.com/mosra/magnum/issues/386)) enabled (see [mosra/magnum#386](https://github.com/mosra/magnum/issues/386))
- @ref Platform::Sdl2Application::Configuration::WindowFlag::Vulkan was - @cpp Platform::Sdl2Application::Configuration::WindowFlag::Vulkan @ce was
enabled conditionally only for SDL >= 2.0.6, but the version defines were enabled conditionally only for SDL >= 2.0.6, but the version defines were
never included so it was always disabled never included so it was always disabled
- Fixed missing handling of - Fixed missing handling of
@ -2409,7 +2410,7 @@ Released 2020-06-27, tagged as
caused @ref Platform::Sdl2Application::setMinimalLoopPeriod() "setMinimalLoopPeriod()" caused @ref Platform::Sdl2Application::setMinimalLoopPeriod() "setMinimalLoopPeriod()"
to be ignored even though Vsync was in fact not enabled. to be ignored even though Vsync was in fact not enabled.
- It was not possible to override DPI scaling using - It was not possible to override DPI scaling using
@ref Platform::Sdl2Application::Configuration as command-line arguments @cpp Platform::Sdl2Application::Configuration @ce as command-line arguments
always got a priority (see [mosra/magnum#416](https://github.com/mosra/magnum/issues/416)) always got a priority (see [mosra/magnum#416](https://github.com/mosra/magnum/issues/416))
- Fixed an otherwise harmless OOB access in @ref MeshTools::tipsifyInPlace() - Fixed an otherwise harmless OOB access in @ref MeshTools::tipsifyInPlace()
that could trigger ASan or debug iterator errors that could trigger ASan or debug iterator errors
@ -2911,10 +2912,10 @@ Released 2019-10-24, tagged as
in @ref Platform::GlfwApplication and @ref Platform::EmscriptenApplication) in @ref Platform::GlfwApplication and @ref Platform::EmscriptenApplication)
for changing window title at runtime as opposed to setting them on for changing window title at runtime as opposed to setting them on
application startup application startup
- Added @ref Platform::Sdl2Application::Configuration::WindowFlag::OpenGL and - Added @cpp Platform::Sdl2Application::Configuration::WindowFlag::OpenGL @ce
@ref Platform::Sdl2Application::Configuration::WindowFlag::Vulkan "WindowFlag::Vulkan", and @cpp WindowFlag::Vulkan @ce, meant to be used together with
meant to be used together with @ref Platform::Sdl2Application::Configuration::WindowFlag::Contextless for @cpp Platform::Sdl2Application::Configuration::WindowFlag::Contextless @ce
manual creation of OpenGL contexts and Vulkan instances for manual creation of OpenGL contexts and Vulkan instances
- @ref Platform::WindowlessEglApplication now uses the - @ref Platform::WindowlessEglApplication now uses the
@m_class{m-doc-external} [EGL_EXT_device_enumeration](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_device_enumeration.txt), @m_class{m-doc-external} [EGL_EXT_device_enumeration](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_device_enumeration.txt),
@m_class{m-doc-external} [EGL_EXT_platform_base](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_base.txt) and @m_class{m-doc-external} [EGL_EXT_platform_base](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_base.txt) and

6
doc/platform.dox

@ -136,8 +136,8 @@ target_link_libraries(myapplication
@section platform-configuration Specifying configuration @section platform-configuration Specifying configuration
By default the application is created with some reasonable defaults (e.g. By default the application is created with some reasonable defaults (e.g.
window size 800x600 pixels). If you want something else, you can pass window size 800x600 pixels). If you want something else, you can pass a
@ref Platform::Sdl2Application::Configuration "Configuration" instance to @relativeref{Platform::Sdl2ApplicationWindow,Configuration} instance to the
application constructor. Using method chaining it can be done conveniently like application constructor. Using method chaining it can be done conveniently like
this: this:
@ -148,7 +148,7 @@ this:
Sometimes you may want to set up the application based on a configuration file Sometimes you may want to set up the application based on a configuration file
or system introspection, which can't really be done inside the base class or system introspection, which can't really be done inside the base class
initializer. You can specify @ref NoCreate in the constructor instead and pass initializer. You can specify @ref NoCreate in the constructor instead and pass
the @relativeref{Platform::Sdl2Application,Configuration} later to a the @relativeref{Platform::Sdl2ApplicationWindow,Configuration} later to a
@relativeref{Platform::Sdl2Application,create()} function: @relativeref{Platform::Sdl2Application,create()} function:
@snippet Platform.cpp createcontext @snippet Platform.cpp createcontext

4
src/Magnum/Platform/AndroidApplication.h

@ -149,8 +149,8 @@ to simplify porting.
@section Platform-AndroidApplication-resizing Responding to viewport events @section Platform-AndroidApplication-resizing Responding to viewport events
Unlike in desktop application implementations, where this is controlled via Unlike in desktop application implementations, where this is controlled via
@ref Sdl2Application::Configuration::WindowFlag::Resizable, for example, on @ref Sdl2ApplicationWindow::Configuration::WindowFlag::Resizable, for example,
Android you have to describe this in the `AndroidManifest.xml` file, as by on Android you have to describe this in the `AndroidManifest.xml` file, as by
default the application gets killed and relaunched on screen orientation default the application gets killed and relaunched on screen orientation
change. See the @ref platforms-android-apps-manifest-screen-resize "manifest file docs" change. See the @ref platforms-android-apps-manifest-screen-resize "manifest file docs"
for more information. for more information.

18
src/Magnum/Platform/Screen.h

@ -175,7 +175,7 @@ template<class Application> class BasicScreen:
* @brief Key event * @brief Key event
* *
* Defined only if the application has a * Defined only if the application has a
* @ref Sdl2Application::KeyEvent "KeyEvent". * @relativeref{Sdl2ApplicationWindow,KeyEvent}.
*/ */
typedef typename BasicScreenedApplication<Application>::KeyEvent KeyEvent; typedef typename BasicScreenedApplication<Application>::KeyEvent KeyEvent;
#endif #endif
@ -192,7 +192,7 @@ template<class Application> class BasicScreen:
* @m_since{2019,10} * @m_since{2019,10}
* *
* Defined only if the application has a * Defined only if the application has a
* @ref Sdl2Application::MouseScrollEvent "MouseScrollEvent". * @relativeref{Sdl2ApplicationWindow,MouseScrollEvent}.
*/ */
typedef typename BasicScreenedApplication<Application>::MouseScrollEvent MouseScrollEvent; typedef typename BasicScreenedApplication<Application>::MouseScrollEvent MouseScrollEvent;
@ -201,7 +201,7 @@ template<class Application> class BasicScreen:
* @m_since{2019,10} * @m_since{2019,10}
* *
* Defined only if the application has a * Defined only if the application has a
* @ref Sdl2Application::TextInputEvent "TextInputEvent". * @relativeref{Sdl2ApplicationWindow,TextInputEvent}.
*/ */
typedef typename BasicScreenedApplication<Application>::TextInputEvent TextInputEvent; typedef typename BasicScreenedApplication<Application>::TextInputEvent TextInputEvent;
@ -210,7 +210,7 @@ template<class Application> class BasicScreen:
* @m_since{2019,10} * @m_since{2019,10}
* *
* Defined only if the application has a * Defined only if the application has a
* @ref Sdl2Application::TextEditingEvent "TextEditingEvent". * @relativeref{Sdl2ApplicationWindow,TextEditingEvent}.
*/ */
typedef typename BasicScreenedApplication<Application>::TextEditingEvent TextEditingEvent; typedef typename BasicScreenedApplication<Application>::TextEditingEvent TextEditingEvent;
#endif #endif
@ -379,7 +379,7 @@ template<class Application> class BasicScreen:
* Called when @ref PropagatedEvent::Input is enabled and an key is * Called when @ref PropagatedEvent::Input is enabled and an key is
* pressed. See @ref Sdl2Application::keyPressEvent() "*Application::keyPressEvent()" * pressed. See @ref Sdl2Application::keyPressEvent() "*Application::keyPressEvent()"
* for more information. Defined only if the application has a * for more information. Defined only if the application has a
* @ref Sdl2Application::KeyEvent "KeyEvent". * @relativeref{Sdl2ApplicationWindow,KeyEvent}.
*/ */
virtual void keyPressEvent(KeyEvent& event); virtual void keyPressEvent(KeyEvent& event);
@ -389,7 +389,7 @@ template<class Application> class BasicScreen:
* Called when @ref PropagatedEvent::Input is enabled and an key is * Called when @ref PropagatedEvent::Input is enabled and an key is
* released. See @ref Sdl2Application::keyReleaseEvent() "*Application::keyReleaseEvent()" * released. See @ref Sdl2Application::keyReleaseEvent() "*Application::keyReleaseEvent()"
* for more information. Defined only if the application has a * for more information. Defined only if the application has a
* @ref Sdl2Application::KeyEvent "KeyEvent". * @relativeref{Sdl2ApplicationWindow,KeyEvent}.
*/ */
virtual void keyReleaseEvent(KeyEvent& event); virtual void keyReleaseEvent(KeyEvent& event);
#endif #endif
@ -437,7 +437,7 @@ template<class Application> class BasicScreen:
* Called when @ref PropagatedEvent::Input is enabled and mouse wheel * Called when @ref PropagatedEvent::Input is enabled and mouse wheel
* is rotated. See @ref Sdl2Application::mouseScrollEvent() "*Application::mouseScrollEvent()" * is rotated. See @ref Sdl2Application::mouseScrollEvent() "*Application::mouseScrollEvent()"
* for more information. Defined only if the application has a * for more information. Defined only if the application has a
* @ref Sdl2Application::MouseScrollEvent "MouseScrollEvent". * @relativeref{Sdl2ApplicationWindow,MouseScrollEvent}.
*/ */
virtual void mouseScrollEvent(MouseScrollEvent& event); virtual void mouseScrollEvent(MouseScrollEvent& event);
#endif #endif
@ -457,7 +457,7 @@ template<class Application> class BasicScreen:
* *
* Called when @ref PropagatedEvent::Input is enabled and text is being * Called when @ref PropagatedEvent::Input is enabled and text is being
* input. Defined only if the application has a * input. Defined only if the application has a
* @ref Sdl2Application::TextInputEvent "TextInputEvent". * @relativeref{Sdl2ApplicationWindow,TextInputEvent}.
*/ */
virtual void textInputEvent(TextInputEvent& event); virtual void textInputEvent(TextInputEvent& event);
@ -467,7 +467,7 @@ template<class Application> class BasicScreen:
* *
* Called when @ref PropagatedEvent::Input and the text is being * Called when @ref PropagatedEvent::Input and the text is being
* edited. Defined only if the application has a * edited. Defined only if the application has a
* @ref Sdl2Application::TextEditingEvent "TextEditingEvent". * @relativeref{Sdl2ApplicationWindow,TextEditingEvent}.
*/ */
virtual void textEditingEvent(TextEditingEvent& event); virtual void textEditingEvent(TextEditingEvent& event);
#endif #endif

917
src/Magnum/Platform/Sdl2Application.cpp

File diff suppressed because it is too large Load Diff

2071
src/Magnum/Platform/Sdl2Application.h

File diff suppressed because it is too large Load Diff

112
src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp

@ -23,9 +23,11 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Arguments.h> #include <Corrade/Utility/Arguments.h>
#include <Corrade/Utility/Format.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -174,6 +176,106 @@ Debug& operator<<(Debug& debug, const Application::KeyEvent::Key value) {
using namespace Containers::Literals; using namespace Containers::Literals;
#ifndef CORRADE_TARGET_EMSCRIPTEN
struct Sdl2ApplicationTestWindow: Platform::ApplicationWindow {
explicit Sdl2ApplicationTestWindow(Platform::Application& application, std::size_t id): Platform::ApplicationWindow{application, Configuration{}
.setTitle(Utility::format("Window {}", id))
.setSize({400, 300})
.addWindowFlags(Configuration::WindowFlag::Resizable)
}, _id{id} {}
void viewportEvent(ViewportEvent& event) override {
Debug{} << "window" << _id << "viewport event" << event.windowSize()
#ifdef MAGNUM_TARGET_GL
<< event.framebufferSize()
#endif
<< event.dpiScaling();
#warning query the GL fb size here and compare
// GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()});
}
void drawEvent() override {
Debug{} << "window" << _id << "draw event";
#ifdef MAGNUM_TARGET_GL
GL::defaultFramebuffer.clear(GL::FramebufferClear::Color);
#endif
swapBuffers();
}
/* For testing event coordinates */
void mousePressEvent(MouseEvent& event) override {
Debug{} << "window" << _id << "mouse press event:" << event.position() << Int(event.button());
}
void mouseReleaseEvent(MouseEvent& event) override {
Debug{} << "window" << _id << "mouse release event:" << event.position() << Int(event.button());
}
void mouseMoveEvent(MouseMoveEvent& event) override {
Debug{} << "window" << _id << "mouse move event:" << event.position() << event.relativePosition() << Uint32(event.buttons());
}
void mouseScrollEvent(MouseScrollEvent& event) override {
Debug{} << "window" << _id << "mouse scroll event:" << event.offset() << event.position();
}
void keyPressEvent(KeyEvent& event) override {
Debug{} << "window" << _id << "key press event:" << SDL_Keycode(event.key()) << event.keyName();
if(event.key() == KeyEvent::Key::F1) {
Debug{} << "starting text input";
application().startTextInput();
} else if(event.key() == KeyEvent::Key::Esc) {
Debug{} << "stopping text input";
application().stopTextInput();
} else if(event.key() == KeyEvent::Key::T) {
Debug{} << "setting window title";
setWindowTitle("This is a UTF-8 Window Title™ and it should have no exclamation mark!!"_s.exceptSuffix(2));
}
#ifndef CORRADE_TARGET_EMSCRIPTEN
else if(event.key() == KeyEvent::Key::S) {
Debug{} << "setting window size, which should trigger a viewport event";
setWindowSize(Vector2i{300, 200});
} else if(event.key() == KeyEvent::Key::W) {
Debug{} << "setting max window size, which should trigger a viewport event";
setMaxWindowSize(Vector2i{700, 500});
}
#endif
else if(event.key() == KeyEvent::Key::H) {
Debug{} << "toggling hand cursor";
setCursor(cursor() == Cursor::Arrow ? Cursor::Hand : Cursor::Arrow);
}
#ifndef CORRADE_TARGET_EMSCRIPTEN
else if(event.key() == KeyEvent::Key::L) {
Debug{} << "toggling locked mouse";
setCursor(cursor() == Cursor::Arrow ? Cursor::HiddenLocked : Cursor::Arrow);
}
#else
else if(event.key() == KeyEvent::Key::F) {
Debug{} << "toggling fullscreen";
setContainerCssClass((_fullscreen ^= true) ? "mn-fullsize" : "");
}
#endif
else if(event.key() == KeyEvent::Key::X) {
Debug{} << "requesting an exit with code 5";
exit(5);
}
}
void keyReleaseEvent(KeyEvent& event) override {
Debug{} << "window" << _id << "key release event:" << SDL_Keycode(event.key()) << event.keyName();
}
void textInputEvent(TextInputEvent& event) override {
Debug{} << "window" << _id << "text input event:" << event.text();
}
private:
std::size_t _id;
};
#endif
struct Sdl2ApplicationTest: Platform::Application { struct Sdl2ApplicationTest: Platform::Application {
explicit Sdl2ApplicationTest(const Arguments& arguments); explicit Sdl2ApplicationTest(const Arguments& arguments);
@ -242,6 +344,10 @@ struct Sdl2ApplicationTest: Platform::Application {
Debug{} << "setting max window size, which should trigger a viewport event"; Debug{} << "setting max window size, which should trigger a viewport event";
setMaxWindowSize(Vector2i{700, 500}); setMaxWindowSize(Vector2i{700, 500});
} }
else if(event.key() == KeyEvent::Key::O) {
Debug{} << "opening window" << _windows.size();
arrayAppend(_windows, Containers::pointer<Sdl2ApplicationTestWindow>(*this, _windows.size()));
}
#endif #endif
else if(event.key() == KeyEvent::Key::H) { else if(event.key() == KeyEvent::Key::H) {
Debug{} << "toggling hand cursor"; Debug{} << "toggling hand cursor";
@ -303,10 +409,12 @@ struct Sdl2ApplicationTest: Platform::Application {
if(event.type == SDL_WINDOWEVENT) d << event.window.event; if(event.type == SDL_WINDOWEVENT) d << event.window.event;
} }
#ifdef CORRADE_TARGET_EMSCRIPTEN
private: private:
#ifndef CORRADE_TARGET_EMSCRIPTEN
Containers::Array<Containers::Pointer<Sdl2ApplicationTestWindow>> _windows;
#else
bool _fullscreen = false; bool _fullscreen = false;
#endif #endif
}; };
Sdl2ApplicationTest::Sdl2ApplicationTest(const Arguments& arguments): Platform::Application{arguments, NoCreate} { Sdl2ApplicationTest::Sdl2ApplicationTest(const Arguments& arguments): Platform::Application{arguments, NoCreate} {

2
src/Magnum/SceneGraph/Camera.h

@ -156,7 +156,7 @@ template<UnsignedInt dimensions, class T> class Camera: public AbstractFeature<d
* *
* Conversion from integer window-space coordinates with origin in top * Conversion from integer window-space coordinates with origin in top
* left corner and Y down (e.g. from * left corner and Y down (e.g. from
* @ref Platform::Sdl2Application::MouseEvent "Platform::*Application::MouseEvent") * @ref Platform::Sdl2ApplicationWindow::MouseEvent "Platform::*Application::MouseEvent")
* to floating-point coordinates on near XY plane with origin at camera * to floating-point coordinates on near XY plane with origin at camera
* position and Y up can be done using the following snippet: * position and Y up can be done using the following snippet:
* *

Loading…
Cancel
Save