Default to DirectX renderer if OpenGL can't be ran

This commit is contained in:
Agent X 2026-05-14 20:47:35 -04:00
parent e87d118063
commit 2e9e6644ca
3 changed files with 19 additions and 0 deletions

View file

@ -836,6 +836,18 @@ static void gfx_opengl_init(void) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
bool gfx_opengl_check_compatibility(void) {
// check GL version
int vmajor = 0;
int vminor = 0;
bool is_es = false;
gl_get_version(&vmajor, &vminor, &is_es);
if (vmajor < 2 && vminor < 1 && !is_es)
return false;
return true;
}
static void gfx_opengl_on_resize(void) {
}

View file

@ -5,4 +5,6 @@
extern struct GfxRenderingAPI gfx_opengl_api;
bool gfx_opengl_check_compatibility(void);
#endif

View file

@ -221,6 +221,11 @@ static void select_graphics_backend(void) {
return;
}
#if defined(_WIN32)
if (configGraphicsBackend == GAPI_GL && !gfx_opengl_check_compatibility()) {
configGraphicsBackend = GAPI_D3D11;
}
#endif
int backend = configGraphicsBackend;
#if defined(_WIN32)
if (gCLIOpts.backend != -1) { backend = gCLIOpts.backend; }