Skip to content

Overview

Brine2D

Brine2D.Rendering Namespace

Classes
Camera2D A 2D camera for viewing and navigating the game world.
CameraBounds Constrains camera movement to stay within world bounds.
CameraExtensions Stateless interpolation helpers for any ICamera.
CameraManager Default implementation of camera manager. Manages multiple cameras for different rendering viewports.
DrawContextExtensions Scoped helpers for IDrawContext state that auto-restore on dispose.
FontAtlas Represents a font atlas containing pre-rendered glyphs packed into a texture.
GpuDeviceHandle Shared, mutable reference to the GPU device pointer. The renderer creates one instance and passes it to every texture it allocates. When the renderer destroys the device, it calls Brine2D.Rendering.GpuDeviceHandle.Invalidate, and all textures that still reference this handle see System.IntPtr.Zero instead of a dangling pointer.
GPUDriverExtensions
HeadlessFontLoader No-op font loader for headless mode (servers, testing). Returns stub fonts; all operations are silently ignored.
HeadlessRenderer No-op renderer for headless mode (servers, testing). All rendering operations are silently ignored. CreateRenderTarget(int, int) is the sole exception: render targets require GPU infrastructure that does not exist in headless mode and throw System.NotSupportedException.
HeadlessTextureLoader No-op texture loader for headless mode (servers, testing). Returns zero-size stub textures; all operations are silently ignored.
RendererExtensions Extension methods for IRenderer to simplify common operations.
RenderingOptions Configuration options for the rendering system.
RenderingServiceCollectionExtensions Extension methods for registering rendering services.
ScissorRectHelper Shared scissor rectangle intersection logic used by both HeadlessRenderer and SDL3StateManager.
SDL3BatchRenderer Handles vertex batching and indexed primitive rendering operations. All geometry is emitted as groups of four vertices with a pre-generated static index buffer using the quad pattern [0, 1, 2, 1, 3, 2], reducing vertex throughput by a third for quads.
SDL3Font SDL_ttf implementation of a font.
SDL3FontLoader SDL_ttf implementation of font loader.
SDL3FrameManager Manages frame lifecycle including command buffers, swapchain acquisition, and presentation.
SDL3Lifecycle Owns the SDL3 process-level lifetime. ...SDL_Quit intentionally lives in Brine2D.Rendering.SDL3Lifecycle.Dispose, not Microsoft.Extensions.Hosting.IHostedService.StopAsync(System.Threading.CancellationToken), because StopAsync runs before DI disposal — calling it there would pull the rug from under services like AudioService that release SDL resources in their own System.IDisposable.Dispose.
SDL3Renderer SDL3 GPU API implementation of the renderer.
SDL3RenderTargetManager Manages render targets and post-processing effects.
SDL3Shader SDL3 GPU shader implementation.
SDL3ShaderLoader SDL3 shader loader using ShaderCross for cross-platform compilation. ShaderCross accepts HLSL or SPIRV as input.
SDL3StateManager Manages render state: blend modes, scissor rectangles, layers, and camera transforms.
SDL3TextRenderer Handles text rendering using font atlases and markup parsing.
SDL3Texture SDL3 GPU API texture implementation.
ShaderSource Represents shader source code.
SpriteBatcher Batches sprite draw calls for efficient rendering. Sorts and groups sprites before submission to minimize state changes and draw calls.
TilemapRenderer Handles rendering of tilemaps with sprite batching. Separates rendering from core tilemap data. Uses SpriteBatcher for optimal performance.
WindowOptions Configuration options for the game window.
Structs
BlendModeScope Restores the previous BlendMode when disposed.
FontGlyph Contains metrics and texture coordinates for a single glyph in a font atlas.
RenderLayerScope Restores the previous render layer when disposed.
SpriteBatcher.IndexComparer Compares batch items by index into the items list, avoiding full-struct copies during sort swaps. Only 4-byte indices are swapped instead of the 80+ byte SpriteBatchItem structs.
SpriteBatchItem Represents a single sprite draw call in the batch.
Interfaces
ICamera Represents a 2D camera for viewing the game world.
ICameraManager Manages multiple cameras for different viewports (gameplay, minimap, split-screen, etc.).
IDrawContext Drawing operations surface for Brine2D renderers. Consumers that only need to draw shapes, textures, and text should depend on this interface rather than the full IRenderer.
IFont Represents a loaded font that can be used for text rendering.
IFontLoader Low-level font loading interface. For most use cases, use instead.
IRenderer Core rendering interface for Brine2D.
IRenderTarget Platform-agnostic render target interface for off-screen rendering. GPU renderer only - legacy renderer throws NotSupportedException.
IShader Represents a GPU shader program.
IShaderLoader Service for loading and compiling shaders using ShaderCross. ShaderCross supports HLSL source or SPIRV bytecode as input.
IShakableCamera Opt-in contract for cameras that support screen shake. The built-in Camera2D implements this. Custom ICamera implementations that don't need shake can skip this entirely.
ITexture Represents a 2D texture that can be rendered.
ITextureContext Provides context for creating textures specific to the renderer implementation. Similar to ASP.NET's HttpContext or DbContext pattern - abstracts away implementation details.
ITextureLoader Low-level texture loading interface. For most use cases, use instead! This interface is for advanced scenarios like: - Custom texture loading implementations - Framework/system-level texture management - Direct texture operations without caching
ITrackableCamera Opt-in contract for cameras that need to clean up their registration with ICameraManager when their DI scope is torn down. The built-in Camera2D implements this. Custom ICamera implementations that want automatic unregistration should implement this interface.
Enums
BlendMode Blend modes for rendering. Controls how pixels are combined when drawing on top of existing pixels.
GPUDriver GPU backend driver for SDL3 rendering.
ShaderLanguage Supported shader source languages.
ShaderStage Shader stage types in the graphics pipeline.
ShakeSpace Determines how camera shake offset is applied relative to zoom and rotation.
SpriteFlip Flags for flipping sprites horizontally and/or vertically.
TextureScaleMode Texture scaling/filtering mode.