Graphics

Graphics API

Namespace: dmGraphics
Include: #include <dmsdk/graphics/graphics.h>
TYPES
HContext Context handle
HIndexBuffer Index buffer handle
HProgram Program handle
HRenderTarget Rendertarget handle
HStorageBuffer Storage buffer handle
HTexture Texture handle
HUniformLocation Uniform location handle
HVertexBuffer Vertex buffer handle
HVertexDeclaration Vertex declaration handle
HVertexStreamDeclaration Vertex stream declaration handle
SetTextureAsyncCallback Function called when a texture has been set asynch...
CONSTANTS
INVALID_PROGRAM_HANDLE Invalid program handle constant
INVALID_STREAM_OFFSET Invalid stream offset
INVALID_UNIFORM_LOCATION Invalid uniform location constant
MAX_BUFFER_COLOR_ATTACHMENTS Max buffer color attachments
ENUMS
AdapterFamily Graphics adapter family
AttachmentOp Defines how an attachment should be treated at the...
BlendFactor Blend factors for color blending
BufferAccess
BufferUsage Buffer usage hints
CompareFunc Depth and alpha test comparison functions
FaceWinding
HandleResult Function's call result code
IndexBufferFormat Index buffer element types
PrimitiveType Primitive drawing modes
RenderTargetAttachment Attachment points for render targets
StencilOp Stencil test actions
TextureFilter Texture filtering modes
TextureFormat Pixel formats supported by textures
TextureStatusFlags Texture data upload status flags
TextureType Texture types
TextureWrap Texture addressing/wrapping modes
Type Data type
STRUCTS
struct ContextParams Graphics context creation parameters
struct ShaderDesc Shader program description (from graphics_ddf.h)
struct TextureCreationParams Texture creation parameters
struct TextureParams Texture update parameters
FUNCTIONS
void AddVertexStream(const char* name, uint32_t size, dmGraphics::Type type, bool normalize) Adds a stream to a vertex stream declaration
void AddVertexStream(dmhash_t name_hash, uint32_t size, dmGraphics::Type type, bool normalize) Adds a stream to a vertex stream declaration
void BeginFrame(dmGraphics::HContext context) Begins frame rendering
void Clear(dmGraphics::HContext context, uint32_t flags, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha, float depth, uint32_t stencil) Clears the render target buffers
void CloseWindow(dmGraphics::HContext context) Closes the window associated with the graphics con...
void DeleteContext(dmGraphics::HContext context) Destroys a graphics context
void DeleteIndexBuffer(dmGraphics::HIndexBuffer buffer) Delete the index buffer
void DeleteProgram(dmGraphics::HContext context, dmGraphics::HProgram program) Destroys a shader program and frees associated res...
void DeleteRenderTarget(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target)
void DeleteTexture(dmGraphics::HContext context, dmGraphics::HTexture texture) Delete texture
void DeleteVertexBuffer(dmGraphics::HVertexBuffer buffer) Delete vertex buffer
void DeleteVertexDeclaration(dmGraphics::HVertexDeclaration vertex_declaration) Delete vertex declaration
void DeleteVertexStreamDeclaration(dmGraphics::HVertexStreamDeclaration stream_declaration) Delete vertex stream declaration
void DisableProgram(dmGraphics::HContext context) Deactivates the currently bound shader program
void DisableState(dmGraphics::HContext context, dmGraphics::State state)
void DisableTexture(dmGraphics::HContext context, uint32_t unit, dmGraphics::HTexture texture) Disable a texture bound to a texture unit
void DisableVertexBuffer(dmGraphics::HContext context, dmGraphics::HVertexBuffer vertex_buffer) Unbinds a vertex buffer from the graphics pipeline
void DisableVertexDeclaration(dmGraphics::HContext context, dmGraphics::HVertexDeclaration vertex_declaration) Unbinds a vertex declaration from the graphics pip...
void Draw(dmGraphics::HContext context, dmGraphics::PrimitiveType prim_type, uint32_t first, uint32_t count, uint32_t instance_count) Draws non-indexed primitives
void EnableProgram(dmGraphics::HContext context, dmGraphics::HProgram program) Activates a shader program for rendering
void EnableState(dmGraphics::HContext context, dmGraphics::State state)
void EnableTexture(dmGraphics::HContext context, uint32_t unit, uint8_t id_index, dmGraphics::HTexture texture) Enable and bind a texture to a texture unit
void EnableVertexBuffer(dmGraphics::HContext context, dmGraphics::HVertexBuffer vertex_buffer, uint32_t binding_index) Binds a vertex buffer for rendering
void EnableVertexDeclaration(dmGraphics::HContext context, dmGraphics::HVertexDeclaration vertex_declaration, uint32_t binding_index, uint32_t base_offset, dmGraphics::HProgram program) Binds a vertex declaration for rendering
void Finalize() Finalizes the graphics system
dmGraphics::HUniformLocation FindUniformLocation(dmGraphics::HProgram program, dmhash_t name_hash) Finds the location of a uniform variable in a shad...
dmGraphics::HUniformLocation FindUniformLocation(dmGraphics::HProgram program, const char* name) Finds the location of a uniform variable in a shad...
void Flip(dmGraphics::HContext context) Flips screen buffers
dmGraphics::AdapterFamily GetAdapterFamily(const char* adapter_name) Gets the adapter family from a string name
float GetDisplayScaleFactor(dmGraphics::HContext context) Get the scale factor of the display
uint32_t GetHeight(dmGraphics::HContext context) Returns the specified height of the opened window,...
dmGraphics::AdapterFamily GetInstalledAdapterFamily() Get installed graphics adapter family
dmGraphics::HContext GetInstalledContext()
uint32_t GetMaxElementsIndices(dmGraphics::HContext context) Get the max number of indices allowed by the syste...
uint32_t GetMaxElementsVertices(dmGraphics::HContext context) Get the max number of vertices allowed by the syst...
uint32_t GetMaxTextureSize(dmGraphics::HContext context) Get maximum supported size in pixels of non-array ...
uint32_t GetNumSupportedExtensions(dmGraphics::HContext context)
uint8_t GetNumTextureHandles(dmGraphics::Context context, dmGraphics::HTexture texture) Get how many platform-dependent texture handle use...
uint16_t GetOriginalTextureHeight(dmGraphics::HContext context, dmGraphics::HTexture texture) Get texture original (before uploading to GPU) hei...
uin16_t GetOriginalTextureWidth(dmGraphics::HContext context, dmGraphics::HTexture texture) Get texture original (before uploading to GPU) wid...
dmGraphics::PipelineState GetPipelineState(dmGraphics::HContext context)
dmGraphics::HTexture GetRenderTargetAttachment(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, dmGraphics::RenderTargetAttachment attachment_type) Get the attachment texture from a render target. R...
void GetRenderTargetSize(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, dmGraphics::BufferType buffer_type, uint32_t& width, uint32_t& height)
dmGraphics::HTexture GetRenderTargetTexture(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, dmGraphics::BufferType buffer_type)
const char* GetSupportedExtension(dmGraphics::HContext context, uint32_t index) get the supported extension
uint16_t GetTextureDepth(dmGraphics::HContext context, dmGraphics::HTexture texture) Get texture depth. applicable for 3D and cube map ...
const char* GetTextureFormatLiteral(dmGraphics::TextureFormat format) Get string representation of texture format
dmGraphics::HandleResult GetTextureHandle(dmGraphics::HTexture texture, void** out_handle) Get the native graphics API texture object from an...
uint16_t GetTextureHeight(dmGraphics::HContext context, dmGraphics::HTexture texture) Get texture height
uint8_t GetTextureMipmapCount(dmGraphice::HContext context, dmGraphics::HTexture texture) Get texture mipmap count
uint32_t GetTextureResourceSize(dmGraphics::HContext context, dmGraphics::HTexture texture) Get approximate size of how much memory texture co...
dmGraphics::TextureStatusFlags GetTextureStatusFlags(dmGraphics::HContext context, dmGraphics::HTexture texture) Get status of texture
dmGraphics::TextureType GetTextureType(dmGraphics::HContext context, dmGraphics::HTexture texture) Get texture type
const char* GetTextureTypeLiteral(dmGraphics::TextureType texture_type) Get string representation of texture type
uint32_t GetTextureUsageHintFlags(dmGraphics::HContext context, dmGraphics::HTexture texture) Query usage hint flags for a texture
uint16_t GetTextureWidth(dmGraphics::HContext context, dmGraphics::HTexture texture) Get texture width
 GetVertexStreamOffset(dmGraphics::HVertexDeclaration vertex_declaration, dmhash_t name_hash) Get the physical offset into the vertex data for a...
