Namespace: dmGraphics
Language: C++
Type: Defold C++
File: graphics.h
Source: engine/graphics/src/dmsdk/graphics/graphics.h
Include: dmsdk/graphics/graphics.h
Graphics API
Type: ENUM Graphics adapter family. Identifies the type of graphics backend used by the rendering system
Members
ADAPTER_FAMILY_NONE - No adapter detected. Used as an error state or uninitialized valueADAPTER_FAMILY_NULL - Null (dummy) backend. Used for headless operation, testing, or environments where rendering output is not requiredADAPTER_FAMILY_OPENGL - OpenGL desktop backend. Common on Windows, macOS and Linux systemsADAPTER_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 multithreadingADAPTER_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 WebGLADAPTER_FAMILY_DIRECTX - DirectX backend. Microsoft’s graphics API used on Windows and XboxType: FUNCTION Adds a stream to a vertex stream declaration
Parameters
name (const char*) - the name of the streamsize (uint32_t) - the size of the stream, i.e number of componentstype (dmGraphics::Type) - the data type of the streamnormalize (bool) - true if the stream should be normalized in the 0..1 rangeType: FUNCTION Adds a stream to a vertex stream declaration
Parameters
name_hash (dmhash_t) - the name hash of the streamsize (uint32_t) - the size of the stream, i.e number of componentstype (dmGraphics::Type) - the data type of the streamnormalize (bool) - true if the stream should be normalized in the 0..1 rangeType: ENUM Defines how an attachment should be treated at the start and end of a render pass
Members
ATTACHMENT_OP_DONT_CARE - Ignore existing content, no guarantees about the resultATTACHMENT_OP_LOAD - Preserve the existing contents of the attachmentATTACHMENT_OP_STORE - Store the attachment’s results after the pass finishesATTACHMENT_OP_CLEAR - Clear the attachment to a predefined value at the beginning of the passType: FUNCTION Begins frame rendering. Prepares the graphics context for rendering a new frame. This should be called at the start of each frame.
Parameters
context (dmGraphics::HContext) - Graphics contextType: ENUM Blend factors for color blending. Defines how source and destination colors are combined
Members
BLEND_FACTOR_ZERO - Always use 0.0BLEND_FACTOR_ONE - Always use 1.0BLEND_FACTOR_SRC_COLOR - Use source colorBLEND_FACTOR_ONE_MINUS_SRC_COLOR - Use (1 - source color)BLEND_FACTOR_DST_COLOR - Use destination colorBLEND_FACTOR_ONE_MINUS_DST_COLOR - Use (1 - destination color)BLEND_FACTOR_SRC_ALPHA - Use source alphaBLEND_FACTOR_ONE_MINUS_SRC_ALPHA - Use (1 - source alpha)BLEND_FACTOR_DST_ALPHA - Use destination alphaBLEND_FACTOR_ONE_MINUS_DST_ALPHA - Use (1 - destination alpha)BLEND_FACTOR_SRC_ALPHA_SATURATE - Use min(srcAlpha, 1 - dstAlpha)BLEND_FACTOR_CONSTANT_COLORBLEND_FACTOR_ONE_MINUS_CONSTANT_COLORBLEND_FACTOR_CONSTANT_ALPHABLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHAType: ENUM
Members
BUFFER_ACCESS_READ_ONLYBUFFER_ACCESS_WRITE_ONLYBUFFER_ACCESS_READ_WRITEType: ENUM Buffer usage hints. Indicates how often the data in a buffer will be updated. Helps the driver optimize memory placement
Members
BUFFER_USAGE_STREAM_DRAW - Updated every frame, used once (e.g. dynamic geometry)BUFFER_USAGE_DYNAMIC_DRAW - Updated occasionally, used many timesBUFFER_USAGE_STATIC_DRAW - Set once, used many times (e.g. meshes, textures). Preferred for buffers that never changeType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextflags (uint32t) - Bitmask specifying which buffers to clear (BUFFER_TYPE*)red (uint8_t) - Red component value (0-255)green (uint8_t) - Green component value (0-255)blue (uint8_t) - Blue component value (0-255)alpha (uint8_t) - Alpha component value (0-255)depth (float) - Depth value to clear depth buffer tostencil (uint32_t) - Stencil value to clear stencil buffer toType: FUNCTION Closes the window associated with the graphics context. If a window is open, this will close it and clean up associated resources.
Parameters
context (dmGraphics::HContext) - Graphics contextType: ENUM Depth and alpha test comparison functions. Defines how incoming values are compared against stored ones
Members
COMPARE_FUNC_NEVER - Never passes.COMPARE_FUNC_LESS - Passes if incoming < storedCOMPARE_FUNC_LEQUAL - Passes if incoming <= storedCOMPARE_FUNC_GREATER - Passes if incoming > storedCOMPARE_FUNC_GEQUAL - Passes if incoming >= storedCOMPARE_FUNC_EQUAL - Passes if incoming == storedCOMPARE_FUNC_NOTEQUAL - Passes if incoming != storedCOMPARE_FUNC_ALWAYS - Always passes (ignores stored values)Type: STRUCT 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
m_Window (dmPlatform::HWindow) - Platform window handle to associate with the graphics contextm_JobContext (dmJobSystem::HJobContext) - Job system context for asynchronous operationsm_DefaultTextureMinFilter (dmGraphics::TextureFilter) - Default minification filter for texturesm_DefaultTextureMagFilter (dmGraphics::TextureFilter) - Default magnification filter for texturesm_Width (uint32_t) - Initial width of the rendering surfacem_Height (uint32_t) - Initial height of the rendering surfacem_GraphicsMemorySize (uint32_t) - Maximum allowed graphics memory in bytes (0 for default/unlimited) (Switch)m_SwapInterval (uint32_t) - Vertical synchronization interval (1 for 60Hz, 2 for 30Hz, etc.) (Default = 1)m_GraphicsApiVersionMajorHint (uint16_t) - Requested graphics API major version hint. A value of 0 lets the platform use its default.m_GraphicsApiVersionMinorHint (uint16_t) - Requested graphics API minor version hint.m_VerifyGraphicsCalls (bool) - Enable API call verification for debuggingm_PrintDeviceInfo (bool) - Print graphics device information at startupm_UseValidationLayers (bool) - Enable validation layers for debugging (Vulkan/DirectX 12 only)Type: FUNCTION Destroys a graphics context. Cleans up all resources associated with the graphics context. The context becomes invalid after this call.
Parameters
context (dmGraphics::HContext) - Graphics context to destroyType: FUNCTION Delete the index buffer
Parameters
buffer (dmGraphics::HIndexBuffer) - the index bufferType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextprogram (dmGraphics::HProgram) - Program handle to destroyType: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextrender_target (dmGraphics::HRenderTarget)Type: FUNCTION Delete texture
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleType: FUNCTION Delete vertex buffer
Parameters
buffer (dmGraphics::HVertexBuffer) - the bufferType: FUNCTION Delete vertex declaration
Parameters
vertex_declaration (dmGraphics::HVertexDeclaration) - the vertex declarationType: FUNCTION Delete vertex stream declaration
Parameters
stream_declaration (dmGraphics::HVertexStreamDeclaration) - the vertex stream declarationType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextType: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextstate (dmGraphics::State) - Render stateType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextunit (uint32_t) - Texture unit index to disable. Must match the one previously used in dmGraphics::EnableTexturetexture (dmGraphics::HTexture) - Handle to the texture object to disableType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextvertex_buffer (dmGraphics::HVertexBuffer) - Vertex buffer handle to unbindType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextvertex_declaration (dmGraphics::HVertexDeclaration) - Vertex declaration handle to unbindType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextprim_type (dmGraphics::PrimitiveType) - Type of primitives to drawfirst (uint32_t) - Index of the first vertex to drawcount (uint32_t) - Number of vertices to drawinstance_count (uint32_t) - Number of instances to draw (for instanced rendering)Type: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextprogram (dmGraphics::HProgram) - Program handle to activateType: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextstate (dmGraphics::State) - Render stateType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextunit (uint32_t) - Texture unit index to bind the texture to. Valid range depends on GPU capabilities (commonly 0–15 for at least 16 texture units)id_index (uint8_t) - 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)texture (dmGraphics::HTexture) - Handle to the texture object to enable and bindType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextvertex_buffer (dmGraphics::HVertexBuffer) - Vertex buffer handlebinding_index (uint32_t) - Binding index to associate with this bufferType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextvertex_declaration (dmGraphics::HVertexDeclaration) - Vertex declaration handlebinding_index (uint32_t) - Binding index to associate with this declarationbase_offset (uint32_t) - Byte offset to add to all vertex attribute pointersprogram (dmGraphics::HProgram) - Shader program to use with this declarationType: ENUM
Members
FACE_WINDING_CCWFACE_WINDING_CWType: FUNCTION Finalizes the graphics system. Cleans up global graphics resources and shuts down the graphics system. This should be called when the application is exiting.
Type: FUNCTION 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
program (dmGraphics::HProgram) - Shader program handlename_hash (dmhash_t) - Hash of the uniform variable nameReturns
location (dmGraphics::HUniformLocation) - Uniform location handle, or INVALID_UNIFORM_LOCATION if not foundType: FUNCTION 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
program (dmGraphics::HProgram) - Shader program handlename (const char*) - Name of the uniform variableReturns
location (dmGraphics::HUniformLocation) - Uniform location handle, or INVALID_UNIFORM_LOCATION if not foundType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextType: FUNCTION Gets the adapter family from a string name. Converts a string identifier to the corresponding AdapterFamily enum value.
Parameters
adapter_name (const char*) - String name of the adapter (e.g., “opengl”, “vulkan”)Returns
family (dmGraphics::AdapterFamily) - Corresponding adapter family enum valueType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextReturns
scale_factor (float) - Display scale factorType: FUNCTION Returns the specified height of the opened window, which might differ from the actual window width.
Parameters
context (dmGraphics::HContext) - Graphics contextReturns
height (uint32_t) - Specified height of the window. If no window is opened, 0 is always returned.Type: FUNCTION Get installed graphics adapter family
Returns
family (dmGraphics::AdapterFamily) - Installed adapter familyType: FUNCTION
Returns
context (dmGraphics::HContext) - Installed graphics contextType: FUNCTION Get the max number of indices allowed by the system in an index buffer
Parameters
context (dmGraphics::HContext) - the contextReturns
count (uint32_t) - the countType: FUNCTION Get the max number of vertices allowed by the system in a vertex buffer
Parameters
context (dmGraphics::HContext) - the contextReturns
count (uint32_t) - the countType: FUNCTION Get maximum supported size in pixels of non-array texture
Parameters
context (dmGraphics::HContext) - Graphics contextReturns
max_texture_size (uint32_t) - Maximum texture size supported by GPUType: FUNCTION
Parameters
context (dmGraphics::HContext) - the contextReturns
count (uint32_t) - the number of supported extensionsType: FUNCTION Get how many platform-dependent texture handle used for engine texture handle. Applicable only for OpenGL/ES backend. All other backends return 1.
Parameters
context (dmGraphics::Context) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
handles_amount (uint8_t) - Platform-dependent handles amountType: FUNCTION Get texture original (before uploading to GPU) height
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
original_height (uint16_t)Type: FUNCTION Get texture original (before uploading to GPU) width
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
original_width (uin16_t) - Texture’s original widthType: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextReturns
pipeline_state (dmGraphics::PipelineState)Type: FUNCTION Get the attachment texture from a render target. Returns zero if no such attachment texture exists.
Parameters
context (dmGraphics::HContext) - Graphics contextrender_target (dmGraphics::HRenderTarget) - the render targetattachment_type (dmGraphics::RenderTargetAttachment) - the attachment to getReturns
attachment (dmGraphics::HTexture) - the attachment textureType: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextrender_target (dmGraphics::HRenderTarget)buffer_type (dmGraphics::BufferType)width (uint32_t&)height (uint32_t&)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextrender_target (dmGraphics::HRenderTarget)buffer_type (dmGraphics::BufferType)Returns
render_target_texture (dmGraphics::HTexture)Type: FUNCTION get the supported extension
Parameters
context (dmGraphics::HContext) - the contextindex (uint32_t) - the index of the extensionReturns
extension (const char*) - the extension. 0 if index was out of boundsType: FUNCTION Get texture depth. applicable for 3D and cube map textures
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
depth (uint16_t) - Texture’s depthType: FUNCTION Get string representation of texture format
Parameters
format (dmGraphics::TextureFormat) - Texture formatReturns
literal_format (const char*) - String representation of formatType: FUNCTION 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
texture (dmGraphics::HTexture) - the texture handleout_handle (void**) - a pointer to where the raw object should be storedReturns
handle_result (dmGraphics::HandleResult) - the result of the queryType: FUNCTION Get texture height
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
height (uint16_t) - Texture’s heightType: FUNCTION Get texture mipmap count
Parameters
context (dmGraphice::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
count (uint8_t) - Texture mipmap countType: FUNCTION Get approximate size of how much memory texture consumes
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
data_size (uint32_t) - Resource data size in bytesType: FUNCTION Get status of texture
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
flags (dmGraphics::TextureStatusFlags) - Enumerated status bit flagsType: FUNCTION Get texture type
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
type (dmGraphics::TextureType) - Texture typeType: FUNCTION Get string representation of texture type
Parameters
texture_type (dmGraphics::TextureType) - Texture typeReturns
literal_type (const char*) - String representation of typeType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
flags (uint32_t) - A bitwise OR of usage flags describing how the texture may be used. Applications can test specific flags using bitmask operationsType: FUNCTION Get texture width
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleReturns
width (uint16_t) - Texture’s widthType: FUNCTION Get the physical offset into the vertex data for a particular stream
Parameters
vertex_declaration (dmGraphics::HVertexDeclaration) - the vertex declarationname_hash (dmhash_t) - the name hash of the vertex stream (as passed into AddVertexStream())Returns
Offset - in bytes into the vertex or INVALID_STREAM_OFFSET if not foundType: FUNCTION Get viewport’s parameters
Parameters
context (dmGraphics::HContext) - the contextx (int32_t) - x-coordinate of the viewport’s originy (int32_t) - y-coordinate of the viewport’s originwidth (uint32_t) - viewport’s widthheight (uint32_t) - viewport’s heightType: FUNCTION Returns the specified width of the opened window, which might differ from the actual window width.
Parameters
context (dmGraphics::HContext) - Graphics contextReturns
width (uint32_t) - Specified width of the window. If no window is opened, 0 is always returned.Type: FUNCTION Return the height of the opened window, if any.
Parameters
context (dmGraphics::HContext) - Graphics contextReturns
window_height (uint32_t) - Height of the window. If no window is opened, 0 is always returnedType: FUNCTION Return the width of the opened window, if any.
Parameters
context (dmGraphics::HContext) - Graphics contextReturns
window_width (uint32_t) - Width of the window. If no window is opened, 0 is always returnedType: ENUM Function’s call result code
Members
HANDLE_RESULT_OK - The function’s call succeeded and returned a valid resultHANDLE_RESULT_NOT_AVAILABLE - The function is not supported by the current graphics backendHANDLE_RESULT_ERROR - An error occurred while function callType: TYPEDEF Context handle
Type: TYPEDEF Index buffer handle
Type: TYPEDEF Program handle
Type: TYPEDEF Rendertarget handle
Type: TYPEDEF Storage buffer handle
Type: TYPEDEF Texture handle
Type: TYPEDEF Uniform location handle
Type: TYPEDEF Vertex buffer handle
Type: TYPEDEF Vertex declaration handle
Type: TYPEDEF Vertex stream declaration handle
Type: ENUM Index buffer element types. Defines the integer size used for vertex indices
Members
INDEXBUFFER_FORMAT_16 - 16-bit unsigned integers (max 65535 vertices)INDEXBUFFER_FORMAT_32 - 32-bit unsigned integers (supports larger meshes)Type: FUNCTION Installs a graphics adapter. Initializes the specified graphics backend (OpenGL, Vulkan, etc.). This must be called before creating any graphics context.
Parameters
family (dmGraphics::AdapterFamily) - Graphics adapter family to installReturns
success (bool) - True if the adapter was successfully installed, false otherwiseType: CONSTANT Invalid program handle constant. Used to represent an uninitialized or invalid program handle. Can be used to check if program creation or loading failed.
Type: CONSTANT Invalid stream offset
Type: CONSTANT Invalid uniform location constant. Used to represent an uninitialized or invalid uniform location. Can be used to check if uniform location lookup failed.
Type: FUNCTION check if an extension is supported
Parameters
context (dmGraphics::HContext) - the contextextension (const char*) - the extension.Returns
result (bool) - true if the extension was supportedType: FUNCTION Check if the index format is supported
Parameters
context (dmGraphics::HContext) - the contextformat (dmGraphics::IndexBufferFormat) - the formatresult (bool) - true if the format is supoprtedType: FUNCTION check if a specific texture format is supported
Parameters
context (dmGraphics::HContext) - the contextformat (dmGraphics::TextureFormat) - the texture format.Returns
result (bool) - true if the texture format was supportedType: CONSTANT Max buffer color attachments
Type: FUNCTION Creates a new graphics context. Initializes the graphics system with the specified parameters. Only one graphics context can be active at a time.
Parameters
params (const dmGraphics::ContextParams&) - Context creation parametersReturns
context (dmGraphics::HContext) - New graphics context handle, or null on failureType: FUNCTION Create new index buffer with initial data
Notes
Parameters
context (dmGraphics::HContext) - the contextsize (uint32_t) - the size of the buffer (in bytes). May be 0data (void*) - the databuffer_usage (dmGraphics::BufferUsage) - the usageReturns
buffer (dmGraphics::HIndexBuffer) - the index bufferType: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextddf (dmGraphics::ShaderDesc*) - Shader description containing source code and parameterserror_buffer (char*) - Buffer to receive error messages (can be null)error_buffer_size (uint32_t) - Size of the error bufferReturns
program (dmGraphics::HProgram) - New program handle, or INVALID_PROGRAM_HANDLE on failureType: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextbuffer_type_flags (uint32_t)params (dmGraphics::const RenderTargetCreationParams)Returns
render_target (dmGraphics::HRenderTarget) - Newly created render targetType: FUNCTION Create new texture
Parameters
context (HContext) - Graphics contextparams (const dmGraphics::TextureCreationParams&) - Creation parametersReturns
texture_handle (dmGraphics::HTexture) - Opaque texture handleType: FUNCTION Create new vertex buffer with initial data
Parameters
context (dmGraphics::HContext) - the contextsize (uint32_t) - the size of the buffer (in bytes). May be 0data (void*) - the databuffer_usage (dmGraphics::BufferUsage) - the usageReturns
buffer (dmGraphics::HVertexBuffer) - the vertex bufferType: FUNCTION Create new vertex declaration from a vertex stream declaration
Parameters
context (dmGraphics::HContext) - the contextstream_declaration (dmGraphics::HVertexStreamDeclaration) - the vertex stream declarationReturns
declaration (dmGraphics::HVertexDeclaration) - the vertex declarationType: FUNCTION 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
context (dmGraphics::HContext) - the contextstream_declaration (dmGraphics::HVertexStreamDeclaration) - the vertex stream declarationstride (uint32_t) - the stride between the start of each vertex (in bytes)Returns
declaration (dmGraphics::HVertexDeclaration) - the vertex declarationType: 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
context (dmGraphics::HContext) - the contextReturns
declaration (dmGraphics::HVertexStreamDeclaration) - the vertex declarationType: 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
context (dmGraphics::HContext) - the contextstep_function (dmGraphics::VertexStepFunction) - the vertex step function to useReturns
declaration (dmGraphics::HVertexStreamDeclaration) - the vertex declarationType: ENUM Primitive drawing modes. Defines how vertex data is assembled into primitives
Members
PRIMITIVE_LINES - Each pair of vertices forms a linePRIMITIVE_TRIANGLES - Each group of 3 vertices forms a trianglePRIMITIVE_TRIANGLE_STRIP - Connected strip of triangles (shares vertices)Type: FUNCTION Read frame buffer pixels in BGRA format
Parameters
context (dmGraphics::HContext) - the contextx (int32_t) - x-coordinate of the starting positiony (int32_t) - y-coordinate of the starting positionwidth (uint32_t) - width of the regionheight (uint32_t) - height of the regionbuffer (void*) - buffer to read tobuffer_size (uint32_t) - buffer sizeType: ENUM Attachment points for render targets
Members
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)Type: FUNCTION
Parameters
num_pixels (uint32_t)rgb (uint8_t*)rgba (uint8_t*)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextsource_factor (gmGraphics::BlendFactor)destination_factor (dmGraphics::BlendFactor)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextred (bool)green (bool)blue (bool)alpha (bool)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextface_type (dmGraphics::FaceType)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextfunc (dmGraphics::CompareFunc)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextenable_mask (bool)Type: FUNCTION Set index buffer data
Parameters
buffer (dmGraphics::HIndexBuffer) - the buffersize (uint32_t) - the size of the buffer (in bytes). May be 0data (void*) - the databuffer_usage (dmGraphics::BufferUsage) - the usageType: FUNCTION Set subset of index buffer data
Parameters
buffer (dmGraphics::HVertexBuffer) - the bufferoffset (uint32_t) - the offset into the desination buffer (in bytes)size (uint32_t) - the size of the buffer (in bytes). May be 0data (void*) - the dataType: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextrender_target (dmGraphics::HRenderTarget)transient_buffer_types (uint32_t)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextrender_target (dmGraphics::HRenderTarget)width (uint32_t)height (uint32_t)Type: FUNCTION 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
context (dmGraphics::HContext) - Graphics contextlocation (dmGraphics::HUniformLocation) - Uniform location of the samplerunit (int32_t) - Texture unit index to bind toType: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextfunc (dmGraphics::CompareFunc)ref (uint32_t)mask (uint32_t)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextface_type (dmGraphics::FaceType)func (dmGraphics::CompareFunc)ref (uint32_t)mask (uint32_t)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextmask (uint32_t)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextsfail (dmGraphics::StencilOp)dpfail (dmGraphics::StencilOp)dppass (dmGraphics::StencilOp)Type: FUNCTION
Parameters
context (dmGraphics::HContext) - Graphics contextface_type (dmGraphics::FaceType)sfail (dmGraphics::StencilOp)dpfail (dmGraphics::StencilOp)dppass (dmGraphics::StencilOp)Type: FUNCTION 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
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleparams (const dmGraphics::TextureParams&)Type: FUNCTION 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
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handleparams (const dmGraphics::TextureParams&) - Texture parameters. Texture will be recreated if parameters differ from creation parameterscallback (dmGraphics::SetTextureAsyncCallback) - Completion callbackuser_data (void*) - User data that will be passed to completion callbackType: TYPEDEF Function called when a texture has been set asynchronously
Parameters
texture (dmGraphics::HTexture) - Texture handleuser_data (void*) - User data that will be passed to the SetTextureAsyncCallbackType: FUNCTION Set texture parameters
Parameters
context (dmGraphics::HContext) - Graphics contexttexture (dmGraphics::HTexture) - Texture handlemin_filter (dmGraphics::TextureFilter) - Minification filter typemag_filter (dmGraphics::TextureFilter) - Magnification filter typeuwrap (dmGraphics::TextureWrap) - Wrapping mode for the U (X) texture coordinate.vwrap (dmGraphics::TextureWrap) - Wrapping mode for the V (Y) texture coordinatemax_anisotropy (float)Type: FUNCTION Set vertex buffer data
Parameters
buffer (dmGraphics::HVertexBuffer) - the buffersize (uint32_t) - the size of the buffer (in bytes). May be 0data (void*) - the databuffer_usage (dmGraphics::BufferUsage) - the usageType: FUNCTION Set subset of vertex buffer data
Parameters
buffer (dmGraphics::HVertexBuffer) - the bufferoffset (uint32_t) - the offset into the desination buffer (in bytes)size (uint32_t) - the size of the buffer (in bytes). May be 0data (void*) - the dataType: FUNCTION Sets the viewport for rendering. Defines the affine transformation from normalized device coordinates to window coordinates. This affects all subsequent rendering operations.
Parameters
context (dmGraphics::HContext) - Graphics contextx (int32_t) - X coordinate of the viewport’s origin (in pixels)y (int32_t) - Y coordinate of the viewport’s origin (in pixels)width (int32_t) - Width of the viewport (in pixels)height (int32_t) - Height of the viewport (in pixels)Type: STRUCT Shader program description (from graphics_ddf.h)
Type: ENUM Stencil test actions. Defines what happens to a stencil buffer value depending on the outcome of the stencil/depth test.
Members
STENCIL_OP_KEEP - Keep the current stencil valueSTENCIL_OP_ZERO - Set stencil value to 0STENCIL_OP_REPLACE - Replace stencil value with reference valueSTENCIL_OP_INCR - Increment stencil value (clamps at max)STENCIL_OP_INCR_WRAP - Increment stencil value, wrapping aroundSTENCIL_OP_DECR - Decrement stencil value (clamps at 0)STENCIL_OP_DECR_WRAP - Decrement stencil value, wrapping aroundSTENCIL_OP_INVERT - Bitwise invert stencil valueType: STRUCT 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
m_Type (dmGraphics::TextureType) - Texture type. Defines the dimensionality and interpretation of the texture (2D, 3D, cube map, array)m_Width (uint16_t) - Width of the texture in pixels at the base mip levelm_Height (uint16_t) - Height of the texture in pixels at the base mip levelm_Depth (uint16_t) - Depth of the texture. Used for 3D textures or texture arrays. For standard 2D textures, this is typically 1m_OriginalWidth (uint16_t) - Width of the original source data before scaling or compressionm_OriginalHeight (uint16_t) - Height of the original source data before scaling or compressionm_OriginalDepth (uint16_t) - Depth of the original source datam_LayerCount (uint8_t) - Number of layers in the texture. Used for array textures (TEXTURE_TYPE_2D_ARRAY). For standard 2D textures, this is 1m_MipMapCount (uint8_t) - Number of mipmap levels. A value of 1 means no mipmaps (only the base level is stored). Larger values allow for mipmapped sampling.m_UsageHintBits (uint8_t) - Bitfield of usage hints. Indicates how the texture will be used (e.g. sampling, render target, storage image). See dmGraphics::TextureUsageFlagType: ENUM Texture filtering modes. Controls how texels are sampled when scaling or rotating textures
Members
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 texelTEXTURE_FILTER_NEAREST_MIPMAP_LINEAR - Linear blend between two mipmap levels, nearest texelTEXTURE_FILTER_LINEAR_MIPMAP_NEAREST - Nearest mipmap level, linear texelTEXTURE_FILTER_LINEAR_MIPMAP_LINEAR - Linear blend between mipmap levels and texels (trilinear)Type: ENUM Pixel formats supported by textures. Includes uncompressed, compressed, and floating-point variants
Members
TEXTURE_FORMAT_LUMINANCE - Single-channel grayscaleTEXTURE_FORMAT_LUMINANCE_ALPHA - Two-channel grayscale + alphaTEXTURE_FORMAT_RGB - Standard 24-bit RGB colorTEXTURE_FORMAT_RGBA - Standard 32-bit RGBA colorTEXTURE_FORMAT_RGB_16BPP - Packed 16-bit RGB (lower precision, saves memory)TEXTURE_FORMAT_RGBA_16BPP - Packed 16-bit RGBATEXTURE_FORMAT_DEPTH - Depth buffer texture (used for depth testing)TEXTURE_FORMAT_STENCIL - Stencil buffer textureTEXTURE_FORMAT_RGB_PVRTC_2BPPV1 - PVRTC compressed RGB at 2 bits per pixelTEXTURE_FORMAT_RGB_PVRTC_4BPPV1 - PVRTC compressed RGB at 4 bits per pixelTEXTURE_FORMAT_RGBA_PVRTC_2BPPV1 - PVRTC compressed RGBA at 2 bits per pixelTEXTURE_FORMAT_RGBA_PVRTC_4BPPV1 - PVRTC compressed RGBA at 4 bits per pixelTEXTURE_FORMAT_RGB_ETC1 - ETC1 compressed RGB (no alpha support)TEXTURE_FORMAT_R_ETC2 - ETC2 single-channelTEXTURE_FORMAT_RG_ETC2 - ETC2 two-channelTEXTURE_FORMAT_RGBA_ETC2 - ETC2 four-channel (with alpha)TEXTURE_FORMAT_RGBA_ASTC_4X4 - ASTC block-compressed 4×4TEXTURE_FORMAT_RGB_BC1 - BC1/DXT1 compressed RGBTEXTURE_FORMAT_RGBA_BC3 - BC3/DXT5 compressed RGBATEXTURE_FORMAT_R_BC4 - BC4 single-channelTEXTURE_FORMAT_RG_BC5 - BC5 two-channelTEXTURE_FORMAT_RGBA_BC7 - BC7 high-quality compressed RGBATEXTURE_FORMAT_RGB16F - Half-precision float RGBTEXTURE_FORMAT_RGB32F - Full 32-bit float RGBTEXTURE_FORMAT_RGBA16F - Half-precision float RGBATEXTURE_FORMAT_RGBA32F - Full 32-bit float RGBATEXTURE_FORMAT_R16F - Half-precision float single channelTEXTURE_FORMAT_RG16F - Half-precision float two channelsTEXTURE_FORMAT_R32F - Full 32-bit float single channelTEXTURE_FORMAT_RG32F - Full 32-bit float two channelsTEXTURE_FORMAT_RGBA32UI - Internal: 32-bit unsigned integer RGBA (not script-exposed)TEXTURE_FORMAT_BGRA8U - Internal: 32-bit BGRA layoutTEXTURE_FORMAT_R32UI - Internal: 32-bit unsigned integer single channelTEXTURE_FORMAT_RGBA_ASTC_5X4 - ASTC 5x4 block compressionTEXTURE_FORMAT_RGBA_ASTC_5X5 - ASTC 5x5 block compressionTEXTURE_FORMAT_RGBA_ASTC_6X5 - ASTC 6x5 block compressionTEXTURE_FORMAT_RGBA_ASTC_6X6 - ASTC 6x6 block compressionTEXTURE_FORMAT_RGBA_ASTC_8X5 - ASTC 8x5 block compressionTEXTURE_FORMAT_RGBA_ASTC_8X6 - ASTC 8x6 block compressionTEXTURE_FORMAT_RGBA_ASTC_8X8 - ASTC 8x8 block compressionTEXTURE_FORMAT_RGBA_ASTC_10X5 - ASTC 10x5 block compressionTEXTURE_FORMAT_RGBA_ASTC_10X6 - ASTC 10x6 block compressionTEXTURE_FORMAT_RGBA_ASTC_10X8 - ASTC 10x8 block compressionTEXTURE_FORMAT_RGBA_ASTC_10X10 - ASTC 10x10 block compressionTEXTURE_FORMAT_RGBA_ASTC_12X10 - ASTC 12x10 block compressionTEXTURE_FORMAT_RGBA_ASTC_12X12 - ASTC 12x12 block compressionType: STRUCT 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
m_Data (const void*) - Pointer to raw pixel data in CPU memory. The format is defined by m_Formatm_DataSize (uint32_t) - Size of the pixel data in bytes. Must match the expected size from width, height, depth, and formatm_Format (dmGraphics::TextureFormat) - Format of the pixel data (e.g. RGBA, RGB, compressed formats). Dictates how the GPU interprets the memory pointed by m_Datam_MinFilter (dmGraphics::TextureFilter) - Minification filter (applied when shrinking). Determines how pixels are sampled when the texture is displayed smaller than its native resolutionm_MagFilter (dmGraphics::TextureFilter) - Magnification filter (applied when enlarging). Determines how pixels are sampled when the texture is displayed larger than its native resolutionm_UWrap (dmGraphics::TextureWrap) - Wrapping mode for U (X) texture coordinate. Controls behavior when texture coordinates exceed [0,1]m_VWrap (dmGraphics::TextureWrap) - Wrapping mode for V (Y) texture coordinate. Controls behavior when texture coordinates exceed [0,1]m_X (uint32_t) - X offset in pixels for sub-texture updates. Defines the left edge of the destination regionm_Y (uint32_t) - Y offset in pixels for sub-texture updates. Defines the top edge of the destination regionm_Z (uint32_t) - Z offset (depth layer) for 3D textures. Ignored for standard 2D texturesm_Slice (uint32_t) - Slice index in an array texture where the data should be uploadedm_Width (uint16_t) - Width of the pixel data block in pixels. Used for both full uploads and sub-updatesm_Height (uint16_t) - Height of the pixel data block in pixels. Used for both full uploads and sub-updatesm_Depth (uint16_t) - Depth of the pixel data block in pixels. Only relevant for 3D texturesm_LayerCount (uint8_t) - Number of layers to update. For array textures, this specifies how many pages are updatedm_MipMap (uint8_t) - Only 7 bit available Mipmap level to update. Level 0 is the base level, higher levels are progressively downscaled versionsm_SubUpdate (uint8_t) - 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 replacedType: ENUM Texture data upload status flags
Members
TEXTURE_STATUS_OK - Texture updated and ready-to-useTEXTURE_STATUS_DATA_PENDING - Data upload to the texture is in progressType: ENUM Texture types
Members
TEXTURE_TYPE_2DTEXTURE_TYPE_2D_ARRAYTEXTURE_TYPE_3DTEXTURE_TYPE_CUBE_MAPTEXTURE_TYPE_IMAGE_2DTEXTURE_TYPE_IMAGE_3DTEXTURE_TYPE_SAMPLERTEXTURE_TYPE_TEXTURE_2DTEXTURE_TYPE_TEXTURE_2D_ARRAYTEXTURE_TYPE_TEXTURE_3DTEXTURE_TYPE_TEXTURE_CUBEType: ENUM Texture addressing/wrapping modes. Controls behavior when texture coordinates fall outside the [0,1] range
Members
TEXTURE_WRAP_CLAMP_TO_BORDER - Clamp to the color defined as ‘border’TEXTURE_WRAP_CLAMP_TO_EDGE - Clamp to the edge pixel of the textureTEXTURE_WRAP_MIRRORED_REPEAT - Repeat texture, mirroring every other repetitionTEXTURE_WRAP_REPEAT - Repeat texture in a tiled fashionType: ENUM Data type. Represents scalar, vector, matrix, image, or sampler types used for vertex attributes, uniforms, and shader interface definitions
Members
TYPE_BYTE - Signed 8-bit integer. Compact storage, often used for colors, normals, or compressed vertex attributesTYPE_UNSIGNED_BYTE - Unsigned 8-bit integer. Common for color channels (0–255) or normalized texture dataTYPE_SHORT - Signed 16-bit integer. Used for medium-range numeric attributes such as bone weights or coordinates with normalizationTYPE_UNSIGNED_SHORT - Unsigned 16-bit integer. Often used for indices or normalized attributes when extra precision over bytes is requiredTYPE_INT - Signed 32-bit integer. Typically used for uniform values, shader constants, or countersTYPE_UNSIGNED_INT - Unsigned 32-bit integer. Used for indices, IDs, or GPU countersTYPE_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 attributesTYPE_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 lookupsTYPE_SAMPLER_CUBE - Cube map sampler. Used for environment mapping, reflections, and skyboxesTYPE_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 positionsTYPE_FLOAT_VEC3 - 3-component floating-point vector (vec3 in GLSL). Used for positions, normals, and directions in 3D spaceTYPE_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 lightingTYPE_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 resourceTYPE_SAMPLER - Generic sampler handle, used as a placeholder for texture units without specifying the dimensionTYPE_TEXTURE_2D_ARRAY - 2D texture array object handleTYPE_TEXTURE_CUBE - Cube map texture object handleTYPE_SAMPLER_3D - 3D texture sampler. Used for volumetric effects, noise fields, or voxel dataTYPE_TEXTURE_3D - 3D texture object handleTYPE_IMAGE_3D - 3D image object. Used for compute-based volume processingTYPE_SAMPLER_3D_ARRAY - Array of 3D texture samplersTYPE_TEXTURE_3D_ARRAY - 3D texture array object handle