/**
 * @file renderer.c
 * @author Piotr Krygier (everyonecancode@gmail.com)
 * @brief
 * @version 0.1
 * @date 2025-10-15
 *
 * @copyright Copyright (c) 2025
 *
 */

#include "renderer.h"

#include <SDL3/SDL_log.h>
#include <stdint.h>

#include "src/graphics_context.h"
#include "utilities/commons.h"
#include "utilities/errors_common.h"

rse_err_t renderer_get_new_id(struct graphics_context_t* context, uint32_t* id)
{
    if (context->renderer_data.renderers_count >= RENDERER_MAX_COUNT) {
        SDL_LogCritical(SDL_LOG_CATEGORY_GPU, "Reached maximum number of renderers");

        return RSE_ERROR_INTERNAL_ERROR;
    }

    *id = context->renderer_data.renderers_count++;

    return RSE_ERROR_NO_ERROR;
}

rse_err_t renderer_set_render_function(struct graphics_context_t* context,
                                       uint32_t renderer_id,
                                       renderer_function_t renderer_function)
{
    context->renderer_data.renderers[renderer_id].render_function = renderer_function;

    return RSE_ERROR_NO_ERROR;
}