void GetViewport(dmGraphics::HContext context, int32_t x, int32_t y, uint32_t width, uint32_t height) Get viewport's parameters
uint32_t GetWidth(dmGraphics::HContext context) Returns the specified width of the opened window, ...
uint32_t GetWindowHeight(dmGraphics::HContext context) Return the height of the opened window, if any.
uint32_t GetWindowWidth(dmGraphics::HContext context) Return the width of the opened window, if any.
bool InstallAdapter(dmGraphics::AdapterFamily family) Installs a graphics adapter
bool IsExtensionSupported(dmGraphics::HContext context, const char* extension) check if an extension is supported
void IsIndexBufferFormatSupported(dmGraphics::HContext context, dmGraphics::IndexBufferFormat format, bool result) Check if the index format is supported
bool IsTextureFormatSupported(dmGraphics::HContext context, dmGraphics::TextureFormat format) check if a specific texture format is supported
dmGraphics::HContext NewContext(const dmGraphics::ContextParams& params) Creates a new graphics context
dmGraphics::HIndexBuffer NewIndexBuffer(dmGraphics::HContext context, uint32_t size, void* data, dmGraphics::BufferUsage buffer_usage) Create new index buffer with initial data
dmGraphics::HProgram NewProgram(dmGraphics::HContext context, dmGraphics::ShaderDesc* ddf, char* error_buffer, uint32_t error_buffer_size) Creates a new shader program from a shader descrip...
dmGraphics::HRenderTarget NewRenderTarget(dmGraphics::HContext context, uint32_t buffer_type_flags, dmGraphics::const RenderTargetCreationParams params)
dmGraphics::HTexture NewTexture(HContext context, const dmGraphics::TextureCreationParams& params) Create new texture
dmGraphics::HVertexBuffer NewVertexBuffer(dmGraphics::HContext context, uint32_t size, void* data, dmGraphics::BufferUsage buffer_usage) Create new vertex buffer with initial data
dmGraphics::HVertexDeclaration NewVertexDeclaration(dmGraphics::HContext context, dmGraphics::HVertexStreamDeclaration stream_declaration) Create new vertex declaration from a vertex stream...
dmGraphics::HVertexDeclaration NewVertexDeclaration(dmGraphics::HContext context, dmGraphics::HVertexStreamDeclaration stream_declaration, uint32_t stride) Create new vertex declaration from a vertex stream...
dmGraphics::HVertexStreamDeclaration NewVertexStreamDeclaration(dmGraphics::HContext context) Create new vertex stream declaration. A stream dec...
dmGraphics::HVertexStreamDeclaration NewVertexStreamDeclaration(dmGraphics::HContext context, dmGraphics::VertexStepFunction step_function) Create new vertex stream declaration. A stream dec...
void ReadPixels(dmGraphics::HContext context, int32_t x, int32_t y, uint32_t width, uint32_t height, void* buffer, uint32_t buffer_size) Read frame buffer pixels in BGRA format
void RepackRGBToRGBA(uint32_t num_pixels, uint8_t* rgb, uint8_t* rgba)
void SetBlendFunc(dmGraphics::HContext context, gmGraphics::BlendFactor source_factor, dmGraphics::BlendFactor destination_factor)
void SetColorMask(dmGraphics::HContext context, bool red, bool green, bool blue, bool alpha)
void SetCullFace(dmGraphics::HContext context, dmGraphics::FaceType face_type)
void SetDepthFunc(dmGraphics::HContext context, dmGraphics::CompareFunc func)
void SetDepthMask(dmGraphics::HContext context, bool enable_mask)
void SetIndexBufferData(dmGraphics::HIndexBuffer buffer, uint32_t size, void* data, dmGraphics::BufferUsage buffer_usage) Set index buffer data
void SetIndexBufferSubData(dmGraphics::HVertexBuffer buffer, uint32_t offset, uint32_t size, void* data) Set subset of index buffer data
void SetRenderTarget(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, uint32_t transient_buffer_types)
void SetRenderTargetSize(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, uint32_t width, uint32_t height)
void SetSampler(dmGraphics::HContext context, dmGraphics::HUniformLocation location, int32_t unit) Binds a texture sampler to a texture unit
void SetStencilFunc(dmGraphics::HContext context, dmGraphics::CompareFunc func, uint32_t ref, uint32_t mask)
void SetStencilFuncSeparate(dmGraphics::HContext context, dmGraphics::FaceType face_type, dmGraphics::CompareFunc func, uint32_t ref, uint32_t mask)
void SetStencilMask(dmGraphics::HContext context, uint32_t mask)
void SetStencilOp(dmGraphics::HContext context, dmGraphics::StencilOp sfail, dmGraphics::StencilOp dpfail, dmGraphics::StencilOp dppass)
void SetStencilOpSeparate(dmGraphics::HContext context, dmGraphics::FaceType face_type, dmGraphics::StencilOp sfail, dmGraphics::StencilOp dpfail, dmGraphics::StencilOp dppass)
void SetTexture(dmGraphics::HContext context, dmGraphics::HTexture texture, const dmGraphics::TextureParams& params) Set texture data. For textures of type TEXTURE_TYP...
void SetTextureAsync(dmGraphics::HContext context, dmGraphics::HTexture texture, const dmGraphics::TextureParams& params, dmGraphics::SetTextureAsyncCallback callback, void* user_data) Set texture data asynchronously. For textures of t...
void SetTextureParams(dmGraphics::HContext context, dmGraphics::HTexture texture, dmGraphics::TextureFilter min_filter, dmGraphics::TextureFilter mag_filter, dmGraphics::TextureWrap uwrap, dmGraphics::TextureWrap vwrap, float max_anisotropy) Set texture parameters
void SetVertexBufferData(dmGraphics::HVertexBuffer buffer, uint32_t size, void* data, dmGraphics::BufferUsage buffer_usage) Set vertex buffer data
void SetVertexBufferSubData(dmGraphics::HVertexBuffer buffer, uint32_t offset, uint32_t size, void* data) Set subset of vertex buffer data
void SetViewport(dmGraphics::HContext context, int32_t x, int32_t y, int32_t width, int32_t height) Sets the viewport for rendering

Functions

AddVertexStream

void AddVertexStream(const char* name, uint32_t size, dmGraphics::Type type, bool normalize)

Adds a stream to a vertex stream declaration

PARAMETERS

const char* name the name of the stream
uint32_t size the size of the stream, i.e number of components
dmGraphics::Type type the data type of the stream
bool normalize true if the stream should be normalized in the 0..1 range

AddVertexStream

void AddVertexStream(dmhash_t name_hash, uint32_t size, dmGraphics::Type type, bool normalize)

Adds a stream to a vertex stream declaration

PARAMETERS

dmhash_t name_hash the name hash of the stream
uint32_t size the size of the stream, i.e number of components
dmGraphics::Type type the data type of the stream
bool normalize true if the stream should be normalized in the 0..1 range

BeginFrame

void BeginFrame(dmGraphics::HContext context)

Begins frame rendering. Prepares the graphics context for rendering a new frame. This should be called at the start of each frame.

PARAMETERS

dmGraphics::HContext context Graphics context

Clear

void Clear(dmGraphics::HContext context, uint32_t flags, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha, float depth, uint32_t stencil)

Clears the render target buffers. Fills the specified buffers with predefined values. Commonly used at the beginning of a frame to clear the screen to a specific color and depth.

PARAMETERS

dmGraphics::HContext context Graphics context
uint32_t flags Bitmask specifying which buffers to clear (BUFFER_TYPE_*)
uint8_t red Red component value (0-255)
uint8_t green Green component value (0-255)
uint8_t blue Blue component value (0-255)
uint8_t alpha Alpha component value (0-255)
float depth Depth value to clear depth buffer to
uint32_t stencil Stencil value to clear stencil buffer to

CloseWindow

void CloseWindow(dmGraphics::HContext context)

Closes the window associated with the graphics context. If a window is open, this will close it and clean up associated resources.

PARAMETERS

dmGraphics::HContext context Graphics context

DeleteContext

void DeleteContext(dmGraphics::HContext context)

Destroys a graphics context. Cleans up all resources associated with the graphics context. The context becomes invalid after this call.

PARAMETERS

dmGraphics::HContext context Graphics context to destroy

DeleteIndexBuffer

void DeleteIndexBuffer(dmGraphics::HIndexBuffer buffer)

Delete the index buffer

PARAMETERS

dmGraphics::HIndexBuffer buffer the index buffer

DeleteProgram

