Ream v0.1.0-1
C++ graphics library for Linux
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
RGLMakeCurrent Class Reference

RAII guard for scoped eglMakeCurrent() calls. More...

#include <RGLMakeCurrent.h>

Public Member Functions

 RGLMakeCurrent () noexcept
 Captures the current EGL binding without changing it.
 
 RGLMakeCurrent (EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context) noexcept
 Captures the current EGL binding and makes the given one current.
 
 ~RGLMakeCurrent () noexcept
 Restores the captured EGL binding.
 
bool restore () noexcept
 Restores the EGL binding captured at construction.
 

Static Public Member Functions

static RGLMakeCurrent FromDevice (RGLDevice *device, bool keepSurfaces) noexcept
 Creates a guard that makes the given device's context current on the calling thread.
 

Detailed Description

RAII guard for scoped eglMakeCurrent() calls.

On construction it captures the currently bound EGL display, draw/read surfaces, and context, then optionally binds a new context. On destruction (or an explicit restore()) it re-binds the previously captured state. This is used throughout the GL backend to temporarily make a device's context current on the calling thread without disturbing the caller's own binding.

Constructor & Destructor Documentation

◆ RGLMakeCurrent() [1/2]

RGLMakeCurrent ( )
inlinenoexcept

Captures the current EGL binding without changing it.

Useful to snapshot and later restore() the current context.

◆ RGLMakeCurrent() [2/2]

RGLMakeCurrent ( EGLDisplay  display,
EGLSurface  draw,
EGLSurface  read,
EGLContext  context 
)
inlinenoexcept

Captures the current EGL binding and makes the given one current.

Parameters
displayThe EGL display to bind.
drawThe draw surface to bind.
readThe read surface to bind.
contextThe context to make current.

◆ ~RGLMakeCurrent()

~RGLMakeCurrent ( )
inlinenoexcept

Restores the captured EGL binding.

Member Function Documentation

◆ FromDevice()

static RGLMakeCurrent FromDevice ( RGLDevice device,
bool  keepSurfaces 
)
staticnoexcept

Creates a guard that makes the given device's context current on the calling thread.

Parameters
deviceThe device whose per-thread EGL context should be made current.
keepSurfacesIf true and the device's display is already current, the currently bound draw/read surfaces are preserved; otherwise the context is bound surfaceless.
Returns
A guard bound to the device's context, or a no-op guard (EGL_NO_DISPLAY) if the device is invalid.

◆ restore()

bool restore ( )
noexcept

Restores the EGL binding captured at construction.

Has no effect if already restored (either by a prior call or by the destructor).

Returns
true if the state was restored by this call, false if it had already been restored.