Fix legacy system

This commit is contained in:
EmeraldLoc 2026-07-03 02:07:35 -05:00
parent eb99b25418
commit ff3c2fa839
3 changed files with 17 additions and 10 deletions

View file

@ -532,7 +532,7 @@ static struct ShaderProgram *gfx_d3d11_create_and_load_new_shader(struct ColorCo
prg->used_textures[0] = cc_features.used_textures[0];
prg->used_textures[1] = cc_features.used_textures[1];
prg->used_lightmap = cc->cm.light_map;
prg->used_fog = cc->cm.used_fog;
prg->used_fog = cc->cm.use_fog;
prg->vertexShader = vertexShader;
prg->fragmentShader = fragmentShader;
prg->world_geometry = cc->cm.world_geometry;
@ -1128,7 +1128,7 @@ static void gfx_d3d11_on_resize(void) {
if (framePass->width == 0 || framePass->height == 0) {
// needs to be recreated to redo viewport size
gfx_metal_delete_framebuffer(framePass);
gfx_d3d11_delete_framebuffer(framePass);
}
}
create_render_target_views(true);
@ -1162,7 +1162,7 @@ static void gfx_d3d11_start_frame(void) {
static void gfx_d3d11_end_frame(void) {
}
static const char* gfx_d3d11_get_name(void) {
static const char *gfx_d3d11_get_name(void) {
return "DirectX 11";
}
@ -1208,8 +1208,8 @@ struct GfxRenderingAPI gfx_direct3d11_api = {
gfx_d3d11_start_frame,
gfx_d3d11_end_frame,
gfx_d3d11_finish_render,
gfx_d3d11_is_legacy,
gfx_d3d11_get_name,
gfx_d3d11_is_legacy,
};
#endif

View file

@ -62,7 +62,7 @@ static struct ShaderProgram *opengl_prg = NULL;
static struct GLTexture *opengl_tex[2];
static int opengl_curtex = 0;
static bool sIsLegacy = true;
static bool sIsLegacy = false;
static bool gfx_opengl_z_is_from_0_to_1(void) {
return false;
@ -645,20 +645,21 @@ static void gfx_opengl_init(void) {
sys_fatal("could not init GLEW:\n%s", glewGetErrorString(err));
#endif
sIsLegacy = false;
tex_cache_size = TEX_CACHE_STEP;
tex_cache = calloc(tex_cache_size, sizeof(struct GLTexture));
if (!tex_cache) sys_fatal("out of memory allocating texture cache");
if (!tex_cache) { sys_fatal("out of memory allocating texture cache"); }
// check GL version
int vmajor = 0;
int vminor = 0;
bool is_es = false;
gl_get_version(&vmajor, &vminor, &is_es);
if (vmajor < 4 && vminor < 1 && !is_es) {
if (!is_es && (vmajor < 4 || (vmajor == 4 && vminor < 1))) {
sys_fatal("OpenGL 4.1+ is required.\nReported version: %s%d.%d", is_es ? "ES" : "", vmajor, vminor);
}
if ((vmajor >= 4 && (vmajor > 4 || vminor < 5)) && !is_es) {
if (is_es || (vmajor == 4 && vminor < 5)) {
sIsLegacy = true;
}
@ -714,7 +715,7 @@ static void gfx_opengl_end_frame(void) {
static void gfx_opengl_finish_render(void) {
}
static const char* gfx_opengl_get_name(void) {
static const char *gfx_opengl_get_name(void) {
return sIsLegacy ? "OpenGL (Legacy)" : "OpenGL";
}

View file

@ -139,7 +139,7 @@ static void gfx_sdl_init(const char *window_title) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
#else
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
#endif
}
@ -172,6 +172,12 @@ static void gfx_sdl_init(const char *window_title) {
}
#else
ctx = SDL_GL_CreateContext(wnd);
if (!ctx) {
// try again with 4.1
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
ctx = SDL_GL_CreateContext(wnd);
}
#endif
gfx_sdl_set_vsync(configWindow.vsync);