diff --git a/src/pc/gfx/gfx_direct3d11.cpp b/src/pc/gfx/gfx_direct3d11.cpp index b6d64e017..d14739348 100644 --- a/src/pc/gfx/gfx_direct3d11.cpp +++ b/src/pc/gfx/gfx_direct3d11.cpp @@ -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 diff --git a/src/pc/gfx/gfx_opengl.c b/src/pc/gfx/gfx_opengl.c index 7e2d2ed73..903fb7e3b 100644 --- a/src/pc/gfx/gfx_opengl.c +++ b/src/pc/gfx/gfx_opengl.c @@ -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"; } diff --git a/src/pc/gfx/gfx_sdl.c b/src/pc/gfx/gfx_sdl.c index 3413d39e6..fe5081ad5 100644 --- a/src/pc/gfx/gfx_sdl.c +++ b/src/pc/gfx/gfx_sdl.c @@ -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);