void DeleteProgram(dmGraphics::HContext context, dmGraphics::HProgram program)

Destroys a shader program and frees associated resources. Cleans up GPU memory and resources associated with the program handle. The handle becomes invalid after this call.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HProgram program Program handle to destroy

DeleteRenderTarget

void DeleteRenderTarget(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HRenderTarget render_target

DeleteTexture

void DeleteTexture(dmGraphics::HContext context, dmGraphics::HTexture texture)

Delete texture

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

DeleteVertexBuffer

void DeleteVertexBuffer(dmGraphics::HVertexBuffer buffer)

Delete vertex buffer

PARAMETERS

dmGraphics::HVertexBuffer buffer the buffer

DeleteVertexDeclaration

void DeleteVertexDeclaration(dmGraphics::HVertexDeclaration vertex_declaration)

Delete vertex declaration

PARAMETERS

dmGraphics::HVertexDeclaration vertex_declaration the vertex declaration

DeleteVertexStreamDeclaration

void DeleteVertexStreamDeclaration(dmGraphics::HVertexStreamDeclaration stream_declaration)

Delete vertex stream declaration

PARAMETERS

dmGraphics::HVertexStreamDeclaration stream_declaration the vertex stream declaration

DisableProgram

void DisableProgram(dmGraphics::HContext context)

Deactivates the currently bound shader program. Unbinds any active program from the graphics pipeline, returning to the default state where no custom shader program is active.

PARAMETERS

dmGraphics::HContext context Graphics context

DisableState

void DisableState(dmGraphics::HContext context, dmGraphics::State state)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::State state Render state

DisableTexture

void DisableTexture(dmGraphics::HContext context, uint32_t unit, dmGraphics::HTexture texture)

Disable a texture bound to a texture unit. Unbinds the given texture handle from the specified unit, releasing the association in the graphics pipeline. This is useful to prevent unintended reuse of textures, or to free up texture units for other bindings.

PARAMETERS

dmGraphics::HContext context Graphics context
uint32_t unit Texture unit index to disable. Must match the one previously used in dmGraphics::EnableTexture
dmGraphics::HTexture texture Handle to the texture object to disable

DisableVertexBuffer

void DisableVertexBuffer(dmGraphics::HContext context, dmGraphics::HVertexBuffer vertex_buffer)

Unbinds a vertex buffer from the graphics pipeline. Removes the association between a vertex buffer and its binding index, freeing up the binding slot for other buffers.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HVertexBuffer vertex_buffer Vertex buffer handle to unbind

DisableVertexDeclaration

void DisableVertexDeclaration(dmGraphics::HContext context, dmGraphics::HVertexDeclaration vertex_declaration)

Unbinds a vertex declaration from the graphics pipeline. Removes the association between a vertex declaration and its binding index, freeing up the binding slot for other declarations.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HVertexDeclaration vertex_declaration Vertex declaration handle to unbind

Draw

void Draw(dmGraphics::HContext context, dmGraphics::PrimitiveType prim_type, uint32_t first, uint32_t count, uint32_t instance_count)

Draws non-indexed primitives. Renders geometry using vertex data directly from the bound vertex buffers without index buffer indirection. The vertices are processed sequentially from the specified starting point.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::PrimitiveType prim_type Type of primitives to draw
uint32_t first Index of the first vertex to draw
uint32_t count Number of vertices to draw
uint32_t instance_count Number of instances to draw (for instanced rendering)

EnableProgram

void EnableProgram(dmGraphics::HContext context, dmGraphics::HProgram program)

Activates a shader program for rendering. Binds the specified program to the graphics pipeline, making it the active program for all subsequent rendering operations until another program is activated or disabled.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HProgram program Program handle to activate

EnableState

void EnableState(dmGraphics::HContext context, dmGraphics::State state)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::State state Render state

EnableTexture

void EnableTexture(dmGraphics::HContext context, uint32_t unit, uint8_t id_index, dmGraphics::HTexture texture)

Enable and bind a texture to a texture unit. Associates a texture object with a specific texture unit in the graphics context, making it available for sampling in shaders. Multiple textures can be active simultaneously by binding them to different units. The shader must reference the correct unit (via sampler uniform) to access the bound texture

PARAMETERS

dmGraphics::HContext context Graphics context
uint32_t unit Texture unit index to bind the texture to. Valid range depends on GPU capabilities (commonly 0–15 for at least 16 texture units)
uint8_t id_index Index for internal tracking or binding variation. Typically used when multiple texture IDs are managed within the same unit (e.g. array textures or multi-bind)
dmGraphics::HTexture texture Handle to the texture object to enable and bind

EnableVertexBuffer

void EnableVertexBuffer(dmGraphics::HContext context, dmGraphics::HVertexBuffer vertex_buffer, uint32_t binding_index)

Binds a vertex buffer for rendering. Associates a vertex buffer with a specific binding index in the graphics pipeline. The buffer provides the actual vertex data that will be processed according to the active vertex declaration for that binding index.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HVertexBuffer vertex_buffer Vertex buffer handle
uint32_t binding_index Binding index to associate with this buffer

EnableVertexDeclaration

void EnableVertexDeclaration(dmGraphics::HContext context, dmGraphics::HVertexDeclaration vertex_declaration, uint32_t binding_index, uint32_t base_offset, dmGraphics::HProgram program)

Binds a vertex declaration for rendering. Associates a vertex declaration with a specific binding index in the graphics pipeline. The declaration defines how vertex data is interpreted and laid out in memory.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HVertexDeclaration vertex_declaration Vertex declaration handle
uint32_t binding_index Binding index to associate with this declaration
uint32_t base_offset Byte offset to add to all vertex attribute pointers
dmGraphics::HProgram program Shader program to use with this declaration

Finalize

void Finalize()

Finalizes the graphics system. Cleans up global graphics resources and shuts down the graphics system. This should be called when the application is exiting.

PARAMETERS


FindUniformLocation

dmGraphics::HUniformLocation FindUniformLocation(dmGraphics::HProgram program, dmhash_t name_hash)

Finds the location of a uniform variable in a shader program by name hash. Returns the uniform location that can be used with other uniform-setting functions. This is the preferred method when the uniform name is known at compile time as it avoids runtime string hashing.

PARAMETERS

dmGraphics::HProgram program Shader program handle
dmhash_t name_hash Hash of the uniform variable name

RETURNS

dmGraphics::HUniformLocation Uniform location handle, or INVALID_UNIFORM_LOCATION if not found

FindUniformLocation

dmGraphics::HUniformLocation FindUniformLocation(dmGraphics::HProgram program, const char* name)

Finds the location of a uniform variable in a shader program by name string. Returns the uniform location that can be used with other uniform-setting functions. This method is useful when the uniform name is only known at runtime.

PARAMETERS

dmGraphics::HProgram program Shader program handle
const char* name Name of the uniform variable

RETURNS

dmGraphics::HUniformLocation Uniform location handle, or INVALID_UNIFORM_LOCATION if not found

Flip

void Flip(dmGraphics::HContext context)

Flips screen buffers. Presents the rendered frame to the display. This should be called at the end of each frame after all rendering is complete.

PARAMETERS

dmGraphics::HContext context Graphics context

GetAdapterFamily

dmGraphics::AdapterFamily GetAdapterFamily(const char* adapter_name)

Gets the adapter family from a string name. Converts a string identifier to the corresponding AdapterFamily enum value.

PARAMETERS

const char* adapter_name String name of the adapter (e.g., "opengl", "vulkan")

RETURNS

dmGraphics::AdapterFamily Corresponding adapter family enum value

GetDisplayScaleFactor

float GetDisplayScaleFactor(dmGraphics::HContext context)

Get the scale factor of the display. The display scale factor is usally 1.0 but will for instance be 2.0 on a macOS Retina display.

PARAMETERS

dmGraphics::HContext context Graphics context

RETURNS

float Display scale factor

GetHeight

uint32_t GetHeight(dmGraphics::HContext context)

Returns the specified height of the opened window, which might differ from the actual window width.

PARAMETERS

dmGraphics::HContext context Graphics context

RETURNS

uint32_t Specified height of the window. If no window is opened, 0 is always returned.

GetInstalledAdapterFamily

dmGraphics::AdapterFamily GetInstalledAdapterFamily()

Get installed graphics adapter family

PARAMETERS

RETURNS

dmGraphics::AdapterFamily Installed adapter family

GetInstalledContext

dmGraphics::HContext GetInstalledContext()

PARAMETERS

RETURNS

dmGraphics::HContext Installed graphics context

GetMaxElementsIndices

uint32_t GetMaxElementsIndices(dmGraphics::HContext context)

Get the max number of indices allowed by the system in an index buffer

PARAMETERS

dmGraphics::HContext context the context

RETURNS

uint32_t the count

GetMaxElementsVertices

uint32_t GetMaxElementsVertices(dmGraphics::HContext context)

Get the max number of vertices allowed by the system in a vertex buffer

PARAMETERS

dmGraphics::HContext context the context

RETURNS

uint32_t the count

GetMaxTextureSize

uint32_t GetMaxTextureSize(dmGraphics::HContext context)

Get maximum supported size in pixels of non-array texture

PARAMETERS

dmGraphics::HContext context Graphics context

RETURNS

uint32_t Maximum texture size supported by GPU

GetNumSupportedExtensions

uint32_t GetNumSupportedExtensions(dmGraphics::HContext context)

PARAMETERS

dmGraphics::HContext context the context

RETURNS

uint32_t the number of supported extensions

GetNumTextureHandles

uint8_t GetNumTextureHandles(dmGraphics::Context context, dmGraphics::HTexture texture)

Get how many platform-dependent texture handle used for engine texture handle. Applicable only for OpenGL/ES backend. All other backends return 1.

PARAMETERS

dmGraphics::Context context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

uint8_t Platform-dependent handles amount

GetOriginalTextureHeight

uint16_t GetOriginalTextureHeight(dmGraphics::HContext context, dmGraphics::HTexture texture)

Get texture original (before uploading to GPU) height

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

uint16_t

GetOriginalTextureWidth

uin16_t GetOriginalTextureWidth(dmGraphics::HContext context, dmGraphics::HTexture texture)

Get texture original (before uploading to GPU) width

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

uin16_t Texture's original width

GetPipelineState

dmGraphics::PipelineState GetPipelineState(dmGraphics::HContext context)

PARAMETERS

dmGraphics::HContext context Graphics context

RETURNS

dmGraphics::PipelineState

GetRenderTargetAttachment

dmGraphics::HTexture GetRenderTargetAttachment(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, dmGraphics::RenderTargetAttachment attachment_type)

Get the attachment texture from a render target. Returns zero if no such attachment texture exists.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HRenderTarget render_target the render target
dmGraphics::RenderTargetAttachment attachment_type the attachment to get

RETURNS

dmGraphics::HTexture the attachment texture

GetRenderTargetSize

void GetRenderTargetSize(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, dmGraphics::BufferType buffer_type, uint32_t& width, uint32_t& height)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HRenderTarget render_target
dmGraphics::BufferType buffer_type
uint32_t& width
uint32_t& height

GetRenderTargetTexture

dmGraphics::HTexture GetRenderTargetTexture(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, dmGraphics::BufferType buffer_type)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HRenderTarget render_target
dmGraphics::BufferType buffer_type

RETURNS

dmGraphics::HTexture

GetSupportedExtension

const char* GetSupportedExtension(dmGraphics::HContext context, uint32_t index)

get the supported extension

PARAMETERS

dmGraphics::HContext context the context
uint32_t index the index of the extension

RETURNS

const char* the extension. 0 if index was out of bounds

GetTextureDepth

uint16_t GetTextureDepth(dmGraphics::HContext context, dmGraphics::HTexture texture)

Get texture depth. applicable for 3D and cube map textures

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

uint16_t Texture's depth

GetTextureFormatLiteral

const char* GetTextureFormatLiteral(dmGraphics::TextureFormat format)

Get string representation of texture format

PARAMETERS

dmGraphics::TextureFormat format Texture format

RETURNS

const char* String representation of format

GetTextureHandle

dmGraphics::HandleResult GetTextureHandle(dmGraphics::HTexture texture, void** out_handle)

Get the native graphics API texture object from an engine texture handle. This depends on the graphics backend and is not guaranteed to be implemented on the currently running adapter.

PARAMETERS

dmGraphics::HTexture texture the texture handle
void** out_handle a pointer to where the raw object should be stored

RETURNS

dmGraphics::HandleResult the result of the query

GetTextureHeight

uint16_t GetTextureHeight(dmGraphics::HContext context, dmGraphics::HTexture texture)

Get texture height

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

uint16_t Texture's height

GetTextureMipmapCount

uint8_t GetTextureMipmapCount(dmGraphice::HContext context, dmGraphics::HTexture texture)

Get texture mipmap count

PARAMETERS

dmGraphice::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

uint8_t Texture mipmap count

GetTextureResourceSize

uint32_t GetTextureResourceSize(dmGraphics::HContext context, dmGraphics::HTexture texture)

Get approximate size of how much memory texture consumes

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

uint32_t Resource data size in bytes

GetTextureStatusFlags

dmGraphics::TextureStatusFlags GetTextureStatusFlags(dmGraphics::HContext context, dmGraphics::HTexture texture)

Get status of texture

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

dmGraphics::TextureStatusFlags Enumerated status bit flags

GetTextureType

dmGraphics::TextureType GetTextureType(dmGraphics::HContext context, dmGraphics::HTexture texture)

Get texture type

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

dmGraphics::TextureType Texture type

GetTextureTypeLiteral

const char* GetTextureTypeLiteral(dmGraphics::TextureType texture_type)

Get string representation of texture type

PARAMETERS

dmGraphics::TextureType texture_type Texture type

RETURNS

const char* String representation of type

GetTextureUsageHintFlags

uint32_t GetTextureUsageHintFlags(dmGraphics::HContext context, dmGraphics::HTexture texture)

Query usage hint flags for a texture. Retrieves the bitwise usage flags that were assigned to a texture when it was created. These flags indicate the intended role(s) of the texture in the rendering pipeline and allow the graphics backend to apply optimizations or enforce restrictions

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

uint32_t A bitwise OR of usage flags describing how the texture may be used. Applications can test specific flags using bitmask operations

GetTextureWidth

uint16_t GetTextureWidth(dmGraphics::HContext context, dmGraphics::HTexture texture)

Get texture width

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle

RETURNS

uint16_t Texture's width

GetVertexStreamOffset

 GetVertexStreamOffset(dmGraphics::HVertexDeclaration vertex_declaration, dmhash_t name_hash)

Get the physical offset into the vertex data for a particular stream

PARAMETERS

dmGraphics::HVertexDeclaration vertex_declaration the vertex declaration
dmhash_t name_hash the name hash of the vertex stream (as passed into AddVertexStream())

RETURNS

in bytes into the vertex or INVALID_STREAM_OFFSET if not found

GetViewport

void GetViewport(dmGraphics::HContext context, int32_t x, int32_t y, uint32_t width, uint32_t height)

Get viewport's parameters

PARAMETERS

dmGraphics::HContext context the context
int32_t x x-coordinate of the viewport's origin
int32_t y y-coordinate of the viewport's origin
uint32_t width viewport's width
uint32_t height viewport's height

GetWidth

uint32_t GetWidth(dmGraphics::HContext context)

Returns the specified width of the opened window, which might differ from the actual window width.

PARAMETERS

dmGraphics::HContext context Graphics context

RETURNS

uint32_t Specified width of the window. If no window is opened, 0 is always returned.

GetWindowHeight

uint32_t GetWindowHeight(dmGraphics::HContext context)

Return the height of the opened window, if any.

PARAMETERS

dmGraphics::HContext context Graphics context

RETURNS

uint32_t Height of the window. If no window is opened, 0 is always returned

GetWindowWidth

uint32_t GetWindowWidth(dmGraphics::HContext context)

Return the width of the opened window, if any.

PARAMETERS

dmGraphics::HContext context Graphics context

RETURNS

uint32_t Width of the window. If no window is opened, 0 is always returned

InstallAdapter

bool InstallAdapter(dmGraphics::AdapterFamily family)

Installs a graphics adapter. Initializes the specified graphics backend (OpenGL, Vulkan, etc.). This must be called before creating any graphics context.

PARAMETERS

dmGraphics::AdapterFamily family Graphics adapter family to install

RETURNS

bool True if the adapter was successfully installed, false otherwise

IsExtensionSupported

bool IsExtensionSupported(dmGraphics::HContext context, const char* extension)

check if an extension is supported

PARAMETERS

dmGraphics::HContext context the context
const char* extension the extension.

RETURNS

bool true if the extension was supported

IsIndexBufferFormatSupported

void IsIndexBufferFormatSupported(dmGraphics::HContext context, dmGraphics::IndexBufferFormat format, bool result)

Check if the index format is supported

PARAMETERS

dmGraphics::HContext context the context
dmGraphics::IndexBufferFormat format the format
bool result true if the format is supoprted

IsTextureFormatSupported

bool IsTextureFormatSupported(dmGraphics::HContext context, dmGraphics::TextureFormat format)

check if a specific texture format is supported

PARAMETERS

dmGraphics::HContext context the context
dmGraphics::TextureFormat format the texture format.

RETURNS

bool true if the texture format was supported

NewContext

dmGraphics::HContext NewContext(const dmGraphics::ContextParams& params)

Creates a new graphics context. Initializes the graphics system with the specified parameters. Only one graphics context can be active at a time.

PARAMETERS

const dmGraphics::ContextParams& params Context creation parameters

RETURNS

dmGraphics::HContext New graphics context handle, or null on failure

NewIndexBuffer

dmGraphics::HIndexBuffer NewIndexBuffer(dmGraphics::HContext context, uint32_t size, void* data, dmGraphics::BufferUsage buffer_usage)

Create new index buffer with initial data

PARAMETERS

dmGraphics::HContext context the context
uint32_t size the size of the buffer (in bytes). May be 0
void* data the data
dmGraphics::BufferUsage buffer_usage the usage

RETURNS

dmGraphics::HIndexBuffer the index buffer

NewProgram

dmGraphics::HProgram NewProgram(dmGraphics::HContext context, dmGraphics::ShaderDesc* ddf, char* error_buffer, uint32_t error_buffer_size)

Creates a new shader program from a shader description. Compiles and links shader sources defined in the ShaderDesc into a GPU program. Returns a program handle that can be used for rendering.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::ShaderDesc* ddf Shader description containing source code and parameters
char* error_buffer Buffer to receive error messages (can be null)
uint32_t error_buffer_size Size of the error buffer

RETURNS

dmGraphics::HProgram New program handle, or INVALID_PROGRAM_HANDLE on failure

NewRenderTarget

dmGraphics::HRenderTarget NewRenderTarget(dmGraphics::HContext context, uint32_t buffer_type_flags, dmGraphics::const RenderTargetCreationParams params)

PARAMETERS

dmGraphics::HContext context Graphics context
uint32_t buffer_type_flags
dmGraphics::const RenderTargetCreationParams params

RETURNS

dmGraphics::HRenderTarget Newly created render target

NewTexture

dmGraphics::HTexture NewTexture(HContext context, const dmGraphics::TextureCreationParams& params)

Create new texture

PARAMETERS

HContext context Graphics context
const dmGraphics::TextureCreationParams& params Creation parameters

RETURNS

dmGraphics::HTexture Opaque texture handle

NewVertexBuffer

dmGraphics::HVertexBuffer NewVertexBuffer(dmGraphics::HContext context, uint32_t size, void* data, dmGraphics::BufferUsage buffer_usage)

Create new vertex buffer with initial data

PARAMETERS

dmGraphics::HContext context the context
uint32_t size the size of the buffer (in bytes). May be 0
void* data the data
dmGraphics::BufferUsage buffer_usage the usage

RETURNS

dmGraphics::HVertexBuffer the vertex buffer

NewVertexDeclaration

dmGraphics::HVertexDeclaration NewVertexDeclaration(dmGraphics::HContext context, dmGraphics::HVertexStreamDeclaration stream_declaration)

Create new vertex declaration from a vertex stream declaration

PARAMETERS

dmGraphics::HContext context the context
dmGraphics::HVertexStreamDeclaration stream_declaration the vertex stream declaration

RETURNS

dmGraphics::HVertexDeclaration the vertex declaration

NewVertexDeclaration

dmGraphics::HVertexDeclaration NewVertexDeclaration(dmGraphics::HContext context, dmGraphics::HVertexStreamDeclaration stream_declaration, uint32_t stride)

Create new vertex declaration from a vertex stream declaration and an explicit stride value, where the stride is the number of bytes between each consecutive vertex in a vertex buffer

PARAMETERS

dmGraphics::HContext context the context
dmGraphics::HVertexStreamDeclaration stream_declaration the vertex stream declaration
uint32_t stride the stride between the start of each vertex (in bytes)

RETURNS

dmGraphics::HVertexDeclaration the vertex declaration

NewVertexStreamDeclaration

dmGraphics::HVertexStreamDeclaration NewVertexStreamDeclaration(dmGraphics::HContext context)

Create new vertex stream declaration. A stream declaration contains a list of vertex streams that should be used to create a vertex declaration from.

PARAMETERS

dmGraphics::HContext context the context

RETURNS

dmGraphics::HVertexStreamDeclaration the vertex declaration

NewVertexStreamDeclaration

dmGraphics::HVertexStreamDeclaration NewVertexStreamDeclaration(dmGraphics::HContext context, dmGraphics::VertexStepFunction step_function)

Create new vertex stream declaration. A stream declaration contains a list of vertex streams that should be used to create a vertex declaration from.

PARAMETERS

dmGraphics::HContext context the context
dmGraphics::VertexStepFunction step_function the vertex step function to use

RETURNS

dmGraphics::HVertexStreamDeclaration the vertex declaration

ReadPixels

void ReadPixels(dmGraphics::HContext context, int32_t x, int32_t y, uint32_t width, uint32_t height, void* buffer, uint32_t buffer_size)

Read frame buffer pixels in BGRA format

PARAMETERS

dmGraphics::HContext context the context
int32_t x x-coordinate of the starting position
int32_t y y-coordinate of the starting position
uint32_t width width of the region
uint32_t height height of the region
void* buffer buffer to read to
uint32_t buffer_size buffer size

RepackRGBToRGBA

void RepackRGBToRGBA(uint32_t num_pixels, uint8_t* rgb, uint8_t* rgba)

PARAMETERS

uint32_t num_pixels
uint8_t* rgb
uint8_t* rgba

SetBlendFunc

void SetBlendFunc(dmGraphics::HContext context, gmGraphics::BlendFactor source_factor, dmGraphics::BlendFactor destination_factor)

PARAMETERS

dmGraphics::HContext context Graphics context
gmGraphics::BlendFactor source_factor
dmGraphics::BlendFactor destination_factor

SetColorMask

void SetColorMask(dmGraphics::HContext context, bool red, bool green, bool blue, bool alpha)

PARAMETERS

dmGraphics::HContext context Graphics context
bool red
bool green
bool blue
bool alpha

SetCullFace

void SetCullFace(dmGraphics::HContext context, dmGraphics::FaceType face_type)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::FaceType face_type

SetDepthFunc

void SetDepthFunc(dmGraphics::HContext context, dmGraphics::CompareFunc func)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::CompareFunc func

SetDepthMask

void SetDepthMask(dmGraphics::HContext context, bool enable_mask)

PARAMETERS

dmGraphics::HContext context Graphics context
bool enable_mask

SetIndexBufferData

void SetIndexBufferData(dmGraphics::HIndexBuffer buffer, uint32_t size, void* data, dmGraphics::BufferUsage buffer_usage)

Set index buffer data

PARAMETERS

dmGraphics::HIndexBuffer buffer the buffer
uint32_t size the size of the buffer (in bytes). May be 0
void* data the data
dmGraphics::BufferUsage buffer_usage the usage

SetIndexBufferSubData

void SetIndexBufferSubData(dmGraphics::HVertexBuffer buffer, uint32_t offset, uint32_t size, void* data)

Set subset of index buffer data

PARAMETERS

dmGraphics::HVertexBuffer buffer the buffer
uint32_t offset the offset into the desination buffer (in bytes)
uint32_t size the size of the buffer (in bytes). May be 0
void* data the data

SetRenderTarget

void SetRenderTarget(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, uint32_t transient_buffer_types)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HRenderTarget render_target
uint32_t transient_buffer_types

SetRenderTargetSize

void SetRenderTargetSize(dmGraphics::HContext context, dmGraphics::HRenderTarget render_target, uint32_t width, uint32_t height)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HRenderTarget render_target
uint32_t width
uint32_t height

SetSampler

void SetSampler(dmGraphics::HContext context, dmGraphics::HUniformLocation location, int32_t unit)

Binds a texture sampler to a texture unit. Associates a texture with a specific sampler uniform in the shader, allowing the shader to access the texture data during rendering.

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HUniformLocation location Uniform location of the sampler
int32_t unit Texture unit index to bind to

SetStencilFunc

void SetStencilFunc(dmGraphics::HContext context, dmGraphics::CompareFunc func, uint32_t ref, uint32_t mask)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::CompareFunc func
uint32_t ref
uint32_t mask

SetStencilFuncSeparate

void SetStencilFuncSeparate(dmGraphics::HContext context, dmGraphics::FaceType face_type, dmGraphics::CompareFunc func, uint32_t ref, uint32_t mask)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::FaceType face_type
dmGraphics::CompareFunc func
uint32_t ref
uint32_t mask

SetStencilMask

void SetStencilMask(dmGraphics::HContext context, uint32_t mask)

PARAMETERS

dmGraphics::HContext context Graphics context
uint32_t mask

SetStencilOp

void SetStencilOp(dmGraphics::HContext context, dmGraphics::StencilOp sfail, dmGraphics::StencilOp dpfail, dmGraphics::StencilOp dppass)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::StencilOp sfail
dmGraphics::StencilOp dpfail
dmGraphics::StencilOp dppass

SetStencilOpSeparate

void SetStencilOpSeparate(dmGraphics::HContext context, dmGraphics::FaceType face_type, dmGraphics::StencilOp sfail, dmGraphics::StencilOp dpfail, dmGraphics::StencilOp dppass)

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::FaceType face_type
dmGraphics::StencilOp sfail
dmGraphics::StencilOp dpfail
dmGraphics::StencilOp dppass

SetTexture

void SetTexture(dmGraphics::HContext context, dmGraphics::HTexture texture, const dmGraphics::TextureParams& params)

Set texture data. For textures of type TEXTURE_TYPE_CUBE_MAP it's assumed that 6 mip-maps are present contiguously in memory with stride m_DataSize

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle
const dmGraphics::TextureParams& params

SetTextureAsync

void SetTextureAsync(dmGraphics::HContext context, dmGraphics::HTexture texture, const dmGraphics::TextureParams& params, dmGraphics::SetTextureAsyncCallback callback, void* user_data)

Set texture data asynchronously. For textures of type TEXTURE_TYPE_CUBE_MAP it's assumed that 6 mip-maps are present contiguously in memory with stride m_DataSize

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle
const dmGraphics::TextureParams& params Texture parameters. Texture will be recreated if parameters differ from creation parameters
dmGraphics::SetTextureAsyncCallback callback Completion callback
void* user_data User data that will be passed to completion callback

SetTextureParams

void SetTextureParams(dmGraphics::HContext context, dmGraphics::HTexture texture, dmGraphics::TextureFilter min_filter, dmGraphics::TextureFilter mag_filter, dmGraphics::TextureWrap uwrap, dmGraphics::TextureWrap vwrap, float max_anisotropy)

Set texture parameters

PARAMETERS

dmGraphics::HContext context Graphics context
dmGraphics::HTexture texture Texture handle
dmGraphics::TextureFilter min_filter Minification filter type
dmGraphics::TextureFilter mag_filter Magnification filter type
dmGraphics::TextureWrap uwrap Wrapping mode for the U (X) texture coordinate.
dmGraphics::TextureWrap vwrap Wrapping mode for the V (Y) texture coordinate
float max_anisotropy

SetVertexBufferData

void SetVertexBufferData(dmGraphics::HVertexBuffer buffer, uint32_t size, void* data, dmGraphics::BufferUsage buffer_usage)

Set vertex buffer data

PARAMETERS

dmGraphics::HVertexBuffer buffer the buffer
uint32_t size the size of the buffer (in bytes). May be 0
void* data the data
dmGraphics::BufferUsage buffer_usage the usage

SetVertexBufferSubData

void SetVertexBufferSubData(dmGraphics::HVertexBuffer buffer, uint32_t offset, uint32_t size, void* data)

Set subset of vertex buffer data

PARAMETERS

dmGraphics::HVertexBuffer buffer the buffer
uint32_t offset the offset into the desination buffer (in bytes)
uint32_t size the size of the buffer (in bytes). May be 0
void* data the data

SetViewport

void SetViewport(dmGraphics::HContext context, int32_t x, int32_t y, int32_t width, int32_t height)

Sets the viewport for rendering. Defines the affine transformation from normalized device coordinates to window coordinates. This affects all subsequent rendering operations.

PARAMETERS

dmGraphics::HContext context Graphics context
int32_t x X coordinate of the viewport's origin (in pixels)
int32_t y Y coordinate of the viewport's origin (in pixels)
int32_t width Width of the viewport (in pixels)
int32_t height Height of the viewport (in pixels)

Structs

ContextParams

TYPE

struct ContextParams

Graphics context creation parameters. Defines the configuration for creating a new graphics context. This structure is used when initializing the graphics system and specifies window association, job system context, texture filtering defaults, resolution, memory limits, and various debugging/validation options.

MEMBERS

dmPlatform::HWindow m_Window Platform window handle to associate with the graphics context
dmJobSystem::HJobContext m_JobContext Job system context for asynchronous operations
dmGraphics::TextureFilter m_DefaultTextureMinFilter Default minification filter for textures
dmGraphics::TextureFilter m_DefaultTextureMagFilter Default magnification filter for textures
uint32_t m_Width Initial width of the rendering surface
uint32_t m_Height Initial height of the rendering surface
uint32_t m_GraphicsMemorySize Maximum allowed graphics memory in bytes (0 for default/unlimited) (Switch)
uint32_t m_SwapInterval Vertical synchronization interval (1 for 60Hz, 2 for 30Hz, etc.) (Default = 1)
bool m_VerifyGraphicsCalls Enable API call verification for debugging
bool m_PrintDeviceInfo Print graphics device information at startup
bool m_UseValidationLayers Enable validation layers for debugging (Vulkan/DirectX 12 only)


ShaderDesc

TYPE

struct ShaderDesc

Shader program description (from graphics_ddf.h)


TextureCreationParams

TYPE

struct TextureCreationParams

Texture creation parameters. Defines how a texture is created, initialized, and used. This structure is typically passed when allocating GPU memory for a new texture. It controls dimensions, format, layering, mipmapping, and intended usage.

MEMBERS

dmGraphics::TextureType m_Type Texture type. Defines the dimensionality and interpretation of the texture (2D, 3D, cube map, array)
uint16_t m_Width Width of the texture in pixels at the base mip level
uint16_t m_Height Height of the texture in pixels at the base mip level
uint16_t m_Depth Depth of the texture. Used for 3D textures or texture arrays. For standard 2D textures, this is typically `1`
uint16_t m_OriginalWidth Width of the original source data before scaling or compression
uint16_t m_OriginalHeight Height of the original source data before scaling or compression
uint16_t m_OriginalDepth Depth of the original source data
uint8_t m_LayerCount Number of layers in the texture. Used for array textures (`TEXTURE_TYPE_2D_ARRAY`). For standard 2D textures, this is `1`
uint8_t m_MipMapCount Number of mipmap levels. A value of `1` means no mipmaps (only the base level is stored). Larger values allow for mipmapped sampling.
uint8_t m_UsageHintBits Bitfield of usage hints. Indicates how the texture will be used (e.g. sampling, render target, storage image). See dmGraphics::TextureUsageFlag


TextureParams

TYPE

struct TextureParams

Texture update parameters. Defines a block of pixel data to be uploaded to a texture, along with filtering, wrapping, and sub-region update options. Typically used when calling texture upload/update functions after a texture object has been created with TextureCreationParams

MEMBERS

const void* m_Data Pointer to raw pixel data in CPU memory. The format is defined by `m_Format`
uint32_t m_DataSize Size of the pixel data in bytes. Must match the expected size from width, height, depth, and format
dmGraphics::TextureFormat m_Format Format of the pixel data (e.g. RGBA, RGB, compressed formats). Dictates how the GPU interprets the memory pointed by `m_Data`
dmGraphics::TextureFilter m_MinFilter Minification filter (applied when shrinking). Determines how pixels are sampled when the texture is displayed smaller than its native resolution
dmGraphics::TextureFilter m_MagFilter Magnification filter (applied when enlarging). Determines how pixels are sampled when the texture is displayed larger than its native resolution
dmGraphics::TextureWrap m_UWrap Wrapping mode for U (X) texture coordinate. Controls behavior when texture coordinates exceed [0,1]
dmGraphics::TextureWrap m_VWrap Wrapping mode for V (Y) texture coordinate. Controls behavior when texture coordinates exceed [0,1]
uint32_t m_X X offset in pixels for sub-texture updates. Defines the left edge of the destination region
uint32_t m_Y Y offset in pixels for sub-texture updates. Defines the top edge of the destination region
uint32_t m_Z Z offset (depth layer) for 3D textures. Ignored for standard 2D textures
uint32_t m_Slice Slice index in an array texture where the data should be uploaded
uint16_t m_Width Width of the pixel data block in pixels. Used for both full uploads and sub-updates
uint16_t m_Height Height of the pixel data block in pixels. Used for both full uploads and sub-updates
uint16_t m_Depth Depth of the pixel data block in pixels. Only relevant for 3D textures
uint8_t m_LayerCount Number of layers to update. For array textures, this specifies how many pages are updated
uint8_t m_MipMap Only 7 bit available Mipmap level to update. Level 0 is the base level, higher levels are progressively downscaled versions
uint8_t m_SubUpdate If true, this represents a partial texture update (sub-region), using `m_X`, `m_Y`, `m_Z`, and `m_Slice` offsets. If false, the entire texture/mipmap level is replaced


Constants

INVALID_PROGRAM_HANDLE

Invalid program handle constant. Used to represent an uninitialized or invalid program handle. Can be used to check if program creation or loading failed.


INVALID_STREAM_OFFSET

Invalid stream offset


INVALID_UNIFORM_LOCATION

Invalid uniform location constant. Used to represent an uninitialized or invalid uniform location. Can be used to check if uniform location lookup failed.


MAX_BUFFER_COLOR_ATTACHMENTS

Max buffer color attachments


Types

HContext

void HContext()

Context handle

PARAMETERS



HIndexBuffer

void HIndexBuffer()

Index buffer handle

PARAMETERS



HProgram

void HProgram()

Program handle

PARAMETERS



HRenderTarget

void HRenderTarget()

Rendertarget handle

PARAMETERS



HStorageBuffer

void HStorageBuffer()

Storage buffer handle

PARAMETERS



HTexture

void HTexture()

Texture handle

PARAMETERS



HUniformLocation

void HUniformLocation()

Uniform location handle

PARAMETERS



HVertexBuffer

void HVertexBuffer()

Vertex buffer handle

PARAMETERS



HVertexDeclaration

void HVertexDeclaration()

Vertex declaration handle

PARAMETERS



HVertexStreamDeclaration

void HVertexStreamDeclaration()

Vertex stream declaration handle

PARAMETERS



SetTextureAsyncCallback

void SetTextureAsyncCallback(dmGraphics::HTexture texture, void* user_data)

Function called when a texture has been set asynchronously

PARAMETERS

dmGraphics::HTexture texture Texture handle
void* user_data User data that will be passed to the SetTextureAsyncCallback


Enums

AdapterFamily

Graphics adapter family. Identifies the type of graphics backend used by the rendering system

ADAPTER_FAMILY_NONE No adapter detected. Used as an error state or uninitialized value
ADAPTER_FAMILY_NULL Null (dummy) backend. Used for headless operation, testing, or environments where rendering output is not required
ADAPTER_FAMILY_OPENGL OpenGL desktop backend. Common on Windows, macOS and Linux systems
ADAPTER_FAMILY_OPENGLES OpenGL ES backend. Primarily used on mobile devices (Android, iOS), as well as WebGL (browser)
ADAPTER_FAMILY_VULKAN Vulkan backend. Cross-platform modern graphics API with explicit control over GPU resources and multithreading
ADAPTER_FAMILY_VENDOR Vendor-specific backend. A placeholder for proprietary or experimental APIs tied to a particular GPU vendor.
ADAPTER_FAMILY_WEBGPU WebGPU backend. Modern web graphics API designed as the successor to WebGL
ADAPTER_FAMILY_DIRECTX DirectX backend. Microsoft’s graphics API used on Windows and Xbox

AttachmentOp

Defines how an attachment should be treated at the start and end of a render pass

ATTACHMENT_OP_DONT_CARE Ignore existing content, no guarantees about the result
ATTACHMENT_OP_LOAD Preserve the existing contents of the attachment
ATTACHMENT_OP_STORE Store the attachment’s results after the pass finishes
ATTACHMENT_OP_CLEAR Clear the attachment to a predefined value at the beginning of the pass

BlendFactor

Blend factors for color blending. Defines how source and destination colors are combined

BLEND_FACTOR_ZERO Always use 0.0
BLEND_FACTOR_ONE Always use 1.0
BLEND_FACTOR_SRC_COLOR Use source color
BLEND_FACTOR_ONE_MINUS_SRC_COLOR Use (1 - source color)
BLEND_FACTOR_DST_COLOR Use destination color
BLEND_FACTOR_ONE_MINUS_DST_COLOR Use (1 - destination color)
BLEND_FACTOR_SRC_ALPHA Use source alpha
BLEND_FACTOR_ONE_MINUS_SRC_ALPHA Use (1 - source alpha)
BLEND_FACTOR_DST_ALPHA Use destination alpha
BLEND_FACTOR_ONE_MINUS_DST_ALPHA Use (1 - destination alpha)
BLEND_FACTOR_SRC_ALPHA_SATURATE Use min(srcAlpha, 1 - dstAlpha)
BLEND_FACTOR_CONSTANT_COLOR
BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
BLEND_FACTOR_CONSTANT_ALPHA
BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA

BufferAccess

BUFFER_ACCESS_READ_ONLY
BUFFER_ACCESS_WRITE_ONLY
BUFFER_ACCESS_READ_WRITE

BufferUsage

Buffer usage hints. Indicates how often the data in a buffer will be updated. Helps the driver optimize memory placement

BUFFER_USAGE_STREAM_DRAW Updated every frame, used once (e.g. dynamic geometry)
BUFFER_USAGE_DYNAMIC_DRAW Updated occasionally, used many times
BUFFER_USAGE_STATIC_DRAW Set once, used many times (e.g. meshes, textures). Preferred for buffers that never change

CompareFunc

Depth and alpha test comparison functions. Defines how incoming values are compared against stored ones

COMPARE_FUNC_NEVER Never passes.
COMPARE_FUNC_LESS Passes if incoming < stored
COMPARE_FUNC_LEQUAL Passes if incoming <= stored
COMPARE_FUNC_GREATER Passes if incoming > stored
COMPARE_FUNC_GEQUAL Passes if incoming >= stored
COMPARE_FUNC_EQUAL Passes if incoming == stored
COMPARE_FUNC_NOTEQUAL Passes if incoming != stored
COMPARE_FUNC_ALWAYS Always passes (ignores stored values)

FaceWinding

FACE_WINDING_CCW
FACE_WINDING_CW

HandleResult

Function's call result code

HANDLE_RESULT_OK The function's call succeeded and returned a valid result
HANDLE_RESULT_NOT_AVAILABLE The function is not supported by the current graphics backend
HANDLE_RESULT_ERROR An error occurred while function call

IndexBufferFormat

Index buffer element types. Defines the integer size used for vertex indices

INDEXBUFFER_FORMAT_16 16-bit unsigned integers (max 65535 vertices)
INDEXBUFFER_FORMAT_32 32-bit unsigned integers (supports larger meshes)

PrimitiveType

Primitive drawing modes. Defines how vertex data is assembled into primitives

PRIMITIVE_LINES Each pair of vertices forms a line
PRIMITIVE_TRIANGLES Each group of 3 vertices forms a triangle
PRIMITIVE_TRIANGLE_STRIP Connected strip of triangles (shares vertices)

RenderTargetAttachment

Attachment points for render targets

ATTACHMENT_COLOR A color buffer attachment (used for rendering visible output)
ATTACHMENT_DEPTH A depth buffer attachment (used for depth testing)
ATTACHMENT_STENCIL A stencil buffer attachment (used for stencil operations)

StencilOp

Stencil test actions. Defines what happens to a stencil buffer value depending on the outcome of the stencil/depth test.

STENCIL_OP_KEEP Keep the current stencil value
STENCIL_OP_ZERO Set stencil value to 0
STENCIL_OP_REPLACE Replace stencil value with reference value
STENCIL_OP_INCR Increment stencil value (clamps at max)
STENCIL_OP_INCR_WRAP Increment stencil value, wrapping around
STENCIL_OP_DECR Decrement stencil value (clamps at 0)
STENCIL_OP_DECR_WRAP Decrement stencil value, wrapping around
STENCIL_OP_INVERT Bitwise invert stencil value

TextureFilter

Texture filtering modes. Controls how texels are sampled when scaling or rotating textures

TEXTURE_FILTER_DEFAULT Default texture filtering mode. Depeneds on graphics backend (for example, for OpenGL - TEXTURE_FILTER_LINEAR)
TEXTURE_FILTER_NEAREST Nearest-neighbor sampling (blocky look, fastest)
TEXTURE_FILTER_LINEAR Linear interpolation between texels (smooth look)
TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST Nearest mipmap level, nearest texel
TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR Linear blend between two mipmap levels, nearest texel
TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST Nearest mipmap level, linear texel
TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR Linear blend between mipmap levels and texels (trilinear)

TextureFormat

Pixel formats supported by textures. Includes uncompressed, compressed, and floating-point variants

TEXTURE_FORMAT_LUMINANCE Single-channel grayscale
TEXTURE_FORMAT_LUMINANCE_ALPHA Two-channel grayscale + alpha
TEXTURE_FORMAT_RGB Standard 24-bit RGB color
TEXTURE_FORMAT_RGBA Standard 32-bit RGBA color
TEXTURE_FORMAT_RGB_16BPP Packed 16-bit RGB (lower precision, saves memory)
TEXTURE_FORMAT_RGBA_16BPP Packed 16-bit RGBA
TEXTURE_FORMAT_DEPTH Depth buffer texture (used for depth testing)
TEXTURE_FORMAT_STENCIL Stencil buffer texture
TEXTURE_FORMAT_RGB_PVRTC_2BPPV1 PVRTC compressed RGB at 2 bits per pixel
TEXTURE_FORMAT_RGB_PVRTC_4BPPV1 PVRTC compressed RGB at 4 bits per pixel
TEXTURE_FORMAT_RGBA_PVRTC_2BPPV1 PVRTC compressed RGBA at 2 bits per pixel
TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1 PVRTC compressed RGBA at 4 bits per pixel
TEXTURE_FORMAT_RGB_ETC1 ETC1 compressed RGB (no alpha support)
TEXTURE_FORMAT_R_ETC2 ETC2 single-channel
TEXTURE_FORMAT_RG_ETC2 ETC2 two-channel
TEXTURE_FORMAT_RGBA_ETC2 ETC2 four-channel (with alpha)
TEXTURE_FORMAT_RGBA_ASTC_4X4 ASTC block-compressed 4×4
TEXTURE_FORMAT_RGB_BC1 BC1/DXT1 compressed RGB
TEXTURE_FORMAT_RGBA_BC3 BC3/DXT5 compressed RGBA
TEXTURE_FORMAT_R_BC4 BC4 single-channel
TEXTURE_FORMAT_RG_BC5 BC5 two-channel
TEXTURE_FORMAT_RGBA_BC7 BC7 high-quality compressed RGBA
TEXTURE_FORMAT_RGB16F Half-precision float RGB
TEXTURE_FORMAT_RGB32F Full 32-bit float RGB
TEXTURE_FORMAT_RGBA16F Half-precision float RGBA
TEXTURE_FORMAT_RGBA32F Full 32-bit float RGBA
TEXTURE_FORMAT_R16F Half-precision float single channel
TEXTURE_FORMAT_RG16F Half-precision float two channels
TEXTURE_FORMAT_R32F Full 32-bit float single channel
TEXTURE_FORMAT_RG32F Full 32-bit float two channels
TEXTURE_FORMAT_RGBA32UI Internal: 32-bit unsigned integer RGBA (not script-exposed)
TEXTURE_FORMAT_BGRA8U Internal: 32-bit BGRA layout
TEXTURE_FORMAT_R32UI Internal: 32-bit unsigned integer single channel
TEXTURE_FORMAT_RGBA_ASTC_5X4 ASTC 5x4 block compression
TEXTURE_FORMAT_RGBA_ASTC_5X5 ASTC 5x5 block compression
TEXTURE_FORMAT_RGBA_ASTC_6X5 ASTC 6x5 block compression
TEXTURE_FORMAT_RGBA_ASTC_6X6 ASTC 6x6 block compression
TEXTURE_FORMAT_RGBA_ASTC_8X5 ASTC 8x5 block compression
TEXTURE_FORMAT_RGBA_ASTC_8X6 ASTC 8x6 block compression
TEXTURE_FORMAT_RGBA_ASTC_8X8 ASTC 8x8 block compression
TEXTURE_FORMAT_RGBA_ASTC_10X5 ASTC 10x5 block compression
TEXTURE_FORMAT_RGBA_ASTC_10X6 ASTC 10x6 block compression
TEXTURE_FORMAT_RGBA_ASTC_10X8 ASTC 10x8 block compression
TEXTURE_FORMAT_RGBA_ASTC_10X10 ASTC 10x10 block compression
TEXTURE_FORMAT_RGBA_ASTC_12X10 ASTC 12x10 block compression
TEXTURE_FORMAT_RGBA_ASTC_12X12 ASTC 12x12 block compression

TextureStatusFlags

Texture data upload status flags

TEXTURE_STATUS_OK Texture updated and ready-to-use
TEXTURE_STATUS_DATA_PENDING Data upload to the texture is in progress

TextureType

Texture types

TEXTURE_TYPE_2D
TEXTURE_TYPE_2D_ARRAY
TEXTURE_TYPE_3D
TEXTURE_TYPE_CUBE_MAP
TEXTURE_TYPE_IMAGE_2D
TEXTURE_TYPE_IMAGE_3D
TEXTURE_TYPE_SAMPLER
TEXTURE_TYPE_TEXTURE_2D
TEXTURE_TYPE_TEXTURE_2D_ARRAY
TEXTURE_TYPE_TEXTURE_3D
TEXTURE_TYPE_TEXTURE_CUBE

TextureWrap

Texture addressing/wrapping modes. Controls behavior when texture coordinates fall outside the [0,1] range

TEXTURE_WRAP_CLAMP_TO_BORDER Clamp to the color defined as 'border'
TEXTURE_WRAP_CLAMP_TO_EDGE Clamp to the edge pixel of the texture
TEXTURE_WRAP_MIRRORED_REPEAT Repeat texture, mirroring every other repetition
TEXTURE_WRAP_REPEAT Repeat texture in a tiled fashion

Type

Data type. Represents scalar, vector, matrix, image, or sampler types used for vertex attributes, uniforms, and shader interface definitions

TYPE_BYTE Signed 8-bit integer. Compact storage, often used for colors, normals, or compressed vertex attributes
TYPE_UNSIGNED_BYTE Unsigned 8-bit integer. Common for color channels (0–255) or normalized texture data
TYPE_SHORT Signed 16-bit integer. Used for medium-range numeric attributes such as bone weights or coordinates with normalization
TYPE_UNSIGNED_SHORT Unsigned 16-bit integer. Often used for indices or normalized attributes when extra precision over bytes is required
TYPE_INT Signed 32-bit integer. Typically used for uniform values, shader constants, or counters
TYPE_UNSIGNED_INT Unsigned 32-bit integer. Used for indices, IDs, or GPU counters
TYPE_FLOAT 32-bit floating point. Standard for most vertex attributes and uniform values (positions, UVs, weights)
TYPE_FLOAT_VEC4 4-component floating-point vector (`vec4` in GLSL). Typically used for homogeneous coordinates, colors (RGBA), or combined attributes
TYPE_FLOAT_MAT4 4x4 floating-point matrix (`mat4` in GLSL). Standard for 3D transformations (model, view, projection)
TYPE_SAMPLER_2D 2D texture sampler. Standard type for most texture lookups
TYPE_SAMPLER_CUBE Cube map sampler. Used for environment mapping, reflections, and skyboxes
TYPE_SAMPLER_2D_ARRAY Array of 2D texture samplers. Enables efficient texture indexing when using multiple layers (e.g. terrain textures, sprite atlases)
TYPE_FLOAT_VEC2 2-component floating-point vector (`vec2` in GLSL). Commonly used for texture coordinates or 2D positions
TYPE_FLOAT_VEC3 3-component floating-point vector (`vec3` in GLSL). Used for positions, normals, and directions in 3D space
TYPE_FLOAT_MAT2 2x2 floating-point matrix (`mat2` in GLSL). Used in transformations (e.g. 2D rotations, scaling)
TYPE_FLOAT_MAT3 3x3 floating-point matrix (`mat3` in GLSL). Commonly used for normal matrix calculations in lighting
TYPE_IMAGE_2D 2D image object. Unlike samplers, images allow read/write access in shaders (e.g. compute shaders or image load/store operations)
TYPE_TEXTURE_2D 2D texture object handle. Represents an actual GPU texture resource
TYPE_SAMPLER Generic sampler handle, used as a placeholder for texture units without specifying the dimension
TYPE_TEXTURE_2D_ARRAY 2D texture array object handle
TYPE_TEXTURE_CUBE Cube map texture object handle
TYPE_SAMPLER_3D 3D texture sampler. Used for volumetric effects, noise fields, or voxel data
TYPE_TEXTURE_3D 3D texture object handle
TYPE_IMAGE_3D 3D image object. Used for compute-based volume processing
TYPE_SAMPLER_3D_ARRAY Array of 3D texture samplers
TYPE_TEXTURE_3D_ARRAY 3D texture array object handle