nCine::RHI::GL::GLDevice class

Pipeline-state and draw-call facade of the OpenGL backend.

Exposes everything the render pipeline sets between draws — blending, depth, scissor, viewport, clear — plus the draw calls themselves, with backend-neutral signatures (aliased as RHI::Device). Delegates to the individual OpenGL state-cache wrappers, so redundant state changes keep being filtered exactly as before.

Public types

struct ScissorState
Snapshot of the scissor test state, used to save and restore it around a draw.
struct BlendingState
Snapshot of the blending state, used to save and restore it around a draw.
struct DepthTestState
Snapshot of the depth test state, used to save and restore it around a draw.
struct CullFaceState
Snapshot of the face culling state, used to save and restore it around a draw.

Public static functions

static void SetBlendingEnabled(bool enabled)
Enables or disables blending.
static void SetBlendingFactors(BlendingFactor srcRgb, BlendingFactor dstRgb, BlendingFactor srcAlpha, BlendingFactor dstAlpha)
Sets separate blending factors for color and alpha.
static auto GetBlendingState() -> BlendingState
Returns the whole blending state.
static void SetBlendingState(const BlendingState& state)
Restores the whole blending state.
static void SetDepthTestEnabled(bool enabled)
Enables or disables the depth test.
static void SetDepthMaskEnabled(bool enabled)
Enables or disables writing to the depth buffer.
static auto GetDepthTestState() -> DepthTestState
Returns the whole depth test state.
static void SetDepthTestState(const DepthTestState& state)
Restores the whole depth test state.
static void SetCullFaceEnabled(bool enabled)
Enables or disables face culling.
static auto GetCullFaceState() -> CullFaceState
Returns the whole face culling state.
static void SetCullFaceState(const CullFaceState& state)
Restores the whole face culling state.
static auto GetScissorState() -> ScissorState
Returns the whole scissor test state.
static void SetScissorState(const ScissorState& state)
Restores the whole scissor test state.
static void SetScissor(const Recti& rect)
Enables the scissor test with the specified rectangle.
static void SetScissorTestEnabled(bool enabled)
Enables (reusing the last rectangle) or disables the scissor test.
static auto GetViewport() -> Recti
Returns the current viewport rectangle.
static void SetViewport(const Recti& rect)
Sets the viewport rectangle.
static void InitViewport(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height)
Initializes the cached viewport rectangle right after context creation.
static auto GetClearColor() -> Colorf
Returns the current clear color.
static void SetClearColor(const Colorf& color)
Sets the clear color.
static void Clear(ClearFlags flags)
Clears the specified buffers of the current render target.
static void DrawArrays(PrimitiveType primitive, std::int32_t firstVertex, std::int32_t numVertices)
Draws non-indexed geometry.
static void DrawArraysInstanced(PrimitiveType primitive, std::int32_t firstVertex, std::int32_t numVertices, std::int32_t numInstances)
Draws non-indexed geometry with instancing.
static void DrawElements(PrimitiveType primitive, std::uint32_t numIndices, IndexFormat indexFormat, std::uintptr_t indexOffset, std::int32_t baseVertex)
Draws indexed geometry.
static void DrawElements(PrimitiveType primitive, std::uint32_t numIndices, std::uintptr_t indexOffset, std::int32_t baseVertex)
Draws indexed geometry with 16-bit indices.
static void DrawElementsInstanced(PrimitiveType primitive, std::uint32_t numIndices, IndexFormat indexFormat, std::uintptr_t indexOffset, std::int32_t numInstances, std::int32_t baseVertex)
Draws indexed geometry with instancing.
static void DrawElementsInstanced(PrimitiveType primitive, std::uint32_t numIndices, std::uintptr_t indexOffset, std::int32_t numInstances, std::int32_t baseVertex)
Draws indexed geometry (16-bit indices) with instancing.
static auto InsertFence() -> FenceHandle
Inserts a fence that signals once all previously submitted commands complete.
static void DeleteFence(FenceHandle& fence)
Deletes a fence and resets the handle to nullptr (accepts a null handle).
static auto ClientWaitFence(FenceHandle fence, std::uint64_t timeoutNs) -> bool
Blocks until the fence signals, flushing pending commands; returns false on timeout or failure.
static void SetupInitialState()
Applies the initial pipeline state once after context creation.
static auto CreateSwapchain(void* windowHandle, std::int32_t width, std::int32_t height, bool vsync) -> bool
No-op (the window backend owns the GL context; there is no backend swap chain).
static void DestroySwapchain()
No-op.
static void ResizeSwapchain(std::int32_t width, std::int32_t height)
No-op (the GL default framebuffer resizes with the window).
static void PresentFrame()
No-op (the window backend performs the buffer swap).

Constructors, destructors, conversion operators

GLDevice() deleted
~GLDevice() deleted

Function documentation

static void nCine::RHI::GL::GLDevice::DrawElements(PrimitiveType primitive, std::uint32_t numIndices, IndexFormat indexFormat, std::uintptr_t indexOffset, std::int32_t baseVertex)

Draws indexed geometry.

Parameters
primitive
numIndices
indexFormat
indexOffset Byte offset of the first index within the bound index buffer
baseVertex Added to each index — ignored by backends without base-vertex support, where the caller offsets the vertex format instead