Enhance graphics library functionality and structure
Added new function signatures in `assimp-vc143-mt.lib` for improved logging, parsing, and vector operations. Added new metadata and configuration information in `assimp-vc143-mt.dll` for versioning and licensing compliance. Added Sobol sequence generation in `Sobol.c` for quasi-random sampling. Added window message handling in `Window.c` for rendering graphics. Added ray-triangle intersection tests in `RayIntersection.c` for collision detection. Added functions for loading mesh data in `Mesh.c` to support 3D model import. Added functions for managing triangle collections in `Triangle.c` to enhance geometric data handling. Added light evaluation functions in `LightEvaluation.c` and `SkyLight.c` for realistic rendering. Added sampling and evaluation functions for simple lit materials in `SimpleLit.c`. Changed various header files to include copyright and licensing information. Changed existing functions in multiple files to improve performance and clarity. Removed unused code in several files to streamline the library.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "Rendering/RenderTarget.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
render_target_t render_target_create(uint32_t width, uint32_t height)
|
||||
{
|
||||
@@ -8,9 +9,17 @@ render_target_t render_target_create(uint32_t width, uint32_t height)
|
||||
target.width = width;
|
||||
target.height = height;
|
||||
|
||||
size_t buffer_size = (size_t)width * height * sizeof(vec4s);
|
||||
size_t size_of_pixel = sizeof(vec4s);
|
||||
size_t buffer_size = (size_t)width * height * size_of_pixel;
|
||||
target.buffer = (vec4s*)malloc(buffer_size);
|
||||
|
||||
memset(target.buffer, 0, buffer_size);
|
||||
|
||||
for (size_t i = 0; i < buffer_size / size_of_pixel; i++)
|
||||
{
|
||||
target.buffer[i].w = 1.0;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -34,6 +43,28 @@ void render_target_set_pixel(render_target_t* render_target, uint32_t x, uint32_
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char* render_target_to_char(render_target_t* render_target)
|
||||
{
|
||||
size_t buffer_size = (size_t)render_target->width * render_target->height * 4; // 4 bytes for RGBA
|
||||
unsigned char* char_buffer = (unsigned char*)malloc(buffer_size);
|
||||
|
||||
for (uint32_t y = 0; y < render_target->height; y++)
|
||||
{
|
||||
for (uint32_t x = 0; x < render_target->width; x++)
|
||||
{
|
||||
vec4s pixel = render_target_get_pixel(render_target, x, y);
|
||||
size_t index = ((size_t)y * render_target->width + x) * 4;
|
||||
|
||||
char_buffer[index + 0] = COLOR_CLAMP(pixel.x * 255.0f);
|
||||
char_buffer[index + 1] = COLOR_CLAMP(pixel.y * 255.0f);
|
||||
char_buffer[index + 2] = COLOR_CLAMP(pixel.z * 255.0f);
|
||||
char_buffer[index + 3] = COLOR_CLAMP(pixel.w * 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
return char_buffer;
|
||||
}
|
||||
|
||||
void render_target_free(render_target_t* target)
|
||||
{
|
||||
if (target->buffer != NULL)
|
||||
|
||||
Reference in New Issue
Block a user