Magnum::Platform::GLContext class

Platform-specific OpenGL context.

In most cases not needed to be used directly as the initialization is done automatically in *Application classes. See Platform support for more information.

Base classes

class Magnum::GL::Context
Magnum OpenGL context.

Constructors, destructors, conversion operators

GLContext(Int argc, const char** argv, const Configuration& configuration = {}) explicit
Constructor.
GLContext(Int argc, char** argv, const Configuration& configuration = {}) explicit
GLContext(Int argc, std::nullptr_t argv, const Configuration& configuration = {}) explicit
GLContext(const Configuration& configuration = {}) explicit
Default constructor.
GLContext(NoCreateT, Int argc, const char** argv) explicit
Construct without creating the context.
GLContext(NoCreateT, Int argc, char** argv) explicit
GLContext(NoCreateT, Int argc, std::nullptr_t argv) explicit
GLContext(NoCreateT) explicit
Construct with creation delayed to later.

Public functions

void create(const Configuration& configuration = Configuration{})
Create the context.
auto tryCreate(const Configuration& configuration = Configuration{}) -> bool
Try to create the context.

Function documentation

Magnum::Platform::GLContext::GLContext(Int argc, const char** argv, const Configuration& configuration = {}) explicit

Constructor.

Equivalent to calling GLContext(NoCreateT, Int, const char**) followed by create(const Configuration&).

Magnum::Platform::GLContext::GLContext(Int argc, char** argv, const Configuration& configuration = {}) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Platform::GLContext::GLContext(Int argc, std::nullptr_t argv, const Configuration& configuration = {}) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Platform::GLContext::GLContext(const Configuration& configuration = {}) explicit

Default constructor.

Equivalent to passing {0, nullptr, configuration} to GLContext(Int, const char**, const Configuration&). Even if the command-line options are not propagated, it's still possible to affect the setup behavior from the environment or by passing a Configuration instance. See Creating a context for more information.

Magnum::Platform::GLContext::GLContext(NoCreateT, Int argc, const char** argv) explicit

Construct without creating the context.

Parses command-line arguments and sets version() to GL::Version::None, everything else is left in an empty state. Use create() or tryCreate() to create the context.

Magnum::Platform::GLContext::GLContext(NoCreateT, Int argc, char** argv) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Platform::GLContext::GLContext(NoCreateT, Int argc, std::nullptr_t argv) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Platform::GLContext::GLContext(NoCreateT) explicit

Construct with creation delayed to later.

Equivalent to passing {NoCreate, 0, nullptr} to GLContext(NoCreateT, Int, const char**). Even if the command-line options are not propagated, it's still possible to affect the renderer behavior from the environment or by passing a Configuration instance to create() or tryCreate(). See Creating a context for more information.

void Magnum::Platform::GLContext::create(const Configuration& configuration = Configuration{})

Create the context.

Meant to be called on a NoCreate'd instance. Parses command-line arguments, loads OpenGL function pointers using a platform-specific API, does initial setup, detects available features and enables them throughout the engine. If detected version is unsupported or any other error occurs, a message is printed to output and the application exits. See tryCreate() for an alternative.

bool Magnum::Platform::GLContext::tryCreate(const Configuration& configuration = Configuration{})

Try to create the context.

Unlike create(), instead of exiting prints a message to error output and returns false on error.