Magnum::Platform::Sdl2Application::Configuration class

Configuration.

Public types

enum class WindowFlag: Uint32 { Resizable = SDL_WINDOW_RESIZABLE, Fullscreen = SDL_WINDOW_FULLSCREEN, FullscreenDesktop = SDL_WINDOW_FULLSCREEN_DESKTOP new in 2020.06, Borderless = SDL_WINDOW_BORDERLESS, Hidden = SDL_WINDOW_HIDDEN, Maximized = SDL_WINDOW_MAXIMIZED, Minimized = SDL_WINDOW_MINIMIZED, MouseLocked = SDL_WINDOW_INPUT_GRABBED, AlwaysOnTop = SDL_WINDOW_ALWAYS_ON_TOP new in 2020.06, SkipTaskbar = SDL_WINDOW_SKIP_TASKBAR new in 2020.06, Utility = SDL_WINDOW_UTILITY new in 2020.06, Tooltip = SDL_WINDOW_TOOLTIP new in 2020.06, PopupMenu = SDL_WINDOW_POPUP_MENU new in 2020.06, Contextless = 1u << 31, OpenGL = SDL_WINDOW_OPENGL new in 2019.10, Vulkan = SDL_WINDOW_VULKAN new in 2019.10 }
Window flag.
enum class DpiScalingPolicy: UnsignedByte { Framebuffer, Virtual, Physical, Default }
DPI scaling policy.
using WindowFlags = Containers::EnumSet<WindowFlag>
Window flags.

Public functions

auto title() const -> Containers::StringView
Window title.
auto setTitle(const Containers::StringView title) -> Configuration&
Set window title.
auto size() const -> Vector2i
Window size.
auto dpiScalingPolicy() const -> DpiScalingPolicy
DPI scaling policy.
auto dpiScaling() const -> Vector2
Custom DPI scaling.
auto setSize(const Vector2i& size, DpiScalingPolicy dpiScalingPolicy = DpiScalingPolicy::Default) -> Configuration&
Set window size.
auto setSize(const Vector2i& size, const Vector2& dpiScaling) -> Configuration&
Set window size with custom DPI scaling.
auto windowFlags() const -> WindowFlags
Window flags.
auto setWindowFlags(WindowFlags flags) -> Configuration&
Set window flags.
auto addWindowFlags(WindowFlags flags) -> Configuration& new in 2020.06
Add window flags.
auto clearWindowFlags(WindowFlags flags) -> Configuration& new in 2020.06
Clear window flags.

Enum documentation

enum class Magnum::Platform::Sdl2Application::Configuration::WindowFlag: Uint32

Window flag.

Enumerators
Resizable

Resizable window. On iOS this allows the application to respond to display orientation changes, on Emscripten this causes the framebuffer to be resized when the <canvas> size changes.

Implement viewportEvent() to react to the resizing events.

Fullscreen

Fullscreen window

FullscreenDesktop new in 2020.06

Fullscreen window at the current desktop resolution

Borderless

No window decoration. On iOS this hides the menu bar.

Hidden

Hidden window

Maximized

Maximized window

Minimized

Minimized window

MouseLocked

Window with mouse locked

AlwaysOnTop new in 2020.06

Always on top

SkipTaskbar new in 2020.06

Don't add the window to taskbar

Utility new in 2020.06

Window should be treated as a utility window

Tooltip new in 2020.06

Window should be treated as a tooltip

PopupMenu new in 2020.06

Window should be treated as a popup menu

Contextless

Do not create any GPU context. Use together with Sdl2Application(const Arguments&, const Configuration&), create(const Configuration&) or tryCreate(const Configuration&) to prevent implicit creation of an OpenGL context. Can't be used with Sdl2Application(const Arguments&, const Configuration&, const GLConfiguration&), create(const Configuration&, const GLConfiguration&) or tryCreate(const Configuration&, const GLConfiguration&).

OpenGL new in 2019.10

Request a window for use with OpenGL. Useful in combination with WindowFlag::Contextless, otherwise enabled implicitly when creating an OpenGL context using Sdl2Application(const Arguments&, const Configuration&, const GLConfiguration&), create(const Configuration&, const GLConfiguration&) or tryCreate(const Configuration&, const GLConfiguration&).

Vulkan new in 2019.10

Request a window for use with Vulkan. Useful in combination with WindowFlag::Contextless.

