From ba1b6c32329ef9f6ac820c95c5b16c2f9d2790b7 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Wed, 20 Nov 2024 12:51:35 +0100 Subject: [PATCH] port: turns out depth_clamp is in core GL since 3.2 --- port/fast3d/gfx_opengl.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/port/fast3d/gfx_opengl.cpp b/port/fast3d/gfx_opengl.cpp index 75b315c07..55fa7d788 100644 --- a/port/fast3d/gfx_opengl.cpp +++ b/port/fast3d/gfx_opengl.cpp @@ -904,9 +904,16 @@ static void gfx_opengl_init_extensions(void) { if (!GLAD_GL_ARB_depth_clamp) { if (GLAD_GL_EXT_depth_clamp || GLAD_GL_NV_depth_clamp) { GLAD_GL_ARB_depth_clamp = 1; + } else if (!gl_es && GLVersion.major >= 3) { + // GL3.2+ should have depth_clamp as part of the spec, but some devices don't report it for some reason + GLAD_GL_ARB_depth_clamp = (GLVersion.major > 3 || (GLVersion.major == 3 && GLVersion.minor >= 2)); } } + if (!GLAD_GL_ARB_texture_mirror_clamp_to_edge) { + GLAD_GL_ARB_texture_mirror_clamp_to_edge = GLAD_GL_EXT_texture_mirror_clamp_to_edge; + } + if (GLVersion.major < 3 && !GLAD_GL_ARB_framebuffer_object) { if (GLAD_GL_EXT_framebuffer_object && GLAD_GL_EXT_framebuffer_blit && GLAD_GL_EXT_framebuffer_multisample) { // because of the way glad works we'll have to copy the pointers over @@ -930,6 +937,12 @@ static void gfx_opengl_init(void) { sysFatalError("Could not load OpenGL.\nReported SDL error: %s", SDL_GetError()); } + // check if we're using ES or core, which have more limited feature sets + int val = 0; + SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &val); + gl_core_profile = (val == SDL_GL_CONTEXT_PROFILE_CORE); + gl_es = (val == SDL_GL_CONTEXT_PROFILE_ES); + gfx_opengl_init_extensions(); if (sysArgCheck("--debug-gl")) { @@ -961,12 +974,6 @@ static void gfx_opengl_init(void) { gl_mirror_clamp = GL_MIRRORED_REPEAT; } - // check if we're using ES or core, which have more limited feature sets - int val = 0; - SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &val); - gl_core_profile = (val == SDL_GL_CONTEXT_PROFILE_CORE); - gl_es = (val == SDL_GL_CONTEXT_PROFILE_ES); - // determine GLSL version if (gl_es) { // ES has its own numbering scheme, but it should support 300 even on 3.1 and 3.2