Graphics

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

API

AdapterFamily

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

Members

AddVertexStream

Type: FUNCTION Adds a stream to a vertex stream declaration

Parameters

AddVertexStream

Type: FUNCTION Adds a stream to a vertex stream declaration

Parameters

AttachmentOp

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

Members

BeginFrame

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

Parameters

BlendFactor

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

Members

BufferAccess

Type: ENUM

Members

BufferUsage

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

Members

Clear

Type: 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

CloseWindow

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

Parameters

CompareFunc

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

Members

ContextParams

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

DeleteContext

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

Parameters

DeleteIndexBuffer

Type: FUNCTION Delete the index buffer

Parameters

DeleteProgram

Type: 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

DeleteRenderTarget

Type: FUNCTION

Parameters

DeleteTexture

Type: FUNCTION Delete texture

Parameters

DeleteVertexBuffer

Type: FUNCTION Delete vertex buffer

Parameters

DeleteVertexDeclaration

Type: FUNCTION Delete vertex declaration

Parameters

DeleteVertexStreamDeclaration

Type: FUNCTION Delete vertex stream declaration

Parameters

DisableProgram

Type: 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

DisableState

Type: FUNCTION

Parameters

DisableTexture

Type: 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

DisableVertexBuffer

Type: 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

DisableVertexDeclaration

Type: 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

Draw

Type: 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

EnableProgram

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

EnableState

Type: FUNCTION

Parameters

EnableTexture

Type: 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

EnableVertexBuffer

Type: 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

EnableVertexDeclaration

Type: 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

FaceWinding

Type: ENUM

Members

Finalize

Type: 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.

FindUniformLocation

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

Returns

FindUniformLocation

Type: 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

Returns

Flip

Type: 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

GetAdapterFamily

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

Parameters

Returns

GetDisplayScaleFactor

Type: 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

Returns

GetHeight

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

Parameters

Returns

GetInstalledAdapterFamily

Type: FUNCTION Get installed graphics adapter family

Returns

GetInstalledContext

Type: FUNCTION

Returns

GetMaxElementsIndices

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

Parameters

Returns

GetMaxElementsVertices

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

Parameters

Returns

GetMaxTextureSize

Type: FUNCTION Get maximum supported size in pixels of non-array texture

Parameters

Returns

GetNumSupportedExtensions

Type: FUNCTION

Parameters

Returns

GetNumTextureHandles

Type: 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

Returns

GetOriginalTextureHeight

Type: FUNCTION Get texture original (before uploading to GPU) height

Parameters

Returns

GetOriginalTextureWidth

Type: FUNCTION Get texture original (before uploading to GPU) width

Parameters

Returns

GetPipelineState

Type: FUNCTION

Parameters

Returns

GetRenderTargetAttachment

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

Parameters

Returns

GetRenderTargetSize

Type: FUNCTION

Parameters

GetRenderTargetTexture

Type: FUNCTION

Parameters

Returns

GetSupportedExtension

Type: FUNCTION get the supported extension

Parameters

Returns

GetTextureDepth

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

Parameters

Returns

GetTextureFormatLiteral

Type: FUNCTION Get string representation of texture format

Parameters

Returns

GetTextureHandle

Type: 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

Returns

GetTextureHeight

Type: FUNCTION Get texture height

Parameters

Returns

GetTextureMipmapCount

Type: FUNCTION Get texture mipmap count

Parameters

Returns

GetTextureResourceSize

Type: FUNCTION Get approximate size of how much memory texture consumes

Parameters

Returns

GetTextureStatusFlags

Type: FUNCTION Get status of texture

Parameters

Returns

GetTextureType

Type: FUNCTION Get texture type

Parameters

Returns

GetTextureTypeLiteral

Type: FUNCTION Get string representation of texture type

Parameters

Returns

GetTextureUsageHintFlags

Type: 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

Returns

GetTextureWidth

Type: FUNCTION Get texture width

Parameters

Returns

GetVertexStreamOffset

Type: FUNCTION Get the physical offset into the vertex data for a particular stream

Parameters

Returns

GetViewport

Type: FUNCTION Get viewport’s parameters

Parameters

GetWidth

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

Parameters

Returns

GetWindowHeight

Type: FUNCTION Return the height of the opened window, if any.

Parameters

Returns

GetWindowWidth

