Magnum::Platform::WindowlessWglContext class

Windowless WGL context.

GL context using pure WINAPI, used in WindowlessWglApplication.

Meant to be used when there is a need to manage (multiple) GL contexts manually. See Manually managing windowless contexts for more information. If no other application header is included, this class is also aliased to Platform::WindowlessGLContext.

Public types

class Configuration
Configuration.

Constructors, destructors, conversion operators

WindowlessWglContext(const Configuration& configuration, GLContext* context = nullptr) explicit
Constructor.
WindowlessWglContext(NoCreateT) explicit
Construct without creating the context.
WindowlessWglContext(const WindowlessWglContext&) deleted
Copying is not allowed.
WindowlessWglContext(WindowlessWglContext&& other) noexcept
Move constructor.
~WindowlessWglContext()
Destructor.

Public functions

auto operator=(const WindowlessWglContext&) -> WindowlessWglContext& deleted
Copying is not allowed.
auto operator=(WindowlessWglContext&& other) -> WindowlessWglContext& noexcept
Move assignment.
auto isCreated() const -> bool
Whether the context is created.
auto makeCurrent() -> bool
Make the context current.
auto release() -> bool new in Git master
Release current context.
auto glContext() -> HGLRC new in 2020.06
Underlying OpenGL context.

Function documentation

Magnum::Platform::WindowlessWglContext::WindowlessWglContext(const Configuration& configuration, GLContext* context = nullptr) explicit

Constructor.

Parameters
configuration Context configuration
context Optional Magnum context instance constructed using NoCreate to manage driver workarounds

On desktop GL, if version is not specified in configuration, the application first tries to create core context (OpenGL 3.1+) and if that fails, falls back to compatibility OpenGL 2.1 context. However, on binary AMD and NVidia drivers, creating core context does not use the largest available version. If the application detects such case (and given workaround is not disabled in optionally passed context instance), the core context is destroyed and compatibility OpenGL 2.1 context is created instead to make the driver use the latest available version.

Once the context is created, make it current using makeCurrent() and create Platform::GLContext instance to be able to use Magnum.

Magnum::Platform::WindowlessWglContext::WindowlessWglContext(NoCreateT) explicit

Construct without creating the context.

Move a instance with created context over to make it usable.

Magnum::Platform::WindowlessWglContext::~WindowlessWglContext()

Destructor.

Destroys the context, if any.

bool Magnum::Platform::WindowlessWglContext::makeCurrent()

Make the context current.

Prints error message and returns false on failure, otherwise returns true. If the context is current on another thread, you have to release() it there first — an OpenGL context can't be current in multiple threads at the same time.

bool Magnum::Platform::WindowlessWglContext::release() new in Git master

Release current context.

Releases a context previously made current using makeCurrent(). Prints error message and returns false on failure, otherwise returns true.

HGLRC Magnum::Platform::WindowlessWglContext::glContext() new in 2020.06

Underlying OpenGL context.

Use in case you need to call WGL functionality directly or in order to create a shared context. Returns nullptr in case the context was not created yet.