mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-24 00:02:43 +02:00
port: gl: check for GL_MIRROR_CLAMP_TO_EDGE; cleanup
This commit is contained in:
1 parent
c4e0e4f868
commit
8aa1e6b9c9
3 files changed
+23
-31
No files matched your search
@@ -14,12 +14,6 @@
|
||||
#endif
|
||||
#include <PR/gbi.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#define FOR_WINDOWS 1
|
||||
#else
|
||||
#define FOR_WINDOWS 0
|
||||
#endif
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
#include "gfx_cc.h"
|
||||
@@ -63,8 +57,7 @@ static size_t current_framebuffer;
|
||||
static float current_noise_scale;
|
||||
static FilteringMode current_filter_mode = FILTER_LINEAR;
|
||||
|
||||
GLuint pixel_depth_rb, pixel_depth_fb;
|
||||
size_t pixel_depth_rb_size;
|
||||
static GLenum gl_mirror_clamp = GL_MIRROR_CLAMP_TO_EDGE;
|
||||
|
||||
static int gfx_opengl_get_max_texture_size() {
|
||||
GLint max_texture_size;
|
||||
@@ -715,10 +708,6 @@ static void gfx_opengl_upload_texture(const uint8_t* rgba32_buf, uint32_t width,
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgba32_buf);
|
||||
}
|
||||
|
||||
#ifdef __SWITCH__
|
||||
#define GL_MIRROR_CLAMP_TO_EDGE 0x8743
|
||||
#endif
|
||||
|
||||
static uint32_t gfx_cm_to_opengl(uint32_t val) {
|
||||
switch (val) {
|
||||
case G_TX_NOMIRROR | G_TX_CLAMP:
|
||||
@@ -726,7 +715,7 @@ static uint32_t gfx_cm_to_opengl(uint32_t val) {
|
||||
case G_TX_MIRROR | G_TX_WRAP:
|
||||
return GL_MIRRORED_REPEAT;
|
||||
case G_TX_MIRROR | G_TX_CLAMP:
|
||||
return GL_MIRRORED_REPEAT /*GL_MIRROR_CLAMP_TO_EDGE*/; // GL4 only
|
||||
return gl_mirror_clamp;
|
||||
case G_TX_NOMIRROR | G_TX_WRAP:
|
||||
return GL_REPEAT;
|
||||
}
|
||||
@@ -885,6 +874,7 @@ static void gfx_opengl_log_info(void) {
|
||||
sysLogPrintf(LOG_NOTE, "GL: GLSL version: %s", glsl_version ? glsl_version : "unknown");
|
||||
sysLogPrintf(LOG_NOTE, "GL: ARB_framebuffer_object: %s", gfx_opengl_supports_framebuffers() ? "yes" : "no");
|
||||
sysLogPrintf(LOG_NOTE, "GL: ARB_depth_clamp: %s", GLAD_GL_ARB_depth_clamp ? "yes" : "no");
|
||||
sysLogPrintf(LOG_NOTE, "GL: ARB_texture_mirror_clamp_to_edge: %s", GLAD_GL_ARB_texture_mirror_clamp_to_edge ? "yes" : "no");
|
||||
}
|
||||
|
||||
static void *gl_load_proc(const char *name) {
|
||||
@@ -936,6 +926,11 @@ static void gfx_opengl_init(void) {
|
||||
// TODO: actually disable fb usage
|
||||
}
|
||||
|
||||
if ((GLVersion.major < 4 || GLVersion.minor < 4) && !GLAD_GL_ARB_texture_mirror_clamp_to_edge) {
|
||||
// GL_MIRROR_CLAMP_TO_EDGE unsupported
|
||||
gl_mirror_clamp = GL_MIRRORED_REPEAT;
|
||||
}
|
||||
|
||||
glGenBuffers(1, &opengl_vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, opengl_vbo);
|
||||
|
||||
@@ -951,18 +946,6 @@ static void gfx_opengl_init(void) {
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
framebuffers.resize(1); // for the default screen buffer
|
||||
|
||||
glGenRenderbuffers(1, &pixel_depth_rb);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, pixel_depth_rb);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1, 1);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
|
||||
glGenFramebuffers(1, &pixel_depth_fb);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, pixel_depth_fb);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, pixel_depth_rb);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
pixel_depth_rb_size = 1;
|
||||
}
|
||||
|
||||
static void gfx_opengl_on_resize(void) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
OpenGL loader generated by glad 0.1.34 on Tue Sep 26 12:26:06 2023.
|
||||
OpenGL loader generated by glad 0.1.34 on Tue Sep 26 12:54:23 2023.
|
||||
|
||||
Language/Generator: C/C++
|
||||
Specification: gl
|
||||
@@ -9,6 +9,7 @@
|
||||
Extensions:
|
||||
GL_ARB_depth_clamp,
|
||||
GL_ARB_framebuffer_object,
|
||||
GL_ARB_texture_mirror_clamp_to_edge,
|
||||
GL_EXT_framebuffer_blit,
|
||||
GL_EXT_framebuffer_multisample,
|
||||
GL_EXT_framebuffer_object,
|
||||
@@ -21,9 +22,9 @@
|
||||
Reproducible: False
|
||||
|
||||
Commandline:
|
||||
--profile="compatibility" --api="gl=2.1" --generator="c" --spec="gl" --local-files --extensions="GL_ARB_depth_clamp,GL_ARB_framebuffer_object,GL_EXT_framebuffer_blit,GL_EXT_framebuffer_multisample,GL_EXT_framebuffer_object,GL_EXT_gpu_shader4,GL_KHR_debug,GL_NV_depth_clamp"
|
||||
--profile="compatibility" --api="gl=2.1" --generator="c" --spec="gl" --local-files --extensions="GL_ARB_depth_clamp,GL_ARB_framebuffer_object,GL_ARB_texture_mirror_clamp_to_edge,GL_EXT_framebuffer_blit,GL_EXT_framebuffer_multisample,GL_EXT_framebuffer_object,GL_EXT_gpu_shader4,GL_KHR_debug,GL_NV_depth_clamp"
|
||||
Online:
|
||||
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_blit&extensions=GL_EXT_framebuffer_multisample&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_gpu_shader4&extensions=GL_KHR_debug&extensions=GL_NV_depth_clamp
|
||||
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_ARB_texture_mirror_clamp_to_edge&extensions=GL_EXT_framebuffer_blit&extensions=GL_EXT_framebuffer_multisample&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_gpu_shader4&extensions=GL_KHR_debug&extensions=GL_NV_depth_clamp
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -823,6 +824,7 @@ 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_ARB_texture_mirror_clamp_to_edge = 0;
|
||||
int GLAD_GL_EXT_framebuffer_blit = 0;
|
||||
int GLAD_GL_EXT_framebuffer_multisample = 0;
|
||||
int GLAD_GL_EXT_framebuffer_object = 0;
|
||||
@@ -1615,6 +1617,7 @@ 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_ARB_texture_mirror_clamp_to_edge = has_ext("GL_ARB_texture_mirror_clamp_to_edge");
|
||||
GLAD_GL_EXT_framebuffer_blit = has_ext("GL_EXT_framebuffer_blit");
|
||||
GLAD_GL_EXT_framebuffer_multisample = has_ext("GL_EXT_framebuffer_multisample");
|
||||
GLAD_GL_EXT_framebuffer_object = has_ext("GL_EXT_framebuffer_object");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
OpenGL loader generated by glad 0.1.34 on Tue Sep 26 12:26:06 2023.
|
||||
OpenGL loader generated by glad 0.1.34 on Tue Sep 26 12:54:23 2023.
|
||||
|
||||
Language/Generator: C/C++
|
||||
Specification: gl
|
||||
@@ -9,6 +9,7 @@
|
||||
Extensions:
|
||||
GL_ARB_depth_clamp,
|
||||
GL_ARB_framebuffer_object,
|
||||
GL_ARB_texture_mirror_clamp_to_edge,
|
||||
GL_EXT_framebuffer_blit,
|
||||
GL_EXT_framebuffer_multisample,
|
||||
GL_EXT_framebuffer_object,
|
||||
@@ -21,9 +22,9 @@
|
||||
Reproducible: False
|
||||
|
||||
Commandline:
|
||||
--profile="compatibility" --api="gl=2.1" --generator="c" --spec="gl" --local-files --extensions="GL_ARB_depth_clamp,GL_ARB_framebuffer_object,GL_EXT_framebuffer_blit,GL_EXT_framebuffer_multisample,GL_EXT_framebuffer_object,GL_EXT_gpu_shader4,GL_KHR_debug,GL_NV_depth_clamp"
|
||||
--profile="compatibility" --api="gl=2.1" --generator="c" --spec="gl" --local-files --extensions="GL_ARB_depth_clamp,GL_ARB_framebuffer_object,GL_ARB_texture_mirror_clamp_to_edge,GL_EXT_framebuffer_blit,GL_EXT_framebuffer_multisample,GL_EXT_framebuffer_object,GL_EXT_gpu_shader4,GL_KHR_debug,GL_NV_depth_clamp"
|
||||
Online:
|
||||
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_blit&extensions=GL_EXT_framebuffer_multisample&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_gpu_shader4&extensions=GL_KHR_debug&extensions=GL_NV_depth_clamp
|
||||
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_ARB_texture_mirror_clamp_to_edge&extensions=GL_EXT_framebuffer_blit&extensions=GL_EXT_framebuffer_multisample&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_gpu_shader4&extensions=GL_KHR_debug&extensions=GL_NV_depth_clamp
|
||||
*/
|
||||
|
||||
|
||||
@@ -2771,6 +2772,7 @@ GLAPI PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
|
||||
#define GL_MAX_SAMPLES 0x8D57
|
||||
#define GL_INDEX 0x8222
|
||||
#define GL_MIRROR_CLAMP_TO_EDGE 0x8743
|
||||
#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
|
||||
#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
|
||||
#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
|
||||
@@ -3004,6 +3006,10 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum
|
||||
GLAPI PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
|
||||
#define glFramebufferTextureLayer glad_glFramebufferTextureLayer
|
||||
#endif
|
||||
#ifndef GL_ARB_texture_mirror_clamp_to_edge
|
||||
#define GL_ARB_texture_mirror_clamp_to_edge 1
|
||||
GLAPI int GLAD_GL_ARB_texture_mirror_clamp_to_edge;
|
||||
#endif
|
||||
#ifndef GL_EXT_framebuffer_blit
|
||||
#define GL_EXT_framebuffer_blit 1
|
||||
GLAPI int GLAD_GL_EXT_framebuffer_blit;
|
||||
|
||||
Reference in new issue
Block a user