nCine::RHI::LegacyGL::LegacyGlRenderTarget class

Off-screen render target of the legacy GL backend (aliased as RHI::RenderTarget).

Holds the color textures the rasterizer writes into (addressed by attachment index) and an optional depth/stencil (ignored for 2D). BindDraw() records the target on the device so the following clears and draws land in its color attachment 0.

Two ways of getting the pixels into that texture exist, chosen once by LegacyGlDevice::SupportsFramebufferObjects() (which is always false where the entry points do not exist at all - MiniGL on AmigaOS 4, see RHI_LEGACYGL_HAS_FBO in LegacyGlApi.h):

  • A framebuffer object, where one exists. Attachment 0 is the color texture itself, so the draws land in it directly and nothing is ever copied.
  • Drawing into the back buffer and copying back (IsCopyBack()), for a GL without them - which includes a TinyGL that declares the entry points but does not implement them. The target is rendered into the bottom-left corner of the drawable and glCopyTexSubImage2D() lifts the region into the texture when the device leaves the target. This costs a full-surface copy per pass and clobbers the back buffer, which is why it is the fallback: it is only correct because every render-to-texture pass in this game runs before the screen pass that clears and redraws the frame.

Public static variables

static std::uint32_t MaxColorAttachments constexpr

Public static functions

static void UnbindDraw()
Unbinds any render target from the device.

Constructors, destructors, conversion operators

LegacyGlRenderTarget()
~LegacyGlRenderTarget()
LegacyGlRenderTarget(const LegacyGlRenderTarget&) deleted

Public functions

auto operator=(const LegacyGlRenderTarget&) -> LegacyGlRenderTarget& deleted
void AttachColorTexture(LegacyGlTexture& texture, std::uint32_t index)
Attaches a texture as the color attachment with the given index.
void DetachColorTexture(std::uint32_t index)
Detaches any texture from the color attachment with the given index.
void AttachDepthStencil(DepthStencilFormat format, std::int32_t width, std::int32_t height)
Records a depth/stencil buffer (no storage - the backend is 2D).
void DetachDepthStencil(DepthStencilFormat format)
Clears the recorded depth/stencil buffer.
void BindDraw()
Binds the render target as the current draw target on the device.
auto SetDrawBuffers(std::uint32_t numColorAttachments) -> bool
Sets the number of color attachments enabled for drawing.
auto IsStatusComplete() -> bool
Returns true if the target has a usable color attachment 0.
void InvalidateDepthStencil(DepthStencilFormat format)
Hints that the depth/stencil contents are no longer needed (no-op).
void SetObjectLabel(StringView label)
Sets a debug label for the render target (ignored).
auto GetColorTexture(std::uint32_t index) const -> LegacyGlTexture*
Returns the texture attached at the given color attachment index, or nullptr.
auto GetFramebuffer() const -> std::uint32_t
Returns the framebuffer object the draws go into, or zero in the copy-back mode.
auto IsCopyBack() const -> bool
Returns true when this target is drawn into the back buffer and copied out afterwards.
void ResolveCopyBack() const
Copies the drawn region out of the back buffer into the color texture (copy-back only).