From 6f35e00c16073f0c0d4715cc76f0be16fa4acfcb Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Tue, 15 Aug 2023 05:05:53 +0200 Subject: [PATCH] Fixed flipped texts and menu elements that were beyond the near clip plane. --- port/fast3d/gfx_opengl.cpp | 4 +++- port/fast3d/gfx_pc.cpp | 5 +---- port/fast3d/glad/glad.c | 9 ++++++--- port/fast3d/glad/glad.h | 12 +++++++++--- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/port/fast3d/gfx_opengl.cpp b/port/fast3d/gfx_opengl.cpp index 9653c2213..0cf0cc652 100644 --- a/port/fast3d/gfx_opengl.cpp +++ b/port/fast3d/gfx_opengl.cpp @@ -827,7 +827,9 @@ static void gfx_opengl_init(void) { glBindVertexArray(opengl_vao); #endif - // glEnable(GL_DEPTH_CLAMP); // GL4 only + if (GLAD_GL_ARB_depth_clamp) { + glEnable(GL_DEPTH_CLAMP); + } glDepthFunc(GL_LEQUAL); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/port/fast3d/gfx_pc.cpp b/port/fast3d/gfx_pc.cpp index dfc89527f..8286b7c6c 100644 --- a/port/fast3d/gfx_pc.cpp +++ b/port/fast3d/gfx_pc.cpp @@ -2133,10 +2133,7 @@ static void gfx_dp_texture_rectangle(int32_t ulx, int32_t uly, int32_t lrx, int3 // dsdx and dtdy are S5.10 // lrx, lry, ulx, uly are U10.2 // lrs, lrt are S10.5 - if (flip) { - dsdx = -dsdx; - dtdy = -dtdy; - } + int16_t width = !flip ? lrx - ulx : lry - uly; int16_t height = !flip ? lry - uly : lrx - ulx; float lrs = ((uls << 7) + dsdx * width) >> 7; diff --git a/port/fast3d/glad/glad.c b/port/fast3d/glad/glad.c index 5e88b5ea4..5f2eaa5ce 100644 --- a/port/fast3d/glad/glad.c +++ b/port/fast3d/glad/glad.c @@ -1,12 +1,13 @@ /* - OpenGL loader generated by glad 0.1.34 on Sun Jul 30 09:46:53 2023. + OpenGL loader generated by glad 0.1.34 on Tue Aug 15 02:22:41 2023. Language/Generator: C/C++ Specification: gl APIs: gl=2.1 Profile: compatibility Extensions: + GL_ARB_depth_clamp, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object Loader: True @@ -15,9 +16,9 @@ Reproducible: False Commandline: - --profile="compatibility" --api="gl=2.1" --generator="c" --spec="gl" --local-files --extensions="GL_ARB_framebuffer_object,GL_EXT_framebuffer_object" + --profile="compatibility" --api="gl=2.1" --generator="c" --spec="gl" --local-files --extensions="GL_ARB_depth_clamp,GL_ARB_framebuffer_object,GL_EXT_framebuffer_object" Online: - https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D2.1&extensions=GL_ARB_framebuffer_object&extensions=GL_EXT_framebuffer_object + https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D2.1&extensions=GL_ARB_depth_clamp&extensions=GL_ARB_framebuffer_object&extensions=GL_EXT_framebuffer_object */ #include @@ -815,6 +816,7 @@ PFNGLWINDOWPOS3IPROC glad_glWindowPos3i = NULL; PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv = NULL; PFNGLWINDOWPOS3SPROC glad_glWindowPos3s = NULL; PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL; +int GLAD_GL_ARB_depth_clamp = 0; int GLAD_GL_ARB_framebuffer_object = 0; int GLAD_GL_EXT_framebuffer_object = 0; PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL; @@ -1474,6 +1476,7 @@ static void load_GL_EXT_framebuffer_object(GLADloadproc load) { } static int find_extensionsGL(void) { if (!get_exts()) return 0; + GLAD_GL_ARB_depth_clamp = has_ext("GL_ARB_depth_clamp"); GLAD_GL_ARB_framebuffer_object = has_ext("GL_ARB_framebuffer_object"); GLAD_GL_EXT_framebuffer_object = has_ext("GL_EXT_framebuffer_object"); free_exts(); diff --git a/port/fast3d/glad/glad.h b/port/fast3d/glad/glad.h index 761da7948..b8a698f29 100644 --- a/port/fast3d/glad/glad.h +++ b/port/fast3d/glad/glad.h @@ -1,12 +1,13 @@ /* - OpenGL loader generated by glad 0.1.34 on Sun Jul 30 09:46:53 2023. + OpenGL loader generated by glad 0.1.34 on Tue Aug 15 02:22:41 2023. Language/Generator: C/C++ Specification: gl APIs: gl=2.1 Profile: compatibility Extensions: + GL_ARB_depth_clamp, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object Loader: True @@ -15,9 +16,9 @@ Reproducible: False Commandline: - --profile="compatibility" --api="gl=2.1" --generator="c" --spec="gl" --local-files --extensions="GL_ARB_framebuffer_object,GL_EXT_framebuffer_object" + --profile="compatibility" --api="gl=2.1" --generator="c" --spec="gl" --local-files --extensions="GL_ARB_depth_clamp,GL_ARB_framebuffer_object,GL_EXT_framebuffer_object" Online: - https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D2.1&extensions=GL_ARB_framebuffer_object&extensions=GL_EXT_framebuffer_object + https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D2.1&extensions=GL_ARB_depth_clamp&extensions=GL_ARB_framebuffer_object&extensions=GL_EXT_framebuffer_object */ @@ -2691,6 +2692,7 @@ typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei cou GLAPI PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv; #define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv #endif +#define GL_DEPTH_CLAMP 0x864F #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 @@ -2815,6 +2817,10 @@ GLAPI PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv; #define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +GLAPI int GLAD_GL_ARB_depth_clamp; +#endif #ifndef GL_ARB_framebuffer_object #define GL_ARB_framebuffer_object 1 GLAPI int GLAD_GL_ARB_framebuffer_object;