Added handle system and improve resource management.
This commit is contained in:
@@ -308,7 +308,7 @@ SRT_API srt_result_e srt_scene_add_directional_light(srt_scene_t* scene, const s
|
||||
return SRT_OUT_OF_CAPACITY;
|
||||
}
|
||||
|
||||
light_entity_t e = light_create_directional_light(L);
|
||||
light_handle_t e = light_create_directional_light(L);
|
||||
uint32_t id = e.id;
|
||||
|
||||
directional_light_t* dst = &L->directional_lights[id];
|
||||
@@ -414,7 +414,7 @@ SRT_API srt_result_e srt_scene_add_punctual_light(srt_scene_t* scene, const srt_
|
||||
return SRT_OUT_OF_CAPACITY;
|
||||
}
|
||||
|
||||
light_entity_t e = light_create_punctual_light(L);
|
||||
light_handle_t e = light_create_punctual_light(L);
|
||||
uint32_t id = e.id;
|
||||
|
||||
punctual_light_t* dst = &L->punctual_lights[id];
|
||||
@@ -637,7 +637,7 @@ SRT_API srt_result_e srt_scene_texture_load(srt_scene_t* scene,
|
||||
return SRT_ERROR;
|
||||
}
|
||||
|
||||
*out_texture = (srt_texture_handle_t){.id = h.id};
|
||||
*out_texture = (srt_texture_handle_t){.id = h.id, .generation = h.generation};
|
||||
return SRT_OK;
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ SRT_API srt_result_e srt_scene_texture_set_sampler(srt_scene_t* scene,
|
||||
return SRT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
texture_handle_t h = {.id = texture.id};
|
||||
texture_handle_t h = {.id = texture.id, .generation = texture.generation};
|
||||
texture_t* tex = get_texture(&scene->scene.textures, h);
|
||||
if (tex == NULL)
|
||||
{
|
||||
@@ -706,7 +706,7 @@ SRT_API srt_result_e srt_scene_set_sky(srt_scene_t* scene, const srt_sky_desc_t*
|
||||
}
|
||||
|
||||
const srt_sky_hdr_desc_t* d = (const srt_sky_hdr_desc_t*)desc->data;
|
||||
texture_handle_t h = {.id = d->hdri.id};
|
||||
texture_handle_t h = {.id = d->hdri.id, .generation = d->hdri.generation};
|
||||
if (get_texture(&scene->scene.textures, h) == NULL)
|
||||
{
|
||||
return SRT_NOT_FOUND;
|
||||
|
||||
Reference in New Issue
Block a user