#include <gear/graphics/renderer.h>
#include <log.c/log.h>

g_renderer* g_renderer_create(g_color clear_color) {
    sg_color_attachment_action color_action = {
        .load_action = SG_LOADACTION_CLEAR,
        .clear_value = G_COLOR_TO_FLOAT_ARR(clear_color),
    };

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

    return renderer;
}
