2024-08-25 12:52:42 +12:00
|
|
|
#include <gear/graphics/renderer.h>
|
2024-08-31 17:42:56 +12:00
|
|
|
#include <log.c/log.h>
|
2024-08-25 12:52:42 +12:00
|
|
|
|
2024-08-31 17:42:56 +12:00
|
|
|
g_renderer* g_renderer_create(g_color clear_color) {
|
2024-08-25 12:52:42 +12:00
|
|
|
sg_color_attachment_action color_action = {
|
|
|
|
.load_action = SG_LOADACTION_CLEAR,
|
|
|
|
.clear_value = G_COLOR_TO_FLOAT_ARR(clear_color),
|
|
|
|
};
|
|
|
|
|
2024-08-31 17:42:56 +12:00
|
|
|
g_renderer* renderer = calloc(1, sizeof(g_renderer));
|
|
|
|
if(renderer != NULL) {
|
|
|
|
log_info("Renderer allocated successfully");
|
|
|
|
log_debug("Renderer pointer: %p", renderer);
|
|
|
|
|
|
|
|
renderer->pass_action = (sg_pass_action){
|
|
|
|
.colors = { color_action, color_action, color_action, color_action },
|
|
|
|
.depth = { .load_action = SG_LOADACTION_CLEAR, .clear_value = 1.0f },
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
log_fatal("Failed to allocate renderer");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2024-08-25 12:52:42 +12:00
|
|
|
|
|
|
|
return renderer;
|
|
|
|
}
|