Magnum::Ui::AbstractRenderer class new in Git master

Base for renderer implementations.

A renderer implementation handles GPU-API-specific framebuffer switching, clearing and draw state setup. You'll most likely instantiate the class through RendererGL, which contains a concrete OpenGL implementation.

Derived classes

class RendererGL new in Git master
OpenGL renderer implementation.

Constructors, destructors, conversion operators

AbstractRenderer() explicit
Constructor.
AbstractRenderer(const AbstractRenderer&) deleted
Copying is not allowed.
AbstractRenderer(AbstractRenderer&&) noexcept
Move constructor.

Public functions

auto operator=(const AbstractRenderer&) -> AbstractRenderer& deleted
Copying is not allowed.
auto operator=(AbstractRenderer&&) -> AbstractRenderer& noexcept
Move assignment.
auto features() const -> RendererFeatures
Features supported by a renderer.
auto framebufferSize() const -> Vector2i
Framebuffer size.
auto currentTargetState() const -> RendererTargetState
Current target state.
auto currentDrawStates() const -> RendererDrawStates
Current draw states.
void setupFramebuffers(const Vector2i& size)
Set up framebuffer properties.
void transition(RendererTargetState targetState, RendererDrawStates drawStates)
Transition to the next renderer state.

Private functions

auto doFeatures() const -> RendererFeatures pure virtual
Implementation for features()
void doSetupFramebuffers(const Vector2i& size) pure virtual
Set up framebuffer properties.
void doTransition(RendererTargetState targetStateFrom, RendererTargetState targetStateTo, RendererDrawStates drawStatesFrom, RendererDrawStates drawStatesTo) pure virtual
Transition to the next renderer state.

Function documentation

Magnum::Ui::AbstractRenderer::AbstractRenderer(AbstractRenderer&&) noexcept

Move constructor.

Performs a destructive move, i.e. the original object isn't usable afterwards anymore.

Vector2i Magnum::Ui::AbstractRenderer::framebufferSize() const

Framebuffer size.

Initial state is a zero vector. Use setupFramebuffers() to set up framebuffer properties.

RendererTargetState Magnum::Ui::AbstractRenderer::currentTargetState() const

Current target state.

Initial state is RendererTargetState::Initial. Gets subsequently updated with the states passed to transition().

RendererDrawStates Magnum::Ui::AbstractRenderer::currentDrawStates() const

Current draw states.

Initial state is an empty set. Gets subsequently updated with the states passed to transition().

void Magnum::Ui::AbstractRenderer::setupFramebuffers(const Vector2i& size)

Set up framebuffer properties.

Used internally from AbstractUserInterface::setSize(). Exposed just for testing purposes, there should be no need to call this function directly and doing so may cause internal AbstractUserInterface state update to misbehave. Allowed to be called only if currentTargetState() is RendererTargetState::Initial or Final. Delegates to doSetupFramebuffers(), see its documentation for more information about the arguments.

void Magnum::Ui::AbstractRenderer::transition(RendererTargetState targetState, RendererDrawStates drawStates)

Transition to the next renderer state.

Used internally from AbstractUserInterface::draw(). Exposed just for testing purposes, there should be no need to call this function directly and doing so may cause internal AbstractUserInterface state update to misbehave. The targetState is expected to be an allowed transition from currentTargetState() and drawStates is expected to match restrictions of given targetState. If the set of states is different from currentTargetState() and currentDrawStates(), delegates to doTransition(), see its documentation for more information about the arguments. If the set is the same, the function is a no-op.

void Magnum::Ui::AbstractRenderer::doSetupFramebuffers(const Vector2i& size) pure virtual private

Set up framebuffer properties.

Parameters
size Framebuffer size in pixels for allocating custom framebuffer memory, resetting the scissor rectangle and other framebuffer-related operations.

Implementation for setupFramebuffers(), which is called from AbstractUserInterface::setSize(). Is guaranteed to be called only if currentTargetState() is either RendererTargetState::Initial or RendererTargetState::Final, i.e. before any doTransition() call that transitions to other states.

void Magnum::Ui::AbstractRenderer::doTransition(RendererTargetState targetStateFrom, RendererTargetState targetStateTo, RendererDrawStates drawStatesFrom, RendererDrawStates drawStatesTo) pure virtual private

Transition to the next renderer state.

Parameters
targetStateFrom Target state to transition from. Equal to currentTargetState().
targetStateTo Target state to transition to
drawStatesFrom Draw states to transition from. Equal to currentDrawStates()
drawStatesTo Draw states to transition to

Implementation for transition(), which is called from AbstractUserInterface::draw() before, between and after calls to AbstractLayer::draw() based on whether they advertise LayerFeature::DrawUsesBlending or DrawUsesScissor. The targetStateFrom and targetStateTo values are guaranteed to be one of the following combinations:

The Initial to Initial transition, while allowed in transition(), is effectively a no-op so it doesn't propagate here.

In each AbstractUserInterface::draw() invocation, the renderer is guaranteed to start at RendererTargetState::Initial, go through zero or more Draw states, optionally preceded by Composite, and end up at the Final state.