#include "renderer/backend_api.h"

#include "device.hpp"

void Dx11RegisterCVARs(void) {
}

rt_render_backend_init_result Dx11Init(const rt_renderer_window_info *info) {
    rt_result res = rt_dx11_device::GetInstance()->Initialize(info);

    rt_render_device_i iface = {reinterpret_cast<void*>(rt_dx11_device::GetInstance()), nullptr};
    rt_render_backend_init_result result = {.result = res, .device = iface};
    if (res != RT_SUCCESS)
        return result;
    return result;
}

void Dx11Shutdown(void) {
    rt_dx11_device::GetInstance()->Shutdown();
}

// Called by the application to retrieve the renderer api
extern "C" RT_DLLEXPORT rt_render_backend_api rtLoadRenderBackendImpl(void) {
    rt_render_backend_api api = {
        .RegisterCVARs = Dx11RegisterCVARs,
        .Init          = Dx11Init,
        .Shutdown      = Dx11Shutdown,
    };
    return api;
}
