Skip to content

SDL3Renderer Class

Definition

Namespace: Brine2D.Rendering

SDL3 GPU API implementation of the renderer.

C#
internal sealed class SDL3Renderer : Brine2D.Rendering.IRenderer, Brine2D.Rendering.IDrawContext, System.IDisposable, Brine2D.Common.ISDL3WindowProvider, Brine2D.Rendering.ITextureContext

Inheritance System.Object → SDL3Renderer

Implements IRenderer, IDrawContext, System.IDisposable, ISDL3WindowProvider, ITextureContext

Properties
ParticleRenderer Provides direct access to the hardware-instanced particle renderer. Used internally by ParticleSystem to submit instanced draw calls without going through the public IRenderer interface.
Methods
ApplyPostProcessing() Applies post-processing effects to the current frame. Only works if post-processing is enabled via options.
BeginFrame() Begins a new frame. Silently returns \(no\-op\) when the renderer is not initialized, suspended, or unable to acquire GPU resources. Draw calls issued without a successful BeginFrame() are dropped.
BuildBlendState\(BlendMode\) Builds the SDL3.SDL.GPUColorTargetBlendState for a given blend mode. Shared between the standard and particle pipeline creation paths so the blend equations are never duplicated.
CreateParticlePipelineForBlendMode\(BlendMode, GPUTextureFormat\) Creates a two-slot instanced graphics pipeline for particle rendering. ... Vertex attribute layout: ...
CreateParticlePipelines() Creates particle pipelines for all blend modes targeting the swapchain format. Must be called after LoadParticleShaders().
CreateParticlePostProcessPipelines() Creates particle pipelines targeting the post-process render-target format when it differs from the swapchain format. No-op when post-processing is disabled or the formats are identical.
DrainPendingUploads() Releases all pending upload resources unconditionally. The caller must ensure SDL3.SDL.WaitForGPUIdle\(System\.IntPtr\) has completed before calling this method so that all fences are already signaled.
DrawNineSlice\(ITexture, Rectangle, NineSliceBorder, Nullable<Color>\) Draws a nine-slice \(9\-patch\) texture scaled into destination. Corners are drawn at their natural texel size; edges and center are stretched.
DrawTexture\(ITexture, float, float\) Draw texture at position \(float x, y, top\-left anchor\).
DrawTexture\(ITexture, float, float, float, float\) Draw texture at position with explicit width/height \(top\-left anchor\).
DrawTexture\(ITexture, Vector2\) Draw texture at position \(Vector2, top\-left anchor\).
DrawTexture\(ITexture, Vector2, Nullable<Rectangle>, Nullable<Vector2>, float, Nullable<Vector2>, Nullable<Color>, SpriteFlip\) Draw a texture with full control over transform, origin, scale, and flip.
EndFrame() Ends the current frame and submits the command buffer. Silently returns \(no\-op\) when the renderer is not initialized or disposed. When suspended, pending draw calls are discarded but the command buffer is still submitted so GPU resources are not leaked.
LoadParticleShaders() Compiles the particle shaders from HLSL source via ShaderCross.
OnWindowResized\(WindowResizedEvent\)
PopRenderTarget() Pop the current render target from the stack.
PushRenderTarget\(IRenderTarget\) Push the current render target onto a stack and set a new one. Useful for nested render-to-texture operations.
ReadPixelsAsync\(ITexture, CancellationToken\) Asynchronously downloads the pixel data from a GPU texture to a CPU-side byte array.
RenderGlyphs\(ReadOnlySpan<char>, float, float, Color, ITexture, float, float, float, float, bool, float, Action<float,float,float>, Nullable<float>\)