Magnum::Platform::Sdl2Application::Configuration class



Public types

enum class WindowFlag: Uint32 { Resizable = SDL_WINDOW_RESIZABLE, Fullscreen = SDL_WINDOW_FULLSCREEN, Borderless = SDL_WINDOW_BORDERLESS, AllowHighDpi = 0 deprecated in 2018.10, Hidden = SDL_WINDOW_HIDDEN, Maximized = SDL_WINDOW_MAXIMIZED, Minimized = SDL_WINDOW_MINIMIZED, MouseLocked = SDL_WINDOW_INPUT_GRABBED, 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 -> std::string
Window title.
auto setTitle(std::string 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.

Enum documentation

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

Window flag.


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 window


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


Allow high DPI.


Hidden window


Maximized window


Minimized window


Window with mouse locked


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.

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&), 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 overriden on command-line using --magnum-dpi-scaling or via the MAGNUM_DPI_SCALING environment variable.


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 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 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 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

std::string Magnum::Platform::Sdl2Application::Configuration::title() const

Window title.

Configuration& Magnum::Platform::Sdl2Application::Configuration::setTitle(std::string 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.

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.

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.