Skip to content

IRenderer Interface

Core rendering interface for Brine2D.

public interface IRenderer : Brine2D.Rendering.IDrawContext, System.IDisposable

Derived
HeadlessRenderer
SDL3Renderer

Implements IDrawContext, System.IDisposable

Remarks

Extends IDrawContext with lifecycle management, render targets, and viewport state. Consumers that only need drawing operations should depend on IDrawContext instead.

Implementations must be idempotent with respect to System.IDisposable.Dispose. GameEngine.ShutdownAsync disposes the renderer explicitly before the DI container tears down singletons; the container will then call System.IDisposable.Dispose a second time during host disposal. Guard against double-disposal with a standard _disposed flag checked at the top of your Dispose implementation.

Properties
Camera Gets or sets the active camera used for view-projection transforms.
Methods
CreateRenderTarget(int, int) Create a render target for off-screen rendering.
GetRenderTarget() Get the currently active render target (null = rendering to screen).
GetScissorRect() Get the current scissor rectangle (null if clipping is disabled).
PopRenderTarget() Restore the previous render target from the stack.
PopScissorRect() Restore the previous scissor rectangle from the stack.
PushRenderTarget(IRenderTarget) Push current render target onto stack and set a new one. Useful for nested render-to-texture operations.
PushScissorRect(Nullable<Rectangle>) Push the current scissor rect onto a stack and set a new one. Useful for nested clipping regions (e.g., nested scroll views).
SetRenderTarget(IRenderTarget) Set the active render target (null = render to screen).
SetScissorRect(Nullable<Rectangle>) Set a scissor rectangle to clip all rendering to a specific region. All draw calls will be clipped to this rectangle until disabled with null.