LDKRendererTextureDesc
typedef struct LDKRendererTextureDesc{
u32 width;
u32 height;
u32 channel_count;
LDKRHIFormat format;
u32 flags;
void const *pixels;
u64 byte_count;
LDKRendererTextureOptions const *options;
}LDKRendererTextureDesc;
LDKRendererTextureFlag
typedef enum LDKRendererTextureFlag{
LDK_RENDERER_TEXTURE_FLAG_NONE=0,
LDK_RENDERER_TEXTURE_FLAG_SRGB=1<<0,
LDK_RENDERER_TEXTURE_FLAG_RENDERABLE=1<<1
}LDKRendererTextureFlag;
LDKRendererTextureOptions
typedef struct LDKRendererTextureOptions{
u32 flags;
bool generate_mipmaps;
LDKRHIFilter min_filter;
LDKRHIFilter mag_filter;
LDKRHIFilter mip_filter;
LDKRHIWrap wrap_u;
LDKRHIWrap wrap_v;
LDKRHIWrap wrap_w;
}LDKRendererTextureOptions;
LDKRendererTextureResource
typedef struct LDKRendererTextureResource{
LDKRHITexture texture;
LDKRHISampler sampler;
u32 width;
u32 height;
u32 channel_count;
LDKRHIFormat format;
u32 flags;
bool alive;
struct LDKAssetManager *asset_manager;
LDKAssetImage image_asset;
u32 image_references;
}LDKRendererTextureResource;
LDKRendererWaterTexture
typedef enum LDKRendererWaterTexture{
LDK_RENDERER_WATER_TEXTURE_NORMAL=0,
LDK_RENDERER_WATER_TEXTURE_FOAM,
LDK_RENDERER_WATER_TEXTURE_NOISE,
LDK_RENDERER_WATER_TEXTURE_CAUSTICS,
LDK_RENDERER_WATER_TEXTURE_COUNT
}LDKRendererWaterTexture;
ldk_renderer_game_texture_get
Return the game render target color texture for UI rendering.
The returned texture is owned by the renderer and remains valid until the
game render target is recreated or the renderer is terminated.
LDK_API LDKUITextureHandle ldk_renderer_game_texture_get(LDKRenderer const *renderer);
Parameters
LDKRenderer const *renderer
- Renderer instance.
Returns
Game color texture handle, or an invalid handle when unavailable.
ldk_renderer_get_font_page_texture
Get or create the renderer texture for a font atlas page.
The UI system renders text using font atlas pages generated by LDKFontInstance.
This function returns a texture handle for the requested page, creating the
underlying renderer/RHI texture on demand and caching it for later calls.
The returned handle is intended for UI draw commands. It is owned by the
renderer and must not be destroyed by the caller. Cached font page textures
are released when the renderer is terminated.
LDK_API LDKUITextureHandle ldk_renderer_get_font_page_texture(
LDKRenderer *renderer,
LDKFontInstance *font,
u32 page_index
);
Parameters
LDKRenderer *renderer
- Renderer that owns the font page texture cache.
LDKFontInstance *font
- Font instance that owns the requested atlas page.
u32 page_index
- Index of the font atlas page.
Returns
UI texture handle for the atlas page, or an invalid handle on failure.
ldk_renderer_get_font_page_texture_callback
Callback wrapper for ldk_renderer_get_font_page_texture().
This function matches the callback shape expected by the UI/font rendering
code. The user pointer must be an LDKRenderer*.
LDK_API LDKUITextureHandle ldk_renderer_get_font_page_texture_callback(
void *user,
LDKFontInstance *font,
u32 page_index
);
Parameters
void *user
- Renderer pointer passed as opaque callback user data.
LDKFontInstance *font
- Font instance that owns the requested atlas page.
u32 page_index
- Index of the font atlas page.
Returns
UI texture handle for the atlas page, or an invalid handle on failure.
ldk_renderer_texture_create
Create a renderer-owned texture resource.
The renderer translates the high-level texture description into the
appropriate RHI texture description, creates the underlying GPU texture,
stores it in the renderer texture cache, and returns a renderer resource
handle.
The source pixel data is only needed during creation. After the texture is
created, the returned resource does not depend on the original pixel buffer.
LDK_API LDKResourceTexture ldk_renderer_texture_create(
LDKRenderer *renderer,
LDKRendererTextureDesc const *desc
);
Returns
Texture resource handle, or an invalid handle on failure.
ldk_renderer_texture_create_from_image
Create a renderer texture resource from an image with explicit options.
Passing NULL for options uses ldk_renderer_texture_options_defaults().
LDK_API LDKResourceTexture ldk_renderer_texture_create_from_image(
LDKRenderer *renderer,
LDKImage const *image,
LDKRendererTextureOptions const *options
);
Returns
Texture resource handle, or an invalid handle on failure.
ldk_renderer_texture_destroy
Destroy a renderer-owned texture resource.
The renderer resolves the texture handle, destroys the underlying RHI texture,
and releases the renderer texture cache slot.
Destroying an invalid or already-dead texture handle is a no-op. Texture
resources are also destroyed automatically when the renderer is terminated.
LDK_API void ldk_renderer_texture_destroy(
LDKRenderer *renderer,
LDKResourceTexture texture
);
ldk_renderer_texture_is_valid
Check whether a texture resource handle refers to a live renderer texture.
The handle is validated against the renderer that owns the texture resource.
A non-zero handle is not enough to prove validity; the resource must still
exist in the renderer texture cache.
LDK_API bool ldk_renderer_texture_is_valid(
LDKRenderer *renderer,
LDKResourceTexture texture
);
Returns
true if the texture is valid and alive, false otherwise.
ldk_renderer_texture_null
Return an invalid texture resource handle.
This is the renderer texture equivalent of a null handle. It can be used
to initialize texture fields or to represent the absence of a texture.
LDK_API LDKResourceTexture ldk_renderer_texture_null(void);
Returns
Invalid texture resource handle.
ldk_renderer_texture_options_defaults
Initialize renderer texture options with default values.
Defaults preserve the renderer's existing texture behavior: nearest filtering,
clamp-to-edge wrapping, and no generated mipmaps.
LDK_API void ldk_renderer_texture_options_defaults(LDKRendererTextureOptions *options);
ldk_renderer_texture_ui_handle
Resolve a renderer texture resource to a UI draw texture handle.
The returned handle is a frame-local draw token suitable for UI draw
commands. The UI system must treat it as opaque and must not store it as a
persistent engine resource.
The renderer owns the original texture resource. If the resource is invalid
or no longer alive, this function returns an invalid UI texture handle.
LDK_API LDKUITextureHandle ldk_renderer_texture_ui_handle(
LDKRenderer *renderer,
LDKResourceTexture texture
);
Returns
UI texture handle for draw commands, or an invalid handle on failure.
ldk_renderer_texture_update
Update the pixel contents of an existing renderer texture resource.
The texture handle is resolved through the renderer texture cache, then the
underlying RHI texture is updated with the supplied pixel data.
The texture dimensions, format, channel count, and flags are not changed by
this call. The supplied byte count must match the expected data size for the
existing texture.
LDK_API bool ldk_renderer_texture_update(
LDKRenderer *renderer,
LDKResourceTexture texture,
void const *pixels,
u64 byte_count
);
Parameters
LDKRenderer *renderer
- Renderer that owns the texture resource.
LDKResourceTexture texture
- Texture resource handle to update.
void const *pixels
- New pixel data.
u64 byte_count
- Size of the pixel data in bytes.
Returns
true if the texture was updated, false otherwise.
ldk_renderer_view_overlay_texture_request
Request an overlay texture associated with a renderer view.
LDK_API LDKUITextureHandle ldk_renderer_view_overlay_texture_request(
LDKRenderer *renderer,
LDKRendererViewId view_id
);
Returns
Handle to the requested object or resource.
ldk_renderer_view_texture_get
Return the color texture rendered for a submitted view.
The view identifier is supplied by the caller when the view is submitted.
The returned texture is owned by the renderer and remains valid until the
view is removed, the game resolution changes, or the renderer terminates.
LDK_API LDKUITextureHandle ldk_renderer_view_texture_get(
LDKRenderer const *renderer,
LDKRendererViewId view_id
);
Returns
View color texture handle, or an invalid handle when unavailable.
ldk_renderer_view_texture_uv_get
Return the UV rectangle used to display renderer view textures.
View textures are render targets and their storage origin may differ from
ordinary image textures. Callers that display a view texture through the UI
should use this rectangle instead of assuming a texture origin.
LDK_API LDKUIRect ldk_renderer_view_texture_uv_get(LDKRenderer const *renderer);
Parameters
LDKRenderer const *renderer
- Renderer instance that owns the view texture.
Returns
Normalized UV rectangle for sampling a renderer view texture.