LDKRenderer
typedef struct LDKRenderer{
LDKRHIContext *rhi;
LDKRendererUIPass ui_pass;
LDKRendererTextPass text_pass;
LDKRendererMeshPass mesh_pass;
LDKRendererWaterPass water_pass;
LDKRendererShadowPass shadow_pass;
LDKRendererGridPass grid_pass;
LDKRendererSkyboxPass skybox_pass;
LDKRendererBlurPass blur_pass;
LDKRendererPostProcessPass post_process_pass;
LDKUIRenderData const *submitted_ui;
u32 game_width;
u32 game_height;
bool present_game;
LDKRendererView *views;
u32 view_count;
u32 view_capacity;
LDKRendererViewId game_view;
LDKRendererMeshResource *meshes;
u32 mesh_count;
u32 mesh_capacity;
LDKRendererInstanceSetResource *instance_sets;
u32 instance_set_count;
u32 instance_set_capacity;
LDKRendererSkyboxResource *skyboxes;
u32 skybox_count;
u32 skybox_capacity;
LDKRendererTextureResource *textures;
u32 texture_count;
u32 texture_capacity;
LDKRendererMaterialResource *materials;
u32 material_count;
u32 material_capacity;
LDKRendererMaterialSamplerResource *material_samplers;
u32 material_sampler_count;
u32 material_sampler_capacity;
LDKResourceMaterial default_material;
LDKRendererFontPageCacheEntry *font_pages;
u32 font_page_count;
u32 font_page_capacity;
LDKRendererAmbientLight ambient_light;
LDKResourceTexture vegetation_interaction_texture;
Vec2 vegetation_interaction_origin;
float vegetation_interaction_inv_world_size;
bool vegetation_interaction_enabled;
LDKRendererLightSubmit *submitted_lights;
u32 submitted_light_count;
u32 submitted_light_capacity;
bool light_limit_reported;
LDKResourceMesh line_mesh;
LDKRendererLineSubmit *submitted_lines;
u32 submitted_line_count;
u32 submitted_line_capacity;
LDKRendererWireframeSubmit *submitted_wireframes;
u32 submitted_wireframe_count;
u32 submitted_wireframe_capacity;
LDKRendererTextVertex *submitted_text_vertices;
u32 submitted_text_vertex_count;
u32 submitted_text_vertex_capacity;
u32 *submitted_text_indices;
u32 submitted_text_index_count;
u32 submitted_text_index_capacity;
LDKRendererTextSubmit *submitted_texts;
u32 submitted_text_count;
u32 submitted_text_capacity;
LDKRendererMeshSubmit *submitted_meshes;
u32 submitted_mesh_count;
u32 submitted_mesh_capacity;
LDKRendererWaterSubmit *submitted_water;
u32 submitted_water_count;
u32 submitted_water_capacity;
Mat4 *submitted_instance_worlds;
LDKRHIColor *submitted_instance_colors;
u32 submitted_instance_count;
u32 submitted_instance_capacity;
u64 *mesh_sort_items;
u64 *mesh_sort_scratch;
u32 mesh_sort_capacity;
u32 *mesh_sort_mesh_ids;
u32 mesh_sort_mesh_id_capacity;
u32 *mesh_sort_material_ids;
u32 mesh_sort_material_id_capacity;
LDKRendererFrameStats current_frame_stats;
LDKRendererFrameStats last_frame_stats;
u64 animation_start_ticks;
float animation_time_seconds;
bool is_initialized;
}LDKRenderer;
LDKRendererBindingsCacheEntry
typedef struct LDKRendererBindingsCacheEntry{
LDKRHITexture texture;
LDKRHISampler sampler;
LDKRHIBindings bindings;
}LDKRendererBindingsCacheEntry;
LDKRendererBlurPass
typedef struct LDKRendererBlurPass{
LDKRHIContext *rhi;
LDKRHIShaderModule vertex_shader_module;
LDKRHIShaderModule fragment_shader_module;
LDKRHIBindingsLayout bindings_layout;
LDKRHIPipeline ldr_pipeline;
LDKRHIPipeline hdr_pipeline;
LDKRHIBuffer vertex_buffer;
LDKRHIBuffer params_buffer;
LDKRHISampler sampler;
bool is_initialized;
}LDKRendererBlurPass;
LDKRendererConfig
typedef struct LDKRendererConfig{
LDKRHIContext *rhi;
u32 initial_ui_vertex_capacity;
u32 initial_ui_index_capacity;
u32 game_width;
u32 game_height;
bool present_game;
u32 shadow_map_resolution;
float shadow_distance;
}LDKRendererConfig;
LDKRendererFrameDesc
typedef struct LDKRendererFrameDesc{
i32 framebuffer_width;
i32 framebuffer_height;
rgba32 clear_color;
bool clear_color_enabled;
}LDKRendererFrameDesc;
LDKRendererInstanceSetResource
typedef struct LDKRendererInstanceSetResource{
LDKRHIBuffer transform_buffer;
LDKRHIBuffer color_buffer;
u32 instance_count;
u32 instance_capacity;
bool alive;
}LDKRendererInstanceSetResource;
LDKRendererLineSubmit
typedef struct LDKRendererLineSubmit{
Mat4 world;
LDKRendererViewId view_id;
u32 color;
bool depth_test;
}LDKRendererLineSubmit;
LDKRendererPostProcessPass
typedef struct LDKRendererPostProcessPass{
LDKRHIContext *rhi;
LDKRHIShaderModule vertex_shader_module;
LDKRHIShaderModule fragment_shader_module;
LDKRHIBindingsLayout bindings_layout;
LDKRHIPipeline pipeline;
LDKRHIBuffer vertex_buffer;
LDKRHIBuffer params_buffer;
LDKRHISampler sampler;
bool is_initialized;
}LDKRendererPostProcessPass;
LDKRendererPostProcessing
typedef struct LDKRendererPostProcessing{
bool enabled;
bool tonemapping_enabled;
float exposure;
bool blur_enabled;
float blur_strength;
float blur_focus_x;
float blur_focus_y;
float blur_focus_size;
float blur_focus_feather;
bool blur_inverted;
bool color_enabled;
float brightness;
float contrast;
float saturation;
bool vignette_enabled;
float vignette_intensity;
float vignette_radius;
float vignette_softness;
bool screen_distortion_enabled;
float screen_distortion_strength;
bool chromatic_aberration_enabled;
float chromatic_aberration_strength;
bool heat_enabled;
float heat_strength;
float heat_amplitude;
float heat_scale;
float heat_speed;
bool inverse_enabled;
bool black_and_white_enabled;
bool retro_enabled;
float retro_pixel_size;
float retro_color_levels;
float retro_dither_strength;
float retro_pattern_scale;
bool drunk_enabled;
float drunk_strength;
float drunk_speed;
float drunk_ghosting;
float drunk_chromatic_aberration;
float drunk_movement;
}LDKRendererPostProcessing;
LDKRendererRenderKey
typedef u64 LDKRendererRenderKey;
LDKRendererTarget
typedef struct LDKRendererTarget{
LDKRHITexture color_texture;
LDKRHITexture depth_texture;
i32 width;
i32 height;
LDKRHIFormat color_format;
LDKRHIFormat depth_format;
}LDKRendererTarget;
LDKRendererTerrainSurfaceDesc
typedef struct LDKRendererTerrainSurfaceDesc{
float min_height;
float blend_width;
rgba32 color;
Vec4 atlas_rect;
Vec2 uv_scale;
float texture_weight;
}LDKRendererTerrainSurfaceDesc;
LDKRendererUIPass
typedef struct LDKRendererUIPass{
LDKRHIContext *rhi;
LDKRHIShaderModule vertex_shader_module;
LDKRHIShaderModule fragment_shader_module;
LDKRHIBindingsLayout bindings_layout;
LDKRHIPipeline pipeline;
LDKRHIBuffer vertex_buffer;
LDKRHIBuffer index_buffer;
LDKRHIBuffer params_buffer;
LDKRHITexture white_texture;
LDKRHISampler sampler;
LDKRendererBindingsCacheEntry *bindings_cache;
u32 bindings_cache_count;
u32 bindings_cache_capacity;
u32 vertex_capacity;
u32 index_capacity;
bool is_initialized;
}LDKRendererUIPass;
LDKRendererWireframeSubmit
typedef struct LDKRendererWireframeSubmit{
LDKResourceMesh mesh;
Mat4 world;
LDKRendererViewId view_id;
u32 color;
float line_width;
u32 flags;
}LDKRendererWireframeSubmit;
LDKShader
typedef enum LDKShader{
LDK_SHADER_INVALID=0,
LDK_SHADER_UI_PASS,
LDK_SHADER_TEXT_PASS,
LDK_SHADER_MESH_PASS,
LDK_SHADER_PRESENT_PASS,
LDK_SHADER_MESH_PASS_INSTANCED,
LDK_SHADER_GRID_PASS,
LDK_SHADER_MESH_PASS_UNLIT,
LDK_SHADER_MESH_PASS_TEXTURED,
LDK_SHADER_MESH_PASS_TEXTURED_UNLIT,
LDK_SHADER_SHADOW_PASS,
LDK_SHADER_MESH_PASS_TEXTURED_CUTOUT,
LDK_SHADER_MESH_PASS_TEXTURED_UNLIT_CUTOUT,
LDK_SHADER_SHADOW_PASS_CUTOUT,
LDK_SHADER_SHADOW_PASS_INSTANCED,
LDK_SHADER_SHADOW_PASS_CUTOUT_INSTANCED,
LDK_SHADER_VEGETATION_PASS,
LDK_SHADER_VEGETATION_PASS_INSTANCED,
LDK_SHADER_SHADOW_PASS_VEGETATION,
LDK_SHADER_SHADOW_PASS_VEGETATION_INSTANCED,
LDK_SHADER_POST_PROCESS_PASS,
LDK_SHADER_BLUR_PASS,
LDK_SHADER_SKYBOX_PASS,
LDK_SHADER_MESH_PASS_SOLID_UNLIT,
LDK_SHADER_TERRAIN_PASS,
LDK_SHADER_WATER_PASS
}LDKShader;
LDK_RENDERER_ALLOC
#define LDK_RENDERER_ALLOC(size) malloc(size)
LDK_RENDERER_FREE
#define LDK_RENDERER_FREE(ptr) free(ptr)
LDK_RENDERER_REALLOC
#define LDK_RENDERER_REALLOC(ptr, size) realloc(ptr, size)
LDK_RENDERER_TERRAIN_SURFACE_COUNT
#define LDK_RENDERER_TERRAIN_SURFACE_COUNT 8u
ldk_renderer_initialize
Initialize the renderer.
LDK_API bool ldk_renderer_initialize(
LDKRenderer *renderer,
LDKRendererConfig const *config
);
Returns
True if the operation succeeds; false otherwise.
ldk_renderer_terminate
Terminate the renderer and release renderer-owned resources.
This destroys all renderer-owned GPU resources, including mesh buffers,
texture resources, font page textures, render targets, pass buffers,
bindings, pipelines, samplers, and shader modules.
CPU-side assets are not destroyed by this function. Assets remain owned by
the asset manager or by whoever created them.
The RHI context must still be alive when this function is called.
LDK_API void ldk_renderer_terminate(LDKRenderer *renderer);
Parameters
LDKRenderer *renderer
- Renderer instance to terminate.