LDK_RENDERER_ALLOC
#define LDK_RENDERER_ALLOC(size) malloc(size)
LDK engine renderer.
API agnostic renderer built on top of ldk_rhi.
#define LDK_RENDERER_ALLOC(size) malloc(size)
#define LDK_RENDERER_FREE(ptr) free(ptr)
#define LDK_RENDERER_REALLOC(ptr, size) realloc(ptr, size)
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;
typedef struct LDKRendererMeshDesc{
const LDKMeshVertex *vertices;
u32 vertex_count;
const u32 *indices;
u32 index_count;
bool has_tangents;
}LDKRendererMeshDesc;
typedef struct LDKRendererMeshResource{
LDKRHIBuffer vertex_buffer;
LDKRHIBuffer index_buffer;
u32 vertex_count;
u32 index_count;
u32 vertex_capacity;
u32 index_capacity;
LDKAssetMesh source_asset;
u32 source_mesh_index;
u32 ref_count;
bool shared_asset_mesh;
bool alive;
}LDKRendererMeshResource;
typedef struct LDKRendererInstanceSetResource{
LDKRHIBuffer transform_buffer;
LDKRHIBuffer color_buffer;
u32 instance_count;
u32 instance_capacity;
bool alive;
}LDKRendererInstanceSetResource;
typedef u64 LDKRendererViewId;
#define LDK_RENDERER_VIEW_INVALID((LDKRendererViewId)0)
#define LDK_RENDERER_VIEW_ALL((LDKRendererViewId)UINT64_MAX)
#define LDK_RENDERER_WATER_WAVE_COUNT 3u
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;
typedef struct LDKRendererWaterWave{
float height;
float length;
float speed;
float direction_degrees;
}LDKRendererWaterWave;
typedef struct LDKRendererWaterDesc{
float water_level;
rgba32 shallow_color;
rgba32 deep_color;
float depth_color_distance;
float edge_fade_distance;
LDKRendererWaterWave waves[LDK_RENDERER_WATER_WAVE_COUNT];
float detail_scale;
float detail_strength;
float detail_speed;
float specular;
float shininess;
rgba32 foam_color;
float foam_width;
float foam_strength;
float foam_scale;
float shore_range;
float shore_wave_length;
float shore_wave_speed;
float shore_foam_strength;
LDKResourceTexture textures[LDK_RENDERER_WATER_TEXTURE_COUNT];
float noise_scale;
float noise_speed;
float distortion_strength;
float foam_speed;
float foam_cutoff;
float surface_foam_strength;
float caustics_scale;
float caustics_strength;
float caustics_speed;
float caustics_depth;
float time_seconds;
}LDKRendererWaterDesc;
typedef struct LDKRendererWaterSubmit{
LDKResourceMesh mesh;
LDKRendererViewId view_id;
LDKRendererWaterDesc desc;
}LDKRendererWaterSubmit;
typedef struct LDKRendererWaterPass{
LDKRHIContext *rhi;
LDKRHIShaderModule vertex_shader_module;
LDKRHIShaderModule fragment_shader_module;
LDKRHIBindingsLayout bindings_layout;
LDKRHIPipeline ldr_pipeline;
LDKRHIPipeline hdr_pipeline;
LDKRHIBuffer params_buffer;
LDKRHISampler depth_sampler;
LDKRHISampler texture_sampler;
LDKRHITexture fallback_texture;
bool is_initialized;
}LDKRendererWaterPass;
#define LDK_RENDERER_MAX_LIGHTS_PER_VIEW 16
typedef enum LDKRendererLightType{
LDK_RENDERER_LIGHT_POINT=0,
LDK_RENDERER_LIGHT_SPOT,
LDK_RENDERER_LIGHT_DIRECTIONAL
}LDKRendererLightType;
typedef struct LDKRendererLightSubmit{
LDKRendererLightType type;
LDKRendererViewId view_id;
Vec3 position;
Vec3 direction;
u32 color;
float intensity;
float range;
float inner_angle;
float outer_angle;
bool casts_shadows;
}LDKRendererLightSubmit;
typedef struct LDKRendererAmbientLight{
u32 color;
float intensity;
}LDKRendererAmbientLight;
typedef enum LDKRendererMeshSubmitFlag{
LDK_RENDERER_MESH_SUBMIT_FLAG_NONE=0,
LDK_RENDERER_MESH_SUBMIT_FLAG_OVERLAY=1<<0,
LDK_RENDERER_MESH_SUBMIT_FLAG_CAST_SHADOWS=1<<1,
LDK_RENDERER_MESH_SUBMIT_FLAG_BILLBOARD=1<<2,
LDK_RENDERER_MESH_SUBMIT_FLAG_SCREEN_SPACE=1<<3
}LDKRendererMeshSubmitFlag;
typedef struct LDKRendererMeshSubmit{
LDKResourceMesh mesh;
LDKResourceMaterial material;
u32 first_index;
u32 index_count;
Mat4 world;
LDKRendererViewId view_id;
u32 flags;
u32 instance_offset;
u32 instance_count;
LDKResourceInstanceSet instance_set;
Vec4 uv_rect;
}LDKRendererMeshSubmit;
typedef struct LDKRendererLineSubmit{
Mat4 world;
LDKRendererViewId view_id;
u32 color;
bool depth_test;
}LDKRendererLineSubmit;
typedef struct LDKRendererWireframeSubmit{
LDKResourceMesh mesh;
Mat4 world;
LDKRendererViewId view_id;
u32 color;
float line_width;
u32 flags;
}LDKRendererWireframeSubmit;
typedef enum LDKRendererTextSubmitFlag{
LDK_RENDERER_TEXT_SUBMIT_FLAG_NONE=0,
LDK_RENDERER_TEXT_SUBMIT_FLAG_BILLBOARD=1<<0,
LDK_RENDERER_TEXT_SUBMIT_FLAG_NO_DEPTH_TEST=1<<1
}LDKRendererTextSubmitFlag;
typedef struct LDKRendererTextVertex{
float x;
float y;
float u;
float v;
u32 color;
}LDKRendererTextVertex;
typedef struct LDKRendererTextSubmit{
Mat4 world;
LDKRendererViewId view_id;
LDKRHITexture texture;
u32 index_offset;
u32 index_count;
u32 flags;
}LDKRendererTextSubmit;
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;
typedef struct LDKRendererFrameDesc{
i32 framebuffer_width;
i32 framebuffer_height;
rgba32 clear_color;
bool clear_color_enabled;
}LDKRendererFrameDesc;
typedef struct LDKRendererFrameDomainStats{
u32 rendered_view_count;
u32 opaque_mesh_render_count;
u32 overlay_mesh_render_count;
u32 batch_count;
u32 instanced_batch_count;
u32 instanced_instance_count;
u32 max_batch_size;
u32 draw_call_count;
u32 opaque_mesh_draw_call_count;
u32 overlay_mesh_draw_call_count;
u32 shadow_draw_call_count;
u32 line_draw_call_count;
u32 grid_draw_call_count;
u32 skybox_draw_call_count;
u32 ui_draw_call_count;
u32 present_draw_call_count;
}LDKRendererFrameDomainStats;
typedef struct LDKRendererFrameStats{
double cpu_time_ms;
LDKRHIFrameStats rhi;
u32 rendered_view_count;
u32 mesh_submit_count;
u32 opaque_mesh_render_count;
u32 overlay_mesh_render_count;
u32 batch_count;
u32 instanced_batch_count;
u32 instanced_instance_count;
u32 max_batch_size;
u32 draw_call_count;
u32 opaque_mesh_draw_call_count;
u32 overlay_mesh_draw_call_count;
u32 shadow_draw_call_count;
u32 line_draw_call_count;
u32 grid_draw_call_count;
u32 skybox_draw_call_count;
u32 ui_draw_call_count;
u32 present_draw_call_count;
LDKRendererFrameDomainStats game;
LDKRendererFrameDomainStats non_game;
}LDKRendererFrameStats;
typedef struct LDKRendererBindingsCacheEntry{
LDKRHITexture texture;
LDKRHISampler sampler;
LDKRHIBindings bindings;
}LDKRendererBindingsCacheEntry;
typedef struct LDKRendererMeshBindingsCacheEntry{
LDKRHITexture textures[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
LDKRHISampler samplers[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
LDKRHIBindings bindings;
}LDKRendererMeshBindingsCacheEntry;
typedef struct LDKRendererTextPass{
LDKRHIContext *rhi;
LDKRHIShaderModule vertex_shader_module;
LDKRHIShaderModule fragment_shader_module;
LDKRHIBindingsLayout bindings_layout;
LDKRHIPipeline ldr_pipeline;
LDKRHIPipeline hdr_pipeline;
LDKRHIPipeline ldr_no_depth_pipeline;
LDKRHIPipeline hdr_no_depth_pipeline;
LDKRHIBuffer vertex_buffer;
LDKRHIBuffer index_buffer;
LDKRHIBuffer camera_buffer;
LDKRHIBuffer object_buffer;
LDKRHISampler sampler;
LDKRendererBindingsCacheEntry *bindings_cache;
u32 bindings_cache_count;
u32 bindings_cache_capacity;
u32 vertex_capacity;
u32 index_capacity;
bool is_initialized;
}LDKRendererTextPass;
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;
typedef struct LDKRendererShadowPass{
u32 resolution;
float distance;
LDKRHIContext *rhi;
LDKRHIShaderModule vertex_shader_module;
LDKRHIShaderModule fragment_shader_module;
LDKRHIShaderModule cutout_vertex_shader_module;
LDKRHIShaderModule cutout_fragment_shader_module;
LDKRHIShaderModule instanced_vertex_shader_module;
LDKRHIShaderModule cutout_instanced_vertex_shader_module;
LDKRHIShaderModule vegetation_vertex_shader_module;
LDKRHIShaderModule vegetation_instanced_vertex_shader_module;
LDKRHIBindingsLayout bindings_layout;
LDKRHIPipeline pipeline;
LDKRHIPipeline cutout_pipeline;
LDKRHIPipeline instanced_pipeline;
LDKRHIPipeline cutout_instanced_pipeline;
LDKRHIPipeline vegetation_pipeline;
LDKRHIPipeline vegetation_instanced_pipeline;
LDKRHIBuffer camera_buffer;
LDKRHIBuffer object_buffer;
LDKRHIBuffer material_buffer;
LDKRHIBuffer instance_buffer;
LDKRHIBuffer instance_uv_buffer;
u32 instance_capacity;
LDKRHIBindings bindings;
LDKRHIBindings vegetation_bindings;
LDKRendererBindingsCacheEntry *cutout_bindings_cache;
u32 cutout_bindings_cache_count;
u32 cutout_bindings_cache_capacity;
LDKRHITexture depth_texture;
LDKRHISampler sampler;
}LDKRendererShadowPass;
typedef struct LDKRendererMeshPass{
LDKRHIContext *rhi;
LDKRHIShaderModule vertex_shader_module;
LDKRHIShaderModule instanced_vertex_shader_module;
LDKRHIShaderModule fragment_shader_module;
LDKRHIShaderModule overlay_fragment_shader_module;
LDKRHIShaderModule solid_unlit_fragment_shader_module;
LDKRHIShaderModule textured_fragment_shader_module;
LDKRHIShaderModule textured_unlit_fragment_shader_module;
LDKRHIShaderModule textured_cutout_fragment_shader_module;
LDKRHIShaderModule textured_unlit_cutout_fragment_shader_module;
LDKRHIShaderModule vegetation_vertex_shader_module;
LDKRHIShaderModule vegetation_instanced_vertex_shader_module;
LDKRHIShaderModule vegetation_fragment_shader_module;
LDKRHIShaderModule terrain_vertex_shader_module;
LDKRHIShaderModule terrain_fragment_shader_module;
LDKRHIBindingsLayout bindings_layout;
LDKRHIPipeline vertex_color_pipeline;
LDKRHIPipeline vertex_color_unlit_pipeline;
LDKRHIPipeline vertex_color_blend_pipeline;
LDKRHIPipeline vertex_color_unlit_blend_pipeline;
LDKRHIPipeline overlay_pipeline;
LDKRHIPipeline wireframe_pipeline;
LDKRHIPipeline textured_pipeline;
LDKRHIPipeline textured_unlit_pipeline;
LDKRHIPipeline textured_overlay_pipeline;
LDKRHIPipeline textured_cutout_pipeline;
LDKRHIPipeline textured_unlit_cutout_pipeline;
LDKRHIPipeline textured_unlit_cutout_overlay_pipeline;
LDKRHIPipeline textured_blend_pipeline;
LDKRHIPipeline textured_unlit_blend_pipeline;
LDKRHIPipeline vertex_color_instanced_pipeline;
LDKRHIPipeline vertex_color_unlit_instanced_pipeline;
LDKRHIPipeline vertex_color_blend_instanced_pipeline;
LDKRHIPipeline vertex_color_unlit_blend_instanced_pipeline;
LDKRHIPipeline textured_instanced_pipeline;
LDKRHIPipeline textured_unlit_instanced_pipeline;
LDKRHIPipeline textured_cutout_instanced_pipeline;
LDKRHIPipeline textured_unlit_cutout_instanced_pipeline;
LDKRHIPipeline textured_blend_instanced_pipeline;
LDKRHIPipeline textured_unlit_blend_instanced_pipeline;
LDKRHIPipeline vegetation_pipeline;
LDKRHIPipeline vegetation_instanced_pipeline;
LDKRHIPipeline terrain_pipeline;
LDKRHIBuffer camera_buffer;
LDKRHIBuffer object_buffer;
LDKRHIBuffer material_buffer;
LDKRHIBuffer lighting_buffer;
LDKRHIBuffer instance_buffer;
LDKRHIBuffer instance_color_buffer;
LDKRHIBuffer instance_uv_buffer;
u32 instance_capacity;
Mat4 *staging_worlds;
LDKRHIColor *staging_colors;
Vec4 *staging_uvs;
u32 staging_capacity;
LDKRHITexture shadow_texture;
LDKRHISampler shadow_sampler;
LDKRHITexture flat_normal_texture;
LDKRHITexture white_specular_texture;
LDKRHISampler fallback_sampler;
LDKRHIBindings bindings;
LDKRHIBindings vegetation_bindings;
LDKRendererMeshBindingsCacheEntry *material_bindings_cache;
u32 material_bindings_cache_count;
u32 material_bindings_cache_capacity;
bool is_initialized;
}LDKRendererMeshPass;
typedef struct LDKRendererGridPass{
LDKRHIContext *rhi;
LDKRHIShaderModule vertex_shader_module;
LDKRHIShaderModule fragment_shader_module;
LDKRHIBindingsLayout bindings_layout;
LDKRHIPipeline pipeline;
LDKRHIBuffer vertex_buffer;
LDKRHIBuffer params_buffer;
LDKRHIBindings bindings;
bool is_initialized;
}LDKRendererGridPass;
typedef struct LDKRendererSkyboxPass{
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;
bool is_initialized;
}LDKRendererSkyboxPass;
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;
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;
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;
typedef struct LDKRendererFontPageCacheEntry{
LDKFontInstance *font;
u32 page_index;
u32 width;
u32 height;
LDKRHITexture texture;
}LDKRendererFontPageCacheEntry;
typedef struct LDKRendererFontPage{
LDKFontInstance *font;
u32 page_index;
u32 width;
u32 height;
LDKRHITexture texture;
}LDKRendererFontPage;
typedef struct LDKRendererTarget{
LDKRHITexture color_texture;
LDKRHITexture depth_texture;
i32 width;
i32 height;
LDKRHIFormat color_format;
LDKRHIFormat depth_format;
}LDKRendererTarget;
typedef struct LDKRendererView{
LDKRendererViewId id;
Mat4 view;
Mat4 projection;
Vec4 frustum_planes[6];
u32 width;
u32 height;
u32 requested_width;
u32 requested_height;
bool extent_override;
LDKRendererTarget target;
LDKRendererTarget overlay_target;
LDKRHITexture post_process_texture;
LDKRHIBindings post_process_bindings;
LDKRHITexture post_process_input_texture;
LDKRHITexture post_process_blurred_texture;
LDKRHITexture post_process_blur_textures[2];
LDKRHIBindings post_process_blur_bindings[2];
LDKRHITexture post_process_blur_input_textures[2];
LDKRHIFormat post_process_blur_format;
LDKRendererPostProcessing post_processing;
rgba32 clear_color;
bool clear_color_set;
bool separate_overlay;
Vec3 grid_center;
float grid_extent;
float grid_spacing;
bool grid_submitted;
LDKResourceSkybox skybox;
bool submitted;
bool frustum_valid;
}LDKRendererView;
typedef enum LDKRendererTextureFlag{
LDK_RENDERER_TEXTURE_FLAG_NONE=0,
LDK_RENDERER_TEXTURE_FLAG_SRGB=1<<0,
LDK_RENDERER_TEXTURE_FLAG_RENDERABLE=1<<1
}LDKRendererTextureFlag;
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;
typedef struct LDKRendererTextureDesc{
u32 width;
u32 height;
u32 channel_count;
LDKRHIFormat format;
u32 flags;
void const *pixels;
u64 byte_count;
LDKRendererTextureOptions const *options;
}LDKRendererTextureDesc;
typedef struct LDKRendererSkyboxResource{
LDKRHITexture texture;
LDKRHISampler sampler;
LDKRHIBindings bindings;
u32 size;
bool alive;
}LDKRendererSkyboxResource;
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;
#define LDK_RENDERER_TERRAIN_SURFACE_COUNT 8u
typedef struct LDKRendererTerrainSurfaceDesc{
float min_height;
float blend_width;
rgba32 color;
Vec4 atlas_rect;
Vec2 uv_scale;
float texture_weight;
}LDKRendererTerrainSurfaceDesc;
typedef struct LDKRendererMaterialDesc{
LDKMaterialType type;
LDKResourceTexture texture;
LDKResourceTexture normal_map;
LDKResourceTexture specular_map;
LDKResourceTexture additional_textures[LDK_MATERIAL_ADDITIONAL_TEXTURE_COUNT];
rgba32 color;
LDKMaterialAlphaMode alpha_mode;
float alpha_cutoff;
float specular;
float shininess;
float emission;
float vegetation_curvature;
float vegetation_wind_strength;
float vegetation_wind_speed;
float vegetation_wind_direction;
float vegetation_interaction_recovery_time;
bool vegetation;
bool terrain;
u32 terrain_surface_count;
LDKRendererTerrainSurfaceDesc terrain_surfaces[LDK_RENDERER_TERRAIN_SURFACE_COUNT];
}LDKRendererMaterialDesc;
typedef enum LDKRendererMaterialSelection{
LDK_RENDERER_MATERIAL_SELECTION_INVALID=0,
LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_UNLIT,
LDK_RENDERER_MATERIAL_SELECTION_TEXTURED,
LDK_RENDERER_MATERIAL_SELECTION_VERTEX_COLOR_UNLIT,
LDK_RENDERER_MATERIAL_SELECTION_VERTEX_COLOR,
LDK_RENDERER_MATERIAL_SELECTION_VERTEX_COLOR_UNLIT_BLEND,
LDK_RENDERER_MATERIAL_SELECTION_VERTEX_COLOR_BLEND,
LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_UNLIT_CUTOUT,
LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_CUTOUT,
LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_UNLIT_BLEND,
LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_BLEND,
LDK_RENDERER_MATERIAL_SELECTION_VEGETATION,
LDK_RENDERER_MATERIAL_SELECTION_TERRAIN
}LDKRendererMaterialSelection;
typedef u64 LDKRendererRenderKey;
typedef struct LDKRendererMaterialSamplerResource{
LDKRHISamplerDesc desc;
LDKRHISampler sampler;
}LDKRendererMaterialSamplerResource;
typedef struct LDKRendererMaterialResource{
LDKRendererMaterialDesc desc;
LDKRendererMaterialSelection selection;
LDKRendererRenderKey render_key;
LDKRHISampler texture_sampler;
LDKRHISampler texture_samplers[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
Vec2 texture_uv_scales[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
Vec2 texture_uv_offsets[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
bool owns_additional_textures;
u32 ref_count;
const struct LDKAssetManager *source_assets;
LDKMaterialDesc source_desc;
bool has_source_desc;
u64 source_atlas_revisions[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
Vec2 uv_scale;
Vec2 uv_offset;
bool alive;
}LDKRendererMaterialResource;
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;
Initialize defaults for renderer water.
LDK_API void ldk_renderer_water_desc_defaults(LDKRendererWaterDesc *desc);
LDKRendererWaterDesc *descCheck whether the renderer water desc is valid.
LDK_API bool ldk_renderer_water_desc_is_valid(const LDKRendererWaterDesc *desc);
const LDKRendererWaterDesc *descTrue when the queried condition holds; false otherwise.
Submit a horizontal world-space grid. XZ positions come from the mesh; the shader supplies Y using water_level and the three waves. Scene depth is sampled after opaque rendering. Meshes and optional textures remain caller-owned and must live until render_frame() completes. Overlapping water surfaces are composited in submission order; this path does not sort stacked water.
LDK_API bool ldk_renderer_submit_water(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceMesh mesh,
const LDKRendererWaterDesc *desc
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceMesh meshconst LDKRendererWaterDesc *descTrue if the operation succeeds; false otherwise.
Set constant ambient light applied to lit materials. Color uses 0xRRGGBBAA; alpha is ignored. Intensity must be finite and non-negative. Ambient light does not count toward the per-view light limit.
LDK_API bool ldk_renderer_ambient_light_set(
LDKRenderer *renderer,
u32 color,
float intensity
);
LDKRenderer *rendereru32 colorfloat intensityTrue if the operation succeeds; false otherwise.
Bind a world-space interaction field sampled by vegetation shaders.
LDK_API bool ldk_renderer_vegetation_interaction_set(
LDKRenderer *renderer,
LDKResourceTexture texture,
Vec2 world_origin,
float world_size
);
LDKRenderer *rendererLDKResourceTexture textureVec2 world_originfloat world_sizeTrue if the operation succeeds; false otherwise.
Disable the vegetation interaction field and release pass bindings.
LDK_API void ldk_renderer_vegetation_interaction_clear(LDKRenderer *renderer);
LDKRenderer *rendererSubmit an unlit, capped triangular prism from start to end. Thickness is the circumdiameter of its cross-section, in world units. Depth test also enables depth writes; false uses the overlay path. View may be ALL or an ID not yet submitted. Call on the render thread before render_frame; the queue is cleared after that frame is rendered. Zero-length segments succeed without drawing. Invalid/nonfinite data, nonpositive thickness and allocation failures return false.
LDK_API bool ldk_renderer_draw_line(
LDKRenderer *renderer,
LDKRendererViewId view_id,
Vec3 start,
Vec3 end,
float thickness,
u32 color,
bool depth_test
);
LDKRenderer *rendererLDKRendererViewId view_idVec3 startVec3 endfloat thicknessu32 colorbool depth_testTrue if the operation succeeds; false otherwise.
Submit UTF-8 text as unlit world-space geometry. Glyph layout, kerning and atlas placement are shared with the UI text path. Local text height is normalized by the font instance pixel height, so an identity world transform produces approximately one world unit per font height. The local origin is the top-left of the first line and local +Y is up. BILLBOARD preserves translation, XY roll and scale while facing the current camera. Text is alpha blended and does not write depth. Depth testing is enabled by default and can be disabled per submission with LDK_RENDERER_TEXT_SUBMIT_FLAG_NO_DEPTH_TEST. Views need not exist yet. The transient queue is cleared after the frame is rendered.
LDK_API bool ldk_renderer_submit_text(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKFontInstance *font,
char const *text,
Mat4 world,
u32 color,
u32 flags
);
LDKRenderer *rendererLDKRendererViewId view_idLDKFontInstance *fontchar const *textMat4 worldu32 coloru32 flagsTrue if the operation succeeds; false otherwise.
Submit transient world-space lighting. Views need not exist yet. The first 16 matching lights illuminate each view, in submission order. Returns false for invalid data or allocation failure.
LDK_API bool ldk_renderer_submit_light(
LDKRenderer *renderer,
const LDKRendererLightSubmit *light
);
LDKRenderer *rendererconst LDKRendererLightSubmit *lightTrue if the operation succeeds; false otherwise.
Set the renderer shadow settings.
LDK_API bool ldk_renderer_shadow_settings_set(
LDKRenderer *renderer,
u32 resolution,
float distance
);
LDKRenderer *rendereru32 resolutionfloat distanceTrue if the operation succeeds; false otherwise.
Initialize the renderer.
LDK_API bool ldk_renderer_initialize(
LDKRenderer *renderer,
LDKRendererConfig const *config
);
LDKRenderer *rendererLDKRendererConfig const *configTrue if the operation succeeds; false otherwise.
Change the default game render-target resolution. Views using the default game extent release their current render targets when the dimensions change. Views with an explicit per-view extent are not affected. New targets are created when those views are next submitted or rendered.
LDK_API bool ldk_renderer_game_resolution_set(
LDKRenderer *renderer,
u32 width,
u32 height
);
LDKRenderer *rendereru32 widthu32 heighttrue when the resolution is valid and was accepted.
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);
LDKRenderer *rendererRender one frame using the currently submitted renderer data. The renderer begins an RHI frame, renders the submitted scene meshes when a view is available, optionally presents the scene target, renders submitted UI data, and ends the RHI frame. Submitted per-frame data is consumed by this call. After rendering, the renderer clears transient submissions such as submitted meshes, submitted UI, and the active camera/view state.
LDK_API void ldk_renderer_render_frame(
LDKRenderer *renderer,
LDKRendererFrameDesc const *desc
);
LDKRenderer *rendererLDKRendererFrameDesc const *descReturn renderer statistics for the last fully completed frame. CPU time measures the elapsed CPU-side duration of ldk_renderer_render_frame(), including time spent inside RHI calls. It is not GPU time and may include waits performed by the backend. Rendered work is also split by destination. game contains work rendered into the configured game view (and direct game presentation/UI when present_game is enabled). non_game contains all other views and host UI. A VIEW_ALL submission is counted independently in each destination where it is actually rendered. mesh_submit_count remains global because a single submission may participate in both domains.
LDK_API LDKRendererFrameStats ldk_renderer_last_frame_stats_get(LDKRenderer const *renderer);
LDKRenderer const *rendererA snapshot of the previous completed renderer frame. A zeroed snapshot is returned for a null renderer or before the first frame.
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);
LDKRenderer const *rendererGame color texture handle, or an invalid handle when unavailable.
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
);
LDKRenderer const *rendererLDKRendererViewId view_idView color texture handle, or an invalid handle when unavailable.
Set the render-target extent requested for a view. The request is applied the next time the view is submitted. Until then the current render target remains unchanged, allowing editor resize operations to defer GPU resource churn until interaction has finished.
LDK_API bool ldk_renderer_view_extent_set(
LDKRenderer *renderer,
LDKRendererViewId view_id,
u32 width,
u32 height
);
LDKRenderer *rendererLDKRendererViewId view_idu32 widthu32 heighttrue when the request was accepted, false otherwise.
Get the effective extent that will be used by a renderer view. Views without an explicit extent use the game resolution. For an explicit view, this returns its requested extent, including a request that will be applied by the next ldk_renderer_submit_view() call.
LDK_API bool ldk_renderer_view_extent_get(
LDKRenderer const *renderer,
LDKRendererViewId view_id,
u32 *out_width,
u32 *out_height
);
LDKRenderer const *rendererLDKRendererViewId view_idu32 *out_widthu32 *out_heighttrue when a valid effective extent was returned.
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);
LDKRenderer const *rendererNormalized UV rectangle for sampling a renderer view texture.
Set post-processing configuration for a submitted view. The configuration is transient and must be supplied again after the view is submitted on each frame. Disabled post-processing bypasses the post-process pass and exposes the scene color target directly.
LDK_API bool ldk_renderer_view_post_processing_set(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKRendererPostProcessing const *post_processing
);
LDKRenderer *rendererLDKRendererViewId view_idLDKRendererPostProcessing const *post_processingtrue when the configuration was accepted, false otherwise.
Request an overlay texture associated with a renderer view.
LDK_API LDKUITextureHandle ldk_renderer_view_overlay_texture_request(
LDKRenderer *renderer,
LDKRendererViewId view_id
);
LDKRenderer *rendererLDKRendererViewId view_idHandle to the requested object or resource.
Return an invalid mesh resource handle. This is the renderer mesh equivalent of a null handle. It can be used to initialize mesh fields or to represent the absence of a mesh.
LDK_API LDKResourceMesh ldk_renderer_mesh_null(void);
Invalid mesh resource handle.
Check whether a mesh resource handle refers to a live renderer mesh. The handle is validated against the renderer that owns the mesh resource. A non-zero handle is not enough to prove validity; the resource must still exist in the renderer mesh cache.
LDK_API bool ldk_renderer_mesh_is_valid(
LDKRenderer *renderer,
LDKResourceMesh mesh
);
LDKRenderer *rendererLDKResourceMesh meshtrue if the mesh is valid and alive, false otherwise.
Create a renderer-owned mesh resource. The renderer uploads the supplied CPU-side vertex and index data into renderer-owned RHI buffers, stores those buffers in the renderer mesh cache, and returns a renderer resource handle. The source vertex and index arrays are only needed during creation. After the mesh is created, the returned resource does not depend on the original CPU buffers.
LDK_API LDKResourceMesh ldk_renderer_mesh_create(
LDKRenderer *renderer,
LDKRendererMeshDesc const *desc
);
LDKRenderer *rendererLDKRendererMeshDesc const *descMesh resource handle, or an invalid handle on failure.
Reuse geometry uploaded for the same immutable mesh asset/index.
LDK_API LDKResourceMesh ldk_renderer_mesh_asset_acquire(
LDKRenderer *renderer,
LDKAssetMesh asset,
u32 mesh_index,
const LDKRendererMeshDesc *desc
);
LDKRenderer *rendererLDKAssetMesh assetu32 mesh_indexconst LDKRendererMeshDesc *descHandle to the requested object or resource.
Update the renderer mesh.
LDK_API bool ldk_renderer_mesh_update(
LDKRenderer *renderer,
LDKResourceMesh mesh,
LDKRendererMeshDesc const *desc
);
LDKRenderer *rendererLDKResourceMesh meshLDKRendererMeshDesc const *descTrue if the operation succeeds; false otherwise.
Destroy a renderer-owned mesh resource. The renderer resolves the mesh handle, destroys the underlying RHI vertex and index buffers, and releases the renderer mesh cache slot. Destroying an invalid or already-dead mesh handle is a no-op. Mesh resources are also destroyed automatically when the renderer is terminated.
LDK_API void ldk_renderer_mesh_destroy(
LDKRenderer *renderer,
LDKResourceMesh mesh
);
LDKRenderer *rendererLDKResourceMesh meshInitialize 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);
LDKRendererTextureOptions *optionsReturn 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);
Invalid texture resource handle.
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
);
LDKRenderer *rendererLDKResourceTexture texturetrue if the texture is valid and alive, false otherwise.
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
);
LDKRenderer *rendererLDKResourceTexture textureUI texture handle for draw commands, or an invalid handle on failure.
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
);
LDKRenderer *rendererLDKRendererTextureDesc const *descTexture resource handle, or an invalid handle on failure.
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
);
LDKRenderer *rendererLDKResourceTexture texturevoid const *pixelsu64 byte_counttrue if the texture was updated, false otherwise.
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
);
LDKRenderer *rendererLDKResourceTexture textureCreate 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
);
LDKRenderer *rendererLDKImage const *imageLDKRendererTextureOptions const *optionsTexture resource handle, or an invalid handle on failure.
Return an invalid material resource handle.
LDK_API LDKResourceMaterial ldk_renderer_material_null(void);
Invalid material resource handle.
Acquire a renderer resource for an image asset.
LDK_API LDKResourceTexture ldk_renderer_image_acquire(
LDKRenderer *renderer,
struct LDKAssetManager *assets,
LDKAssetImage image
);
LDKRenderer *rendererstruct LDKAssetManager *assetsLDKAssetImage imageHandle to the requested object or resource.
Release a renderer resource acquired for an image asset.
LDK_API void ldk_renderer_image_release(
LDKRenderer *renderer,
LDKResourceTexture texture
);
LDKRenderer *rendererLDKResourceTexture textureResolve an authored material description into renderer resources. Textured materials acquire a shared renderer texture from the supplied asset manager. If the authored image is unavailable, the renderer uses the shared missing-image fallback. Shader-defined slots 3..7 are acquired the same way and are owned by the resolved material. Lit normal/specular maps are acquired when available; missing maps resolve to renderer-owned neutral fallbacks. Existing output resources are replaced only after the new material has been created successfully. The caller owns the returned material resource and one acquisition of each non-null returned image texture. A later successful resolve replaces those resources. Additional slots 3..7 are released by material destruction. The caller must destroy/release the remaining resources when its owner terminates.
LDK_API bool ldk_renderer_material_resolve(
LDKRenderer *renderer,
struct LDKAssetManager *assets,
LDKMaterialDesc const *material_desc,
LDKResourceMaterial *renderer_material,
LDKResourceTexture *renderer_texture,
LDKResourceTexture *renderer_normal_map,
LDKResourceTexture *renderer_specular_map
);
LDKRenderer *rendererstruct LDKAssetManager *assetsLDKMaterialDesc const *material_descLDKResourceMaterial *renderer_materialLDKResourceTexture *renderer_textureLDKResourceTexture *renderer_normal_mapLDKResourceTexture *renderer_specular_maptrue when the material was resolved successfully.
Resolve a normal authored material using TerrainSystem surface rules.
LDK_API bool ldk_renderer_terrain_material_resolve(
LDKRenderer *renderer,
struct LDKAssetManager *assets,
LDKMaterialDesc const *material_desc,
const LDKRendererTerrainSurfaceDesc *surfaces,
u32 surface_count,
LDKResourceMaterial *renderer_material,
LDKResourceTexture *renderer_texture,
LDKResourceTexture *renderer_normal_map,
LDKResourceTexture *renderer_specular_map
);
LDKRenderer *rendererstruct LDKAssetManager *assetsLDKMaterialDesc const *material_descconst LDKRendererTerrainSurfaceDesc *surfacesu32 surface_countLDKResourceMaterial *renderer_materialLDKResourceTexture *renderer_textureLDKResourceTexture *renderer_normal_mapLDKResourceTexture *renderer_specular_mapTrue if the operation succeeds; false otherwise.
Test whether a resolved material still matches its atlas revisions. A changed atlas may have a different backing image or region geometry.
LDK_API bool ldk_renderer_material_atlases_current(
LDKRenderer *renderer,
struct LDKAssetManager *assets,
LDKResourceMaterial material
);
LDKRenderer *rendererstruct LDKAssetManager *assetsLDKResourceMaterial materialTrue if the operation succeeds; false otherwise.
Check whether the renderer material is valid.
LDK_API bool ldk_renderer_material_is_valid(
LDKRenderer *renderer,
LDKResourceMaterial material
);
LDKRenderer *rendererLDKResourceMaterial materialTrue when the queried condition holds; false otherwise.
Create a renderer-owned material resource. Textured materials require a live renderer texture. The referenced texture must remain alive until the material is destroyed. Textured materials may use opaque or cutout alpha mode; cutout thresholds must be finite and in [0, 1]. Lit normal/specular maps and shader-defined slots 3..7 are optional borrowed texture resources and must remain alive while the material exists; null map handles use renderer-owned neutral fallbacks. Vertex-color materials ignore texture and alpha fields. Unlit materials ignore map handles. Lit surface values must be finite and non-negative. A zero shininess uses the default value (32).
LDK_API LDKResourceMaterial ldk_renderer_material_create(
LDKRenderer *renderer,
LDKRendererMaterialDesc const *desc
);
LDKRenderer *rendererLDKRendererMaterialDesc const *descNew material handle, or an invalid handle on failure.
Destroy a renderer-owned material resource. Destroying an invalid or already-dead material is a no-op. Material resources are also destroyed automatically when the renderer terminates.
LDK_API void ldk_renderer_material_destroy(
LDKRenderer *renderer,
LDKResourceMaterial material
);
LDKRenderer *rendererLDKResourceMaterial materialReturn the renderer-owned default mesh material. The default material is a white vertex-color material created during renderer initialization and destroyed during renderer termination.
LDK_API LDKResourceMaterial ldk_renderer_material_default_get(LDKRenderer *renderer);
LDKRenderer *rendererDefault material handle, or an invalid handle when unavailable.
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
);
LDKRenderer *rendererLDKFontInstance *fontu32 page_indexUI texture handle for the atlas page, or an invalid handle on failure.
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
);
void *userLDKFontInstance *fontu32 page_indexUI texture handle for the atlas page, or an invalid handle on failure.
Submit a camera view used for scene rendering this frame. The renderer stores the view and projection matrices as transient frame state. Submitted meshes will be rendered using this view when ldk_renderer_render_frame() is called. The submitted view is consumed for the current frame only. After rendering, the renderer clears the active view state.
LDK_API bool ldk_renderer_submit_view(
LDKRenderer *renderer,
LDKRendererViewId view_id,
Mat4 view,
Mat4 projection
);
LDKRenderer *rendererLDKRendererViewId view_idMat4 viewMat4 projectiontrue if the view was submitted, false otherwise.
Override the clear color used by a submitted view this frame. This is transient view state and must be set again after submit_view on each frame. Alpha is preserved, allowing transparent camera backgrounds.
LDK_API bool ldk_renderer_view_clear_color_set(
LDKRenderer *renderer,
LDKRendererViewId view_id,
rgba32 clear_color
);
LDKRenderer *rendererLDKRendererViewId view_idrgba32 clear_colorTrue if the operation succeeds; false otherwise.
Select the submitted view used as the game output. The selected view is returned by ldk_renderer_game_texture_get() and is presented directly when the renderer was configured with present_game. The selection is transient and must be set again on every frame.
LDK_API bool ldk_renderer_game_view_set(
LDKRenderer *renderer,
LDKRendererViewId view_id
);
LDKRenderer *rendererLDKRendererViewId view_idtrue if the submitted view exists, false otherwise.
Submit UI render data for the current frame. The renderer stores a pointer to the supplied UI render data and renders it during ldk_renderer_render_frame(). The render data is not copied, so it must remain valid until the frame is rendered. After rendering, the renderer clears the submitted UI pointer.
LDK_API void ldk_renderer_submit_ui(
LDKRenderer *renderer,
LDKUIRenderData const *render_data
);
LDKRenderer *rendererLDKUIRenderData const *render_dataExplicit instancing, one submission per mesh/range and matrix array. Matrices are copied during this call and may be released immediately. parent_world transforms each supplied local matrix into world space; pass identity when supplying final world matrices. view_id accepts ALL. index_count must be nonzero. Zero instances is a successful no-op with valid resources/range. Invalid data/allocation failure queues nothing. Ordinary submits never use instancing. Unsupported instancing falls back to one ordinary draw per instance, including ordered overlays.
LDK_API bool ldk_renderer_submit_mesh_instances(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceMesh mesh,
LDKResourceMaterial material,
u32 first_index,
u32 index_count,
Mat4 parent_world,
const Mat4 *instances,
u32 instance_count,
u32 flags
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceMesh meshLDKResourceMaterial materialu32 first_indexu32 index_countMat4 parent_worldconst Mat4 *instancesu32 instance_countu32 flagsTrue if the operation succeeds; false otherwise.
Explicit instancing with one optional RGBA tint per instance. Colors use 0xRRGGBBAA and are copied together with the instance transforms. A NULL color array means opaque white for every instance.
LDK_API bool ldk_renderer_submit_mesh_instances_colored(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceMesh mesh,
LDKResourceMaterial material,
u32 first_index,
u32 index_count,
Mat4 parent_world,
const Mat4 *instances,
const u32 *instance_colors,
u32 instance_count,
u32 flags
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceMesh meshLDKResourceMaterial materialu32 first_indexu32 index_countMat4 parent_worldconst Mat4 *instancesconst u32 *instance_colorsu32 instance_countu32 flagsTrue if the operation succeeds; false otherwise.
Persistent world-space instances uploaded only when the set changes.
LDK_API LDKResourceInstanceSet ldk_renderer_instance_set_create(
LDKRenderer *renderer,
const Mat4 *instances,
u32 instance_count
);
LDKRenderer *rendererconst Mat4 *instancesu32 instance_countHandle to the requested object or resource.
Update the renderer instance set.
LDK_API bool ldk_renderer_instance_set_update(
LDKRenderer *renderer,
LDKResourceInstanceSet instance_set,
const Mat4 *instances,
u32 instance_count
);
LDKRenderer *rendererLDKResourceInstanceSet instance_setconst Mat4 *instancesu32 instance_countTrue if the operation succeeds; false otherwise.
Destroy the renderer instance set.
LDK_API void ldk_renderer_instance_set_destroy(
LDKRenderer *renderer,
LDKResourceInstanceSet instance_set
);
LDKRenderer *rendererLDKResourceInstanceSet instance_setReturn an invalid handle for the renderer instance set.
LDK_API LDKResourceInstanceSet ldk_renderer_instance_set_null(void);
An invalid or empty handle.
Check whether the renderer instance set is valid.
LDK_API bool ldk_renderer_instance_set_is_valid(
LDKRenderer *renderer,
LDKResourceInstanceSet instance_set
);
LDKRenderer *rendererLDKResourceInstanceSet instance_setTrue when the queried condition holds; false otherwise.
Submit one persistent instance set without copying its transforms.
LDK_API bool ldk_renderer_submit_mesh_instance_set(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceMesh mesh,
LDKResourceMaterial material,
u32 first_index,
u32 index_count,
LDKResourceInstanceSet instance_set,
u32 flags
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceMesh meshLDKResourceMaterial materialu32 first_indexu32 index_countLDKResourceInstanceSet instance_setu32 flagsTrue if the operation succeeds; false otherwise.
Submit a contiguous range of a persistent instance set.
LDK_API bool ldk_renderer_submit_mesh_instance_set_range(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceMesh mesh,
LDKResourceMaterial material,
u32 first_index,
u32 index_count,
LDKResourceInstanceSet instance_set,
u32 first_instance,
u32 instance_count,
u32 flags
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceMesh meshLDKResourceMaterial materialu32 first_indexu32 index_countLDKResourceInstanceSet instance_setu32 first_instanceu32 instance_countu32 flagsTrue if the operation succeeds; false otherwise.
True when an AABB is visible to the selected submitted view. VIEW_ALL tests every submitted view and succeeds when any view intersects it. Invalid bounds or unavailable frusta fail open and return true.
LDK_API bool ldk_renderer_view_bounds_visible(
const LDKRenderer *renderer,
LDKRendererViewId view_id,
Vec3 bounds_min,
Vec3 bounds_max
);
const LDKRenderer *rendererLDKRendererViewId view_idVec3 bounds_minVec3 bounds_maxTrue if the operation succeeds; false otherwise.
Submit a mesh instance for scene rendering this frame. The mesh and material handles are validated against their renderer caches, then queued with the supplied world transform. The queued mesh is rendered during ldk_renderer_render_frame() for every submitted view. Submitted mesh instances are transient frame data. After rendering, the renderer clears the submitted mesh queue.
LDK_API bool ldk_renderer_submit_mesh(
LDKRenderer *renderer,
LDKResourceMesh mesh,
LDKResourceMaterial material,
Mat4 world
);
LDKRenderer *rendererLDKResourceMesh meshLDKResourceMaterial materialMat4 worldtrue if the mesh was submitted, false otherwise.
Submit renderer mesh with flags.
LDK_API bool ldk_renderer_submit_mesh_with_flags(
LDKRenderer *renderer,
LDKResourceMesh mesh,
LDKResourceMaterial material,
Mat4 world,
u32 flags
);
LDKRenderer *rendererLDKResourceMesh meshLDKResourceMaterial materialMat4 worldu32 flagsTrue if the operation succeeds; false otherwise.
Submit renderer mesh range with flags.
LDK_API bool ldk_renderer_submit_mesh_range_with_flags(
LDKRenderer *renderer,
LDKResourceMesh mesh,
LDKResourceMaterial material,
u32 first_index,
u32 index_count,
Mat4 world,
u32 flags
);
LDKRenderer *rendererLDKResourceMesh meshLDKResourceMaterial materialu32 first_indexu32 index_countMat4 worldu32 flagsTrue if the operation succeeds; false otherwise.
Submit a contiguous index range of a mesh for scene rendering. This is the ranged form of ldk_renderer_submit_mesh(). The mesh resource remains independent of material topology; callers use this function to submit an individual submesh with its resolved material.
LDK_API bool ldk_renderer_submit_mesh_range(
LDKRenderer *renderer,
LDKResourceMesh mesh,
LDKResourceMaterial material,
u32 first_index,
u32 index_count,
Mat4 world
);
LDKRenderer *rendererLDKResourceMesh meshLDKResourceMaterial materialu32 first_indexu32 index_countMat4 worldtrue if the mesh range was queued, false otherwise.
Submit a mesh instance to a single render view for this frame. Unlike ldk_renderer_submit_mesh(), this mesh is only drawn while rendering the view identified by view_id. This is intended for view-local scene content that must not appear in other views. The view does not need to have been submitted before this call. If no view with the supplied ID is submitted during the frame, the mesh is not drawn.
LDK_API bool ldk_renderer_submit_mesh_to_view(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceMesh mesh,
LDKResourceMaterial material,
Mat4 world
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceMesh meshLDKResourceMaterial materialMat4 worldtrue if the mesh was queued, false otherwise.
Return an invalid handle for the renderer skybox.
LDK_API LDKResourceSkybox ldk_renderer_skybox_null(void);
An invalid or empty handle.
Check whether the renderer skybox is valid.
LDK_API bool ldk_renderer_skybox_is_valid(
LDKRenderer *renderer,
LDKResourceSkybox skybox
);
LDKRenderer *rendererLDKResourceSkybox skyboxTrue when the queried condition holds; false otherwise.
Create the renderer skybox.
LDK_API LDKResourceSkybox ldk_renderer_skybox_create(
LDKRenderer *renderer,
struct LDKAssetManager *assets,
const LDKSkyboxDesc *desc
);
LDKRenderer *rendererstruct LDKAssetManager *assetsconst LDKSkyboxDesc *descHandle to the requested object or resource.
Destroy the renderer skybox.
LDK_API void ldk_renderer_skybox_destroy(
LDKRenderer *renderer,
LDKResourceSkybox skybox
);
LDKRenderer *rendererLDKResourceSkybox skyboxSubmit renderer skybox to view.
LDK_API bool ldk_renderer_submit_skybox_to_view(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceSkybox skybox
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceSkybox skyboxTrue if the operation succeeds; false otherwise.
Submit a procedural ground grid to a single render view. The grid is rendered after regular scene meshes and before overlay meshes, with depth testing enabled and depth writes disabled. Its visible area is centered on grid_center and fades before reaching grid_extent.
LDK_API bool ldk_renderer_submit_grid_to_view(
LDKRenderer *renderer,
LDKRendererViewId view_id,
Vec3 grid_center,
float grid_extent,
float grid_spacing
);
LDKRenderer *rendererLDKRendererViewId view_idVec3 grid_centerfloat grid_extentfloat grid_spacingtrue if the grid was submitted, false otherwise.
Submit a mesh as a view-local overlay for this frame. Overlay meshes are rendered after regular meshes for the selected view, with depth testing and depth writes disabled. This makes them independent of the scene depth buffer and suitable for editor gizmos.
LDK_API bool ldk_renderer_submit_overlay_mesh_to_view(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceMesh mesh,
LDKResourceMaterial material,
Mat4 world
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceMesh meshLDKResourceMaterial materialMat4 worldtrue if the mesh was queued, false otherwise.
Submit a view-local orthographic overlay mesh in framebuffer pixels. The submitted world transform is in view-relative pixels: X right, Y up, origin at the bottom-left of the render target. Z represents an arbitrary local depth. The viewport-independent orthographic camera applies no perspective foreshortening. These meshes render after ordinary overlays, without scene depth testing. Intended for editor handles.
LDK_API bool ldk_renderer_submit_orthographic_overlay_mesh_to_view(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceMesh mesh,
LDKResourceMaterial material,
Mat4 pixel_transform
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceMesh meshLDKResourceMaterial materialMat4 pixel_transformTrue if the operation succeeds; false otherwise.
Submit a depth-tested wireframe mesh to one render view. The mesh is drawn after scene meshes and before editor overlays. It uses the scene depth buffer without writing depth, so hidden geometry remains occluded by the rendered scene. Color uses 0xRRGGBBAA and supports alpha blending. line_width is requested in pixels and may be clamped by the RHI backend. flags accepts LDK_RENDERER_MESH_SUBMIT_FLAG_BILLBOARD only.
LDK_API bool ldk_renderer_submit_wireframe_mesh_to_view(
LDKRenderer *renderer,
LDKRendererViewId view_id,
LDKResourceMesh mesh,
Mat4 world,
u32 color,
float line_width,
u32 flags
);
LDKRenderer *rendererLDKRendererViewId view_idLDKResourceMesh meshMat4 worldu32 colorfloat line_widthu32 flagsTrue if the operation succeeds; false otherwise.