#include "impl/gl/Renderer.hpp"
#ifdef RENDER_VK
#include "impl/vk/Renderer.hpp"
#endif
#include "core/utils/logger.hpp"
#include "Window.hpp"

#undef LOG_PREFIX
#define LOG_PREFIX "Render: "
namespace render {

bool Load(Window& window, bool preferVulkan, const renderOptions& options, const windowOptions& windOpt) {
    #ifdef RENDER_VK
    if(!preferVulkan) {
        LOG_T("Trying OpenGL");
        if(gl::Renderer::Load(window, options, windOpt))
            return true;
        window.destroy();
    }
    LOG_T("Trying Vulkan");
    if(vk::Renderer::Load(window, options, windOpt))
        return true;
    window.destroy();
    LOG_I("Fallback to OpenGL");
    #else
    if(preferVulkan) {
        LOG_W("Vk render isn't available. Consider compiling with RENDER_VK=1");
        LOG_T("Trying OpenGL");
    }
    #endif
    if(gl::Renderer::Load(window, options, windOpt))
        return true;
    LOG_E("No available graphics library");
    return false;
}

}