enum class Magnum::Platform::Sdl2Application::Configuration::DpiScalingPolicy: UnsignedByte

DPI scaling policy.

DPI scaling policy when requesting a particular window size. Can be overridden on command-line using --magnum-dpi-scaling or via the MAGNUM_DPI_SCALING environment variable.

Enumerators
Framebuffer

Framebuffer DPI scaling. The window will have the same size as requested, but the framebuffer size will be different. Supported only on macOS and iOS and is also the only supported value there.

Virtual

Virtual DPI scaling. Scales the window based on UI scaling setting in the system. Falls back to DpiScalingPolicy::Physical on platforms that don't support it. Supported only on desktop platforms (except macOS) and it's the default there.

Equivalent to --magnum-dpi-scaling virtual passed on command-line.

Physical

Physical DPI scaling. Takes the requested window size as a physical size that a window would have on platform's default DPI and scales it to have the same size on given display physical DPI. On platforms that don't have a concept of a window it causes the framebuffer to match screen pixels 1:1 without any scaling. Supported on desktop platforms except macOS and on mobile and web. Default on mobile and web.

Equivalent to --magnum-dpi-scaling physical passed on command-line.

Default

Default policy for current platform. Alias to one of DpiScalingPolicy::Framebuffer, DpiScalingPolicy::Virtual or DpiScalingPolicy::Physical depending on platform. See DPI awareness for details.

Typedef documentation

typedef Containers::EnumSet<WindowFlag> Magnum::Platform::Sdl2Application::Configuration::WindowFlags

Window flags.

Function documentation

Containers::StringView Magnum::Platform::Sdl2Application::Configuration::title() const

Window title.

The returned string view is Containers::StringViewFlag::NullTerminated and is valid until the next call to setTitle().

Configuration& Magnum::Platform::Sdl2Application::Configuration::setTitle(const Containers::StringView title)

Set window title.

Returns Reference to self (for method chaining)

Default is "Magnum SDL2 Application".

DpiScalingPolicy Magnum::Platform::Sdl2Application::Configuration::dpiScalingPolicy() const

DPI scaling policy.

If dpiScaling() is non-zero, it has a priority over this value. The --magnum-dpi-scaling command-line option has a priority over any application-set value.

Vector2 Magnum::Platform::Sdl2Application::Configuration::dpiScaling() const

Custom DPI scaling.

If zero, then dpiScalingPolicy() has a priority over this value. The --magnum-dpi-scaling command-line option has a priority over any application-set value.

Configuration& Magnum::Platform::Sdl2Application::Configuration::setSize(const Vector2i& size, DpiScalingPolicy dpiScalingPolicy = DpiScalingPolicy::Default)

Set window size.

Parameters
size Desired window size
dpiScalingPolicy Policy based on which DPI scaling will be set
Returns Reference to self (for method chaining)

Default is {800, 600} on desktop platforms. On Emscripten and iOS the default is a zero vector, meaning a value that matches the display or canvas size is autodetected. See DPI awareness for more information.

Configuration& Magnum::Platform::Sdl2Application::Configuration::setSize(const Vector2i& size, const Vector2& dpiScaling)

Set window size with custom DPI scaling.

Parameters
size Desired window size
dpiScaling Custom DPI scaling value

Compared to setSize(const Vector2i&, DpiScalingPolicy) which autodetects the DPI scaling value according to given policy, this function sets the DPI scaling directly. The resulting Sdl2Application::windowSize() is size*dpiScaling and Sdl2Application::dpiScaling() is dpiScaling.

Configuration& Magnum::Platform::Sdl2Application::Configuration::setWindowFlags(WindowFlags flags)

Set window flags.

Returns Reference to self (for method chaining)

Default are none. To avoid clearing default flags by accident, prefer to use addWindowFlags() and clearWindowFlags() instead.

Configuration& Magnum::Platform::Sdl2Application::Configuration::addWindowFlags(WindowFlags flags) new in 2020.06

Add window flags.

Returns Reference to self (for method chaining)

Unlike setWindowFlags(), ORs the flags with existing instead of replacing them. Useful for preserving the defaults.

Configuration& Magnum::Platform::Sdl2Application::Configuration::clearWindowFlags(WindowFlags flags) new in 2020.06

Clear window flags.

Returns Reference to self (for method chaining)

Unlike setWindowFlags(), ANDs the inverse of flags with existing instead of replacing them. Useful for removing default flags.