Refactor some of the code.

This commit is contained in:
2025-04-24 00:05:21 +09:00
parent 17872804c5
commit 4db14ffdb0
7 changed files with 20 additions and 38 deletions

View File

@@ -4,13 +4,13 @@
#include <math.h>
bool render_target_init(uint32_t width, uint32_t height, render_target_t* render_target)
{
render_target->width = width;
render_target->height = height;
size_t size_of_pixel = sizeof(vec4s);
size_t buffer_size = (size_t)width * height * size_of_pixel;
size_t image_size = (size_t)width * height;
size_t buffer_size = image_size * size_of_pixel;
vec4s* buffer = (vec4s*)malloc(buffer_size);
if (buffer == NULL)
{
@@ -19,7 +19,7 @@ bool render_target_init(uint32_t width, uint32_t height, render_target_t* render
memset(buffer, 0, buffer_size);
for (size_t i = 0; i < buffer_size / size_of_pixel; i++)
for (size_t i = 0; i < image_size; i++)
{
buffer[i].w = 1.0;
}

View File

@@ -39,7 +39,7 @@ static inline uint16_t get_sample_count(uint16_t sample_count, int flag)
return sample_count;
}
static void render_pixel(const rendering_config_t* config, scene_t* scene, vec3s coord, uint32_t x, uint32_t y, int flag, vec4s* pixel_color)
static void render_pixel(const rendering_config_t* config, scene_t* scene, vec3s coord, uint32_t x, uint32_t y, debug_flag_t flag, vec4s* pixel_color)
{
vec4s accumulated_color = glms_vec4_zero();
uint32_t pixel_id = y * config->width + x;
@@ -118,7 +118,7 @@ void renderer_start(render_job_t* job)
}
vec4s pixel_color;
render_pixel(job->config, job->scene, coord, (uint32_t)x, (uint32_t)y, job->rendering_flag, &pixel_color);
render_pixel(job->config, job->scene, coord, (uint32_t)x, (uint32_t)y, job->debug_flag, &pixel_color);
render_target_set_pixel(job->render_target, (uint32_t)x, (uint32_t)y, pixel_color);
}
}