Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-window support in Sdl2Application and GlfwApplication #168

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
31 changes: 15 additions & 16 deletions doc/changelog-old.dox
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Released 2018-05-01, tagged as

- Ability to create @ref Platform::Sdl2Application and
@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.
- Added @ref Platform::AndroidApplication::windowSize()
- Added @ref Platform::AndroidApplication::nativeActivity() to access
Expand Down Expand Up @@ -157,10 +157,9 @@ Released 2018-05-01, tagged as

@subsubsection changelog-2018-04-changes-platform Platform libraries

- Separated @ref Platform::Sdl2Application::Configuration "Platform::*Application::Configuration"
into @ref Platform::Sdl2Application::Configuration "Configuration" and
@ref Platform::Sdl2Application::GLConfiguration "GLConfiguration" to allow
creation of non-GL application instances in the future
- Separated @cpp Platform::*Application::Configuration @ce
into @cpp Configuration @ce and @cpp GLConfiguration @ce to allow creation
of non-GL application instances in the future

@subsubsection changelog-2018-04-changes-plugins Plugins

Expand Down Expand Up @@ -753,10 +752,10 @@ a high-level overview.
possible
- Ported @ref magnum-gl-info "magnum-info" to Emscripten
- First-class support for scroll events in
@ref Platform::Sdl2Application::MouseScrollEvent (see
[mosra/magnum#157](https://github.com/mosra/magnum/pull/157))
- Added @ref Platform::Sdl2Application::MouseEvent::clickCount()
- Added @ref Platform::Sdl2Application::multiGestureEvent()
@cpp Platform::Sdl2Application::MouseScrollEvent @ce
(see [mosra/magnum#157](https://github.com/mosra/magnum/pull/157))
- Added @cpp Platform::Sdl2Application::MouseEvent::clickCount() @ce
- Added @cpp Platform::Sdl2Application::multiGestureEvent() @ce
- Exposing key repeat in
@ref Platform::Sdl2Application::KeyEvent::isRepeated() "Platform::*Application::KeyEvent::isRepeated()"
(see [mosra/magnum#161](https://github.com/mosra/magnum/issues/161),
Expand All @@ -773,8 +772,8 @@ a high-level overview.
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))
- Added @cpp Platform::Sdl2Application::Configuration::setSRGBCapable() @ce
- Added @ref Platform::Sdl2Application::Configuration::WindowFlag::Borderless
and `Platform::Sdl2Application::Configuration::WindowFlag::AllowHighDpi`
- Added @cpp Platform::Sdl2Application::Configuration::WindowFlag::Borderless @ce
and @cpp Platform::Sdl2Application::Configuration::WindowFlag::AllowHighDpi @ce
for iOS and macOS
- Added @ref Platform::WindowlessGlxApplication::Configuration::setFlags() "Platform::Windowless*Application::Configuration::setFlags()" with
@ref Platform::WindowlessGlxApplication::Configuration::Flag::Debug "Flag::Debug"
Expand All @@ -786,7 +785,7 @@ a high-level overview.
with @ref Platform::GlfwApplication
- Added modifier keys to
@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
[mosra/magnum#159](https://github.com/mosra/magnum/pull/159))
- Added @ref Platform::Sdl2Application::KeyEvent::keyName() "Platform::*Application::KeyEvent::keyName()"
Expand Down Expand Up @@ -1102,10 +1101,10 @@ a high-level overview.
`Platform::GlfwApplication::MouseEvent::Button::WheelDown` mouse events are
deprecated, use @ref Platform::Sdl2Application::mouseScrollEvent() /
@ref Platform::GlfwApplication::mouseScrollEvent() and
@ref Platform::Sdl2Application::MouseScrollEvent /
@cpp Platform::Sdl2Application::MouseScrollEvent @ce /
@ref Platform::GlfwApplication::MouseScrollEvent instead
- @ref Platform::Sdl2Application::Sdl2Application() "Platform::*Application::*Application()"
and @ref Platform::WindowlessGlxApplication::WindowlessGlxApplication() "Platform::Windowless*Application::Windowless*Application()"
- @cpp Platform::*Application::*Application() @ce and
@ref Platform::WindowlessGlxApplication::WindowlessGlxApplication() "Platform::Windowless*Application::Windowless*Application()"
constructors taking @cpp nullptr @ce are deprecated, use constructors
taking @ref NoCreateT instead to create an application without creating
OpenGL context
Expand Down Expand Up @@ -1844,7 +1843,7 @@ for a high-level overview.
purely integral coordinates, useful e.g. for UI or 2D platformers.
- Detailed collision queries and new `InvertedSphere` shape in Shapes library
- 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

Expand Down
57 changes: 29 additions & 28 deletions doc/changelog.dox
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,13 @@ See also:
- Added @ref Platform::EmscriptenApplication::Configuration::addWindowFlags()
and @ref Platform::EmscriptenApplication::Configuration::clearWindowFlags()
for consistency with other application implementations
- Added @ref Platform::Sdl2Application::KeyEvent::Key::CapsLock,
@relativeref{Platform::Sdl2Application::KeyEvent::Key,ScrollLock},
@relativeref{Platform::Sdl2Application::KeyEvent::Key,NumLock},
@relativeref{Platform::Sdl2Application::KeyEvent::Key,PrintScreen},
@relativeref{Platform::Sdl2Application::KeyEvent::Key,Pause} and
@relativeref{Platform::Sdl2Application::KeyEvent::Key,Menu} for consistency
with @ref Platform::EmscriptenApplication and
- Added @ref Platform::Sdl2ApplicationWindow::KeyEvent::Key::CapsLock,
@relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,ScrollLock},
@relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,NumLock},
@relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,PrintScreen},
@relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,Pause} and
@relativeref{Platform::Sdl2ApplicationWindow::KeyEvent::Key,Menu} for
consistency with @ref Platform::EmscriptenApplication and
@ref Platform::GlfwApplication (see [mosra/magnum#547](https://github.com/mosra/magnum/pull/547))
- @ref Platform::Sdl2Application now overrides SDL's default behavior that
prevents computer from entering a power-saving mode while the application
Expand Down Expand Up @@ -1103,9 +1103,9 @@ See also:
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
if it's still made current.
- Fixed handling of @ref Platform::Sdl2Application::InputEvent::Modifier::Super,
which was misreported as @relativeref{Platform::Sdl2Application::InputEvent::Modifier,Alt} (see
[mosra/magnum#547](https://github.com/mosra/magnum/pull/547))
- Fixed handling of @ref Platform::Sdl2ApplicationWindow::InputEvent::Modifier::Super,
which was misreported as @relativeref{Platform::Sdl2ApplicationWindow::InputEvent::Modifier,Alt}
(see [mosra/magnum#547](https://github.com/mosra/magnum/pull/547))
- For meshes with multiple sets of vertex attributes (such as texture
coordinates), @ref MeshTools::compile() should be using only the first set
but it wasn't.
Expand Down Expand Up @@ -1273,6 +1273,10 @@ See also:
performance and a default, use @relativeref{Platform::EmscriptenApplication::GLConfiguration,Flag::PowerPreferenceLowPower}
or @relativeref{Platform::EmscriptenApplication::GLConfiguration,Flag::PowerPreferenceHighPerformance}
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::Generic @ce, @cpp Shaders::MeshVisualizer2D @ce,
@cpp Shaders::MeshVisualizer3D @ce, @cpp Shaders::Phong @ce,
Expand Down Expand Up @@ -1969,12 +1973,12 @@ Released 2020-06-27, tagged as
@ref Platform::AbstractXApplication::mainLoopIteration() for consistency
with @ref Platform::Sdl2Application (see
[mosra/magnum#387](https://github.com/mosra/magnum/pull/387))
- Added @ref Platform::Sdl2Application::KeyEvent::Key::Quote "Key::Quote",
@ref Platform::Sdl2Application::KeyEvent::Key::LeftBracket "Key::LeftBracket",
@ref Platform::Sdl2Application::KeyEvent::Key::RightBracket "Key::RightBracket",
@ref Platform::Sdl2Application::KeyEvent::Key::Backslash "Key::Backslash" and
@ref Platform::Sdl2Application::KeyEvent::Key::Backquote "Key::Backquote"
keys to @ref Platform::Sdl2Application::KeyEvent and
- Added @relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::Quote},
@relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::LeftBracket},
@relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::RightBracket},
@relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::Backslash} and
@relativeref{Platform::Sdl2ApplicationWindow::KeyEvent,Key::Backquote}
keys to @cpp Platform::Sdl2Application::KeyEvent @ce and
@ref Platform::GlfwApplication::KeyEvent
- Added @ref Platform::GlfwApplication::KeyEvent::Key::World1 and
@ref Platform::GlfwApplication::KeyEvent::Key::World2
Expand All @@ -1992,12 +1996,9 @@ Released 2020-06-27, tagged as
- CUDA device selection in @ref Platform::WindowlessEglApplication (see
[mosra/magnum#449](https://github.com/mosra/magnum/pull/449))
- Added @ref Platform::GlfwApplication::Configuration::WindowFlag::Borderless
- Added @ref Platform::Sdl2Application::Configuration::WindowFlag::FullscreenDesktop,
@ref Platform::Sdl2Application::Configuration::WindowFlag::AlwaysOnTop "AlwaysOnTop",
@ref Platform::Sdl2Application::Configuration::WindowFlag::SkipTaskbar "SkipTaskbar",
@ref Platform::Sdl2Application::Configuration::WindowFlag::Utility "Utility",
@ref Platform::Sdl2Application::Configuration::WindowFlag::Tooltip "Tooltip"
and @ref Platform::Sdl2Application::Configuration::WindowFlag::PopupMenu "PopupMenu"
- Added @cpp Platform::Sdl2Application::Configuration::WindowFlag::FullscreenDesktop @ce,
@cpp AlwaysOnTop @ce, @cpp SkipTaskbar @ce, @cpp Utility @ce,
@cpp Tooltip @ce and @cpp PopupMenu @ce
- Added @ref Platform::Sdl2Application::Configuration::addWindowFlags() and
@ref Platform::Sdl2Application::Configuration::clearWindowFlags() "clearWindowFlags()"
for consistency with similar functions in
Expand Down Expand Up @@ -2299,7 +2300,7 @@ Released 2020-06-27, tagged as
- The @ref Primitives::cylinderSolid() and @ref Primitives::coneSolid()
primitives were missing a face when both caps and texture coordinates were
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
never included so it was always disabled
- Fixed missing handling of
Expand Down Expand Up @@ -2330,7 +2331,7 @@ Released 2020-06-27, tagged as
caused @ref Platform::Sdl2Application::setMinimalLoopPeriod() "setMinimalLoopPeriod()"
to be ignored even though Vsync was in fact not enabled.
- 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))
- Fixed an otherwise harmless OOB access in @ref MeshTools::tipsifyInPlace()
that could trigger ASan or debug iterator errors
Expand Down Expand Up @@ -2832,10 +2833,10 @@ Released 2019-10-24, tagged as
in @ref Platform::GlfwApplication and @ref Platform::EmscriptenApplication)
for changing window title at runtime as opposed to setting them on
application startup
- Added @ref Platform::Sdl2Application::Configuration::WindowFlag::OpenGL and
@ref Platform::Sdl2Application::Configuration::WindowFlag::Vulkan "WindowFlag::Vulkan",
meant to be used together with @ref Platform::Sdl2Application::Configuration::WindowFlag::Contextless for
manual creation of OpenGL contexts and Vulkan instances
- Added @cpp Platform::Sdl2Application::Configuration::WindowFlag::OpenGL @ce
and @cpp WindowFlag::Vulkan @ce, meant to be used together with
@cpp Platform::Sdl2Application::Configuration::WindowFlag::Contextless @ce
for manual creation of OpenGL contexts and Vulkan instances
- @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_platform_base](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_base.txt) and
Expand Down
6 changes: 3 additions & 3 deletions doc/platform.dox
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ target_link_libraries(myapplication
@section platform-configuration Specifying configuration

By default the application is created with some reasonable defaults (e.g.
window size 800x600 pixels). If you want something else, you can pass
@ref Platform::Sdl2Application::Configuration "Configuration" instance to
window size 800x600 pixels). If you want something else, you can pass a
@relativeref{Platform::Sdl2ApplicationWindow,Configuration} instance to the
application constructor. Using method chaining it can be done conveniently like
this:

Expand All @@ -148,7 +148,7 @@ this:
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
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:

@snippet MagnumPlatform.cpp createcontext
Expand Down
11 changes: 5 additions & 6 deletions doc/snippets/MagnumTextureTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ atlas.add(stridedArrayView(images).slice(&ImageView2D::size), offsets, rotations

/* Copy the image data to the atlas, assuming all are RGBA8Unorm as well */
Image2D output{PixelFormat::RGBA8Unorm, atlas.filledSize().xy(),
Containers::Array<char>{ValueInit, std::size_t(atlas.filledSize().product())}};
Containers::Array<char>{ValueInit, std::size_t(atlas.filledSize().product()*4)}};
Containers::StridedArrayView2D<Color4ub> dst = output.pixels<Color4ub>();
for(std::size_t i = 0; i != images.size(); ++i) {
/* Rotate 90° counterclockwise if the image is rotated in the atlas */
Expand All @@ -82,7 +82,7 @@ atlas.clearFlags(TextureTools::AtlasLandfillFlag::RotatePortrait|

/* Copy the image data to the atlas, assuming all are RGBA8Unorm as well */
Image2D output{PixelFormat::RGBA8Unorm, atlas.filledSize().xy(),
Containers::Array<char>{ValueInit, std::size_t(atlas.filledSize().product())}};
Containers::Array<char>{ValueInit, std::size_t(atlas.filledSize().product()*4)}};
Containers::StridedArrayView2D<Color4ub> dst = output.pixels<Color4ub>();
for(std::size_t i = 0; i != images.size(); ++i) {
Containers::StridedArrayView2D<const Color4ub> src = images[i].pixels<Color4ub>();
Expand All @@ -104,9 +104,8 @@ TextureTools::AtlasLandfill atlas{{1024, 1024, 0}};
atlas.add(stridedArrayView(images).slice(&ImageView2D::size), offsets, rotations);

/* Copy the image data to the atlas, assuming all are RGBA8Unorm as well */
Vector3i outputSize = atlas.filledSize();
Image3D output{PixelFormat::RGBA8Unorm, outputSize,
Containers::Array<char>{ValueInit, std::size_t(outputSize.product())}};
Image3D output{PixelFormat::RGBA8Unorm, atlas.filledSize(),
Containers::Array<char>{ValueInit, std::size_t(atlas.filledSize().product()*4)}};
Containers::StridedArrayView3D<Color4ub> dst = output.pixels<Color4ub>();
for(std::size_t i = 0; i != images.size(); ++i) {
/* Rotate 90° counterclockwise if the image is rotated in the atlas */
Expand Down Expand Up @@ -135,7 +134,7 @@ Int layerCount = TextureTools::atlasArrayPowerOfTwo(layerSize, sizes, offsets);
/* Copy the image data to the atlas, assuming all are RGBA8Unorm as well */
Vector3i outputSize{layerSize, layerCount};
Image3D output{PixelFormat::RGBA8Unorm, outputSize,
Containers::Array<char>{ValueInit, std::size_t(outputSize.product())}};
Containers::Array<char>{ValueInit, std::size_t(outputSize.product()*4)}};
Containers::StridedArrayView3D<Color4ub> dst = output.pixels<Color4ub>();
for(std::size_t i = 0; i != input.size(); ++i) {
Containers::StridedArrayView3D<const Color4ub> src = input[i].pixels<Color4ub>();
Expand Down
19 changes: 8 additions & 11 deletions src/Magnum/Platform/AndroidApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ to simplify porting.
@section Platform-AndroidApplication-resizing Responding to viewport events

Unlike in desktop application implementations, where this is controlled via
@ref Sdl2Application::Configuration::WindowFlag::Resizable, for example, on
Android you have to describe this in the `AndroidManifest.xml` file, as by
@ref Sdl2ApplicationWindow::Configuration::WindowFlag::Resizable, for example,
on Android you have to describe this in the `AndroidManifest.xml` file, as by
default the application gets killed and relaunched on screen orientation
change. See the @ref platforms-android-apps-manifest-screen-resize "manifest file docs"
for more information.
Expand Down Expand Up @@ -189,7 +189,7 @@ class AndroidApplication {
#endif

/**
* @brief Construct with given configuration for OpenGL context
* @brief Construct with an OpenGL context
* @param arguments Application arguments
* @param configuration Application configuration
* @param glConfiguration OpenGL context configuration
Expand All @@ -202,20 +202,17 @@ class AndroidApplication {
explicit AndroidApplication(const Arguments& arguments, const Configuration& configuration, const GLConfiguration& glConfiguration);

/**
* @brief Construct with given configuration
* @brief Construct without explicit GPU context configuration
*
* Equivalent to calling @ref AndroidApplication(const Arguments&, const Configuration&, const GLConfiguration&)
* with default-constructed @ref GLConfiguration.
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
explicit AndroidApplication(const Arguments& arguments, const Configuration& configuration = Configuration{});
#else
explicit AndroidApplication(const Arguments& arguments, const Configuration& configuration);

/**
* @brief Construct with default configuration
*
* Equivalent to calling @ref AndroidApplication(const Arguments&, const Configuration&)
* with default-constructed @ref Configuration.
*/
explicit AndroidApplication(const Arguments& arguments);
#endif

/**
* @brief Construct without creating a window
Expand Down
5 changes: 4 additions & 1 deletion src/Magnum/Platform/EmscriptenApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ bool EmscriptenApplication::tryCreate(const Configuration& configuration) {

#ifdef MAGNUM_TARGET_GL
bool EmscriptenApplication::tryCreate(const Configuration& configuration, const GLConfiguration& glConfiguration) {
CORRADE_ASSERT(_context->version() == GL::Version::None, "Platform::EmscriptenApplication::tryCreate(): window with OpenGL context already created", false);
CORRADE_ASSERT(!(configuration.windowFlags() & Configuration::WindowFlag::Contextless),
"Platform::EmscriptenApplication::tryCreate(): cannot pass Configuration::WindowFlag::Contextless when creating an OpenGL context", false);
CORRADE_ASSERT(_context->version() == GL::Version::None,
"Platform::EmscriptenApplication::tryCreate(): window with OpenGL context already created", false);

/* Create emscripten WebGL context */
EmscriptenWebGLContextAttributes attrs;
Expand Down
Loading