|
Aegis2D
Modular C++26 2D game engine for networked games
|
OpenGL core profile context of a window, with every OpenGL function loaded. More...
#include <aegis2d/render/opengl/context.hpp>
Public Member Functions | |
| Context (const platform::Window &window, const ContextConfig &config={}) | |
| Creates the context, makes it current and loads the OpenGL functions. | |
| Context (const Context &)=delete | |
| Context & | operator= (const Context &)=delete |
| Context (Context &&other) noexcept | |
Takes over the context of other, which must not be used afterwards. | |
| Context & | operator= (Context &&other) noexcept |
Destroys this context and takes over the context of other. | |
| ~Context () | |
| Destroys the context. | |
| void | make_current () |
| Makes the context current on the calling thread. | |
| void | clear (Color color) |
| Fills the whole framebuffer with one color. | |
| void | swap_buffers () |
| Shows the frame drawn since the previous call. | |
| DebugOutput | debug_output () const noexcept |
| How OpenGL errors are reported for this context. | |
| std::size_t | check_errors () |
| Logs and clears the OpenGL errors recorded since the previous check. | |
| Version | version () const noexcept |
| Version of the context actually created, as reported by the driver. | |
| const DriverInfo & | info () const noexcept |
| Driver strings read when the context was created. | |
Static Public Member Functions | |
| static Version | required_version () noexcept |
| Version the engine requires from the context. | |
OpenGL core profile context of a window, with every OpenGL function loaded.
The context has the version the engine's OpenGL loader is generated for: 4.5, or 4.1 when AEGIS2D_MACOS_GL41 is on (the highest macOS supports). It is current on the creating thread once the constructor returns.
The OpenGL functions are process-wide: use one context, for one window. Destroy the context before its window.
|
explicit |
Creates the context, makes it current and loads the OpenGL functions.
| window | Window created with platform::GraphicsApi::OpenGL. |
| config | Swap behaviour of the context. |
| ContextError | if the window is not an OpenGL window, or if the driver cannot give a context of the required version (macOS with the 4.5 build, Windows without a GPU driver, which only provides OpenGL 1.1). |
|
delete |
|
noexcept |
Takes over the context of other, which must not be used afterwards.
| aegis2d::render::opengl::Context::~Context | ( | ) |
Destroys the context.
| std::size_t aegis2d::render::opengl::Context::check_errors | ( | ) |
Logs and clears the OpenGL errors recorded since the previous check.
Reads glGetError until no error is left, whatever debug_output() is. With DebugOutput::Callback, the driver has already logged each error, with more detail, when it happened.
| void aegis2d::render::opengl::Context::clear | ( | Color | color | ) |
Fills the whole framebuffer with one color.
The viewport follows the window's pixel size, so a resized window is cleared entirely.
| color | Color to fill the framebuffer with. |
|
noexcept |
How OpenGL errors are reported for this context.
Off unless ContextConfig::debug was set; then Callback when the driver supports KHR_debug, Polling otherwise.
|
noexcept |
Driver strings read when the context was created.
| void aegis2d::render::opengl::Context::make_current | ( | ) |
Makes the context current on the calling thread.
| ContextError | if SDL cannot make it current. |
Destroys this context and takes over the context of other.
|
staticnoexcept |
Version the engine requires from the context.
AEGIS2D_MACOS_GL41. | void aegis2d::render::opengl::Context::swap_buffers | ( | ) |
Shows the frame drawn since the previous call.
With DebugOutput::Polling, first logs the errors of the frame.
|
noexcept |
Version of the context actually created, as reported by the driver.