Type: FUNCTION Return the width of the opened window, if any.

Parameters

Returns

HandleResult

Type: ENUM Function’s call result code

Members

HContext

Type: TYPEDEF Context handle

HIndexBuffer

Type: TYPEDEF Index buffer handle

HProgram

Type: TYPEDEF Program handle

HRenderTarget

Type: TYPEDEF Rendertarget handle

HStorageBuffer

Type: TYPEDEF Storage buffer handle

HTexture

Type: TYPEDEF Texture handle

HUniformLocation

Type: TYPEDEF Uniform location handle

HVertexBuffer

Type: TYPEDEF Vertex buffer handle

HVertexDeclaration

Type: TYPEDEF Vertex declaration handle

HVertexStreamDeclaration

Type: TYPEDEF Vertex stream declaration handle

IndexBufferFormat

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

Members

InstallAdapter

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

Parameters

Returns

INVALID_PROGRAM_HANDLE

Type: 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.

INVALID_STREAM_OFFSET

Type: CONSTANT Invalid stream offset

INVALID_UNIFORM_LOCATION

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.

IsExtensionSupported

Type: FUNCTION check if an extension is supported

Parameters

Returns

IsIndexBufferFormatSupported

Type: FUNCTION Check if the index format is supported

Parameters

IsTextureFormatSupported

Type: FUNCTION check if a specific texture format is supported

Parameters

Returns

MAX_BUFFER_COLOR_ATTACHMENTS

Type: CONSTANT Max buffer color attachments

NewContext

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

Returns

NewIndexBuffer

Type: FUNCTION Create new index buffer with initial data

Notes

Parameters

Returns

NewProgram

Type: 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

Returns

NewRenderTarget

Type: FUNCTION

Parameters

Returns

NewTexture

Type: FUNCTION Create new texture

Parameters

Returns

NewVertexBuffer

Type: FUNCTION Create new vertex buffer with initial data

Parameters

Returns

NewVertexDeclaration

Type: FUNCTION Create new vertex declaration from a vertex stream declaration

Parameters

Returns

NewVertexDeclaration

Type: 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

Returns

NewVertexStreamDeclaration

Type: 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

Returns

NewVertexStreamDeclaration

Type: 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

Returns

PrimitiveType

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

Members

ReadPixels

Type: FUNCTION Read frame buffer pixels in BGRA format

Parameters

RenderTargetAttachment

Type: ENUM Attachment points for render targets

Members

RepackRGBToRGBA

Type: FUNCTION

Parameters

SetBlendFunc

Type: FUNCTION

Parameters

SetColorMask

Type: FUNCTION

Parameters

SetCullFace

Type: FUNCTION

Parameters

SetDepthFunc

Type: FUNCTION

Parameters

SetDepthMask

Type: FUNCTION

Parameters

SetIndexBufferData

Type: FUNCTION Set index buffer data

Parameters

SetIndexBufferSubData

Type: FUNCTION Set subset of index buffer data

Parameters

SetRenderTarget

Type: FUNCTION

Parameters

SetRenderTargetSize

Type: FUNCTION

Parameters

SetSampler

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

SetStencilFunc

Type: FUNCTION

Parameters

SetStencilFuncSeparate

Type: FUNCTION

Parameters

SetStencilMask

Type: FUNCTION

Parameters

SetStencilOp

Type: FUNCTION

Parameters

SetStencilOpSeparate

Type: FUNCTION

Parameters

SetTexture

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

SetTextureAsync

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

SetTextureAsyncCallback

Type: TYPEDEF Function called when a texture has been set asynchronously

Parameters

SetTextureParams

Type: FUNCTION Set texture parameters

Parameters

SetVertexBufferData

Type: FUNCTION Set vertex buffer data

Parameters

SetVertexBufferSubData

Type: FUNCTION Set subset of vertex buffer data

Parameters

SetViewport

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

Parameters

ShaderDesc

Type: STRUCT Shader program description (from graphics_ddf.h)

StencilOp

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

Members

TextureCreationParams

Type: 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

TextureFilter

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

Members

TextureFormat

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

Members

TextureParams

Type: 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

TextureStatusFlags

Type: ENUM Texture data upload status flags

Members

TextureType

Type: ENUM Texture types

Members

TextureWrap

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

Members

Type

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

Members