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;
}