Changed function signatures to remove const qualifiers
Changed several function signatures across multiple files to remove the `const` qualifier from parameters of type `vec3s` for improved flexibility. Changed `material_collection_create` to `material_collection_init` for better initialization handling. Changed `scene_create` to `scene_init` to return a boolean indicating success or failure. Changed `render_target_create` to `render_target_init` for consistent initialization practices. Changed `window_create` to remove `const` from its parameters for consistency. Changed `evaluate_bsdf_directional` and `evaluate_bsdf_const_sky` to remove `const` from their parameters. Changed `sample_bsdf_simple_lit` and `sample_bsdf_pdf_simple_lit` to remove `const` from the `normal` parameter. Changed `scene_render` to take a pointer to `render_target_t` instead of returning it directly. Updated `main.c` to reflect new initialization functions for better memory management.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "cglm/struct/mat4.h"
|
||||
|
||||
// Maybe full aces later
|
||||
inline vec4s aces_tone_map(const vec4s color)
|
||||
inline vec4s aces_tone_map( vec4s color)
|
||||
{
|
||||
vec4s mapped_color = color;
|
||||
float a = 2.51f;
|
||||
|
||||
@@ -11,8 +11,8 @@ typedef struct
|
||||
uint32_t height;
|
||||
} render_target_t;
|
||||
|
||||
render_target_t render_target_create(uint32_t width, uint32_t height);
|
||||
vec4s render_target_get_pixel(render_target_t* render_target, uint32_t x, uint32_t y);
|
||||
bool render_target_init(uint32_t width, uint32_t height, render_target_t* render_target);
|
||||
vec4s render_target_get_pixel(const render_target_t* render_target, uint32_t x, uint32_t y);
|
||||
void render_target_set_pixel(render_target_t* render_target, uint32_t x, uint32_t y, vec4s color);
|
||||
unsigned char* render_target_to_char(render_target_t* render_target);
|
||||
void render_target_free(render_target_t* target);
|
||||
|
||||
@@ -42,10 +42,54 @@ typedef struct
|
||||
light_collection_t lights;
|
||||
} scene_t;
|
||||
|
||||
scene_t scene_create(const uint64_t triangle_count, const uint8_t material_count, const uint32_t max_punctual_lights);
|
||||
bool scene_render_tile(scene_t* scene, rendering_context_t* ctx, render_target_t* render_target,
|
||||
const rendering_config_t config, const uint32_t tile_index, tile_t* tile_out);
|
||||
render_target_t scene_render(scene_t* scene, const rendering_config_t config);
|
||||
void scene_free(scene_t* scene);
|
||||
rendering_config_t config, uint32_t tile_index, tile_t* tile_out);
|
||||
bool scene_render(scene_t* scene, rendering_config_t confi, render_target_t* render_targetg);
|
||||
|
||||
inline bool scene_init(uint64_t triangle_count, uint8_t material_count, uint32_t punctual_light_count, scene_t* scene)
|
||||
{
|
||||
scene_t temp = {0};
|
||||
|
||||
if (!triangle_collection_init(triangle_count, &temp.triangles))
|
||||
{
|
||||
goto triangle_failed;
|
||||
}
|
||||
|
||||
if (!material_collection_init(material_count, &temp.materials))
|
||||
{
|
||||
goto material_failed;
|
||||
}
|
||||
|
||||
if (!light_collection_create(punctual_light_count, 16, &temp.lights)) // NOTE: We just fixed the max directional light count to 16.
|
||||
{
|
||||
goto light_failed;
|
||||
}
|
||||
|
||||
temp.camera = camera_create(
|
||||
(vec3s){0.0f, 0.0f, 5.0f},
|
||||
(vec3s){0.0f, 0.0f, -1.0f},
|
||||
(vec3s){0.0f, 1.0f, 0.0f},
|
||||
0.025f,
|
||||
0.036f,
|
||||
16.0f / 9.0f
|
||||
);
|
||||
|
||||
*scene = temp;
|
||||
return true;
|
||||
|
||||
light_failed:
|
||||
material_collection_free(&temp.materials);
|
||||
material_failed:
|
||||
triangle_collection_free(&temp.triangles);
|
||||
triangle_failed:
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void scene_free(scene_t* scene)
|
||||
{
|
||||
triangle_collection_free(&scene->triangles);
|
||||
material_collection_free(&scene->materials);
|
||||
light_collection_free(&scene->lights);
|
||||
}
|
||||
|
||||
#endif // SCENE_H
|
||||
|
||||
Reference in New Issue
Block a user