#include <extra2d/graphics/backends/opengl/gl_renderer.h>
#include <extra2d/graphics/backends/backend_factory.h>

namespace extra2d {
namespace graphics {

namespace {
    static bool s_openglBackendRegistered = false;
}

/**
 * @brief 初始化 OpenGL 后端注册
 */
void initOpenGLBackend() {
    if (s_openglBackendRegistered) {
        return;
    }
    s_openglBackendRegistered = true;
    
    BackendFactory::reg(
        "opengl",
        []() -> UniquePtr<RenderBackend> { 
            return makeUnique<GLRenderer>(); 
        },
        {"sdl2", "glfw"}
    );
}

namespace {
    struct OpenGLBackendAutoReg {
        OpenGLBackendAutoReg() {
            initOpenGLBackend();
        }
    };
    static OpenGLBackendAutoReg s_openglAutoReg;
}

} // namespace graphics
} // namespace extra2d
