#include "gl/Renderer.hpp"
#include "vk/Renderer.hpp"
#include "../../core/utils/logger.hpp"
#include "../Window.hpp"

namespace render {

bool Load(Window& window, bool preferVulkan, const renderOptions& options, const windowOptions& windOpt) {
    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();
    if(preferVulkan) {
        LOG_I("Fallback to OpenGL");
        if(gl::Renderer::Load(window, options, windOpt))
            return true;
    }
    LOG_E("No available graphics library");
    return false;
}

}