Magnum::Platform::EmscriptenApplication::GLConfiguration class

WebGL context configuration.


The created context is always with a double-buffered OpenGL context.

Public types

enum class Flag: Int { PremultipliedAlpha = 1 << 0, PreserveDrawingBuffer = 1 << 1, PreferLowPowerToHighPerformance = 1 << 2, FailIfMajorPerformanceCaveat = 1 << 3, ExplicitSwapControl = 1 << 4, EnableExtensionsByDefault = 1 << 5, RenderViaOffscreenBackBuffer = 1 << 6, ProxyContextToMainThread = 1 << 7 }
Context flag.
using Flags = Containers::EnumSet<Flag>
Context flags.

Public functions

auto flags() const -> Flags
Context flags.
auto setFlags(Flags flags) -> GLConfiguration&
Set context flags.
auto addFlags(Flags flags) -> GLConfiguration&
Add context flags.
auto clearFlags(Flags flags) -> GLConfiguration&
Clear context flags.
auto setVersion(GL::Version) -> GLConfiguration&
Set context version.
auto colorBufferSize() const -> Vector4i
Color buffer size.
auto setColorBufferSize(const Vector4i& size) -> GLConfiguration&
Set color buffer size.
auto depthBufferSize() const -> Int
Depth buffer size.
auto setDepthBufferSize(Int size) -> GLConfiguration&
Set depth buffer size.
auto stencilBufferSize() const -> Int
Stencil buffer size.
auto setStencilBufferSize(Int size) -> GLConfiguration&
Set stencil buffer size.
auto sampleCount() const -> Int
Sample count.
auto setSampleCount(Int count) -> GLConfiguration&
Set sample count.

Enum documentation

enum class Magnum::Platform::EmscriptenApplication::GLConfiguration::Flag: Int

Context flag.


Premultiplied alpha. If set, the alpha channel of the rendering context will be treated as representing premultiplied alpha values. If not set, the alpha channel represents non-premultiplied alpha.


Preserve drawing buffer. If set, the contents of the drawing buffer are preserved between consecutive drawEvent() calls. If not, color, depth and stencil are cleared before entering drawEvent(). Not setting this gives better performance.


Prefer low power to high performance. If set, the WebGL power preference will be set to reduce power consumption.


Fail if major performance caveat. If set, requests context creation to abort if the browser is only able to create a context that does not give good hardware-accelerated performance.


Explicit swap control. For more details, see the Emscripten API reference.


Enable WebGL extensions by default. Enabled by default. For more details, see WebGL-specific behavior and the Emscripten API reference.


Render via offscreen back buffer. For more details, see the Emscripten API reference.


Proxy content to main thread. For more details, see the Emscripten API reference.

Typedef documentation

typedef Containers::EnumSet<Flag> Magnum::Platform::EmscriptenApplication::GLConfiguration::Flags

Context flags.

Function documentation

GLConfiguration& Magnum::Platform::EmscriptenApplication::GLConfiguration::setFlags(Flags flags)

Set context flags.

Returns Reference to self (for method chaining)

Default is Flag::EnableExtensionsByDefault.

GLConfiguration& Magnum::Platform::EmscriptenApplication::GLConfiguration::addFlags(Flags flags)

Add context flags.

Returns Reference to self (for method chaining)

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

GLConfiguration& Magnum::Platform::EmscriptenApplication::GLConfiguration::clearFlags(Flags flags)

Clear context flags.

Returns Reference to self (for method chaining)

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

GLConfiguration& Magnum::Platform::EmscriptenApplication::GLConfiguration::setVersion(GL::Version)

Set context version.

GLConfiguration& Magnum::Platform::EmscriptenApplication::GLConfiguration::setColorBufferSize(const Vector4i& size)

Set color buffer size.

Default is {8, 8, 8, 0} (8-bit-per-channel RGB, no alpha).

GLConfiguration& Magnum::Platform::EmscriptenApplication::GLConfiguration::setDepthBufferSize(Int size)

Set depth buffer size.

Default is 24 bits.

GLConfiguration& Magnum::Platform::EmscriptenApplication::GLConfiguration::setStencilBufferSize(Int size)

Set stencil buffer size.

Default is 0 bits (i.e., no stencil buffer).

GLConfiguration& Magnum::Platform::EmscriptenApplication::GLConfiguration::setSampleCount(Int count)

Set sample count.

Returns Reference to self (for method chaining)

Default is 0, thus no multisampling. See also GL::Renderer::Feature::Multisampling. Note that WebGL does not allow setting the sample count, but merely enabling or disabling multisampling. Multisampling will be enabled if sample count is greater than 0.