Skip to content

PlatformAPI reference

Class RaylibDevice

Namespace: MicroEngine.Raylib
Assembly: MicroEngine.Raylib.dll
Guide: The graphics device

The tier-0 graphics device on raylib’s OpenGL layer (rlgl): textures and render targets are OpenGL textures and framebuffers, buffers are device-owned CPU memory whose triangles are sent through rlgl’s batch, the built-in pipeline is rlgl’s default shader with the pass’s blend factors, and samplers are texture parameters set before each draw. Offscreen targets are rendered with row 0 at the top of the texture’s memory, so uploads, sampling and readback need no flipping and OpenGL’s tie rule gives the contract’s top-left rule; the window’s target (bottom-up in OpenGL) moves geometry up by 1/128 px for the same rule. Desktop OpenGL declares render targets, repeat and mirror addressing, separate filters and custom blend states; in browsers (WebGL) only render targets are declared.

C#
public sealed class RaylibDevice : GraphicsDeviceBase, IGraphicsDevice, IDisposable

Inheritance

object ← GraphicsDeviceBase ← RaylibDevice

Implements

IGraphicsDevice, IDisposable

Inherited Members

GraphicsDeviceBase.CreateTexture(in TextureDescription, ReadOnlySpan<byte>), GraphicsDeviceBase.CreateRenderTarget(in RenderTargetDescription), GraphicsDeviceBase.GetSampler(in SamplerDescription), GraphicsDeviceBase.CreateBuffer(in BufferDescription), GraphicsDeviceBase.CreateShader(in ShaderDescription), GraphicsDeviceBase.CreatePipeline(PipelineDescription), GraphicsDeviceBase.GetBuiltInPipeline(BuiltInPipeline, BlendState, TextureFormat, TextureFormat?), GraphicsDeviceBase.BeginCommands(), GraphicsDeviceBase.Submit(CommandList), GraphicsDeviceBase.ReadPixels(RenderTarget, RectI), GraphicsDeviceBase.TryAcquireSurfaceTarget(out RenderTarget?), GraphicsDeviceBase.Present(), GraphicsDeviceBase.Dispose(), GraphicsDeviceBase.TryGetResource<T>(Handle<GraphicsResource>, out T?), GraphicsDeviceBase.Capabilities, GraphicsDeviceBase.IsDisposed, GraphicsDeviceBase.Counters, GraphicsDeviceBase.PendingReleases, GraphicsDeviceBase.DeviceLost, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

RaylibDevice(ISurface, GraphicsDeviceOptions)

Creates the device on raylib’s window (raylib must have opened it).

C#
public RaylibDevice(ISurface surface, GraphicsDeviceOptions options)

Parameters

surface ISurface

raylib’s window surface.

options GraphicsDeviceOptions

The present mode (raylib’s VSync is a window flag chosen when the window opens; the device records the mode).

Exceptions

GraphicsCapabilityException

The present mode is Mailbox.

Fields

BackendName

The backend name.

C#
public const string BackendName = "raylib"

Field Value

string

Properties

Capabilities

Declared capabilities.

C#
public override GraphicsCapabilities Capabilities { get; }

Property Value

GraphicsCapabilities

PresentMode

The present mode chosen at creation.

C#
public PresentMode PresentMode { get; }

Property Value

PresentMode

SwapOnPresent

Whether Present swaps the window’s buffers (true by default). A host whose frame loop ends with raylib’s EndDrawing, which swaps them itself (and polls input), sets it to false: Present then only finishes the frame’s drawing and expires the surface target.

C#
public bool SwapOnPresent { get; init; }

Property Value

bool

Methods

CreateBufferCore(in BufferDescription)

Backend: create a validated buffer.

C#
protected override GpuBuffer CreateBufferCore(in BufferDescription description)

Parameters

description BufferDescription

Returns

GpuBuffer

CreateBuiltInPipelineCore(BuiltInPipeline, BlendState, TextureFormat, TextureFormat?)

Backend: create a built-in pipeline variant (core caches it).

C#
protected override Pipeline CreateBuiltInPipelineCore(BuiltInPipeline kind, BlendState blend, TextureFormat colorFormat, TextureFormat? depthFormat)

Parameters

kind BuiltInPipeline

blend BlendState

colorFormat TextureFormat

depthFormat TextureFormat?

Returns

Pipeline

CreatePipelineCore(PipelineDescription)

Backend: create a validated custom pipeline (tier 0 is never called: core refuses first).

C#
protected override Pipeline CreatePipelineCore(PipelineDescription description)

Parameters

description PipelineDescription

Returns

Pipeline

CreateRenderTargetCore(in RenderTargetDescription)

Backend: create a validated render target.

C#
protected override RenderTarget CreateRenderTargetCore(in RenderTargetDescription description)

Parameters

description RenderTargetDescription

Returns

RenderTarget

CreateSamplerCore(in SamplerDescription)

Backend: create a validated sampler (core caches it).

C#
protected override Sampler CreateSamplerCore(in SamplerDescription description)

Parameters

description SamplerDescription

Returns

Sampler

CreateShaderCore(in ShaderDescription)

Backend: create a validated shader (tier 0 is never called: core refuses first).

C#
protected override Shader CreateShaderCore(in ShaderDescription description)

Parameters

description ShaderDescription

Returns

Shader

CreateTextureCore(in TextureDescription, ReadOnlySpan<byte>)

Backend: create a validated texture.

C#
protected override Texture CreateTextureCore(in TextureDescription description, ReadOnlySpan<byte> initialData)

Parameters

description TextureDescription

initialData ReadOnlySpan<byte>

Returns

Texture

DisposeCore(IReadOnlyList<Pipeline>, IReadOnlyList<Sampler>)

Backend: release everything, the device-owned built-ins and samplers included.

C#
protected override void DisposeCore(IReadOnlyList<Pipeline> builtIns, IReadOnlyList<Sampler> samplers)

Parameters

builtIns IReadOnlyList<Pipeline>

samplers IReadOnlyList<Sampler>

PresentCore(RenderTarget)

Backend: present and expire the surface target.

C#
protected override void PresentCore(RenderTarget surfaceTarget)

Parameters

surfaceTarget RenderTarget

ReadPixelsCore(RenderTarget, RectI)

Backend: start a validated readback.

C#
protected override ReadbackRequest ReadPixelsCore(RenderTarget target, RectI region)

Parameters

target RenderTarget

region RectI

Returns

ReadbackRequest

SubmitCore(CommandList)

Backend: execute a validated, sealed list after everything submitted before it.

C#
protected override void SubmitCore(CommandList commands)

Parameters

commands CommandList

TryAcquireSurfaceTargetCore()

Backend: acquire this frame’s surface target or return null.

C#
protected override RenderTarget? TryAcquireSurfaceTargetCore()

Returns

RenderTarget?