diff --git a/src/client/refresh/gl4/gl4_main.c b/src/client/refresh/gl4/gl4_main.c index 7e4ea54b..7cd899de 100644 --- a/src/client/refresh/gl4/gl4_main.c +++ b/src/client/refresh/gl4/gl4_main.c @@ -35,11 +35,7 @@ #define DG_DYNARR_IMPLEMENTATION #include "../files/DG_dynarr.h" -#ifdef YQ2_GL3_GLES3 - #define REF_VERSION "Yamagi Quake II OpenGL ES3 Refresher" -#else - #define REF_VERSION "Yamagi Quake II OpenGL4 Refresher" -#endif +#define REF_VERSION "Yamagi Quake II OpenGL4 Refresher" refimport_t ri; @@ -1006,15 +1002,7 @@ GL4_DrawParticles(void) glDepthMask(GL_FALSE); glEnable(GL_BLEND); -#ifdef YQ2_GL3_GLES - // the RPi4 GLES3 implementation doesn't draw particles if culling is - // enabled (at least with GL_FRONT which seems to be default in q2?) - glDisable(GL_CULL_FACE); -#else - // GLES doesn't have this, maybe it's always enabled? (https://gamedev.stackexchange.com/a/15528 says it works) - // luckily we don't use glPointSize() but set gl_PointSize in shader anyway glEnable(GL_PROGRAM_POINT_SIZE); -#endif GL4_UseProgram(gl4state.siParticle.shaderProgram); @@ -1041,12 +1029,8 @@ GL4_DrawParticles(void) glDisable(GL_BLEND); glDepthMask(GL_TRUE); -#ifdef YQ2_GL3_GLES - if(r_cull->value != 0.0f) - glEnable(GL_CULL_FACE); -#else + glDisable(GL_PROGRAM_POINT_SIZE); -#endif YQ2_VLAFREE(buf); } @@ -1880,12 +1864,6 @@ GL4_BeginFrame(float camera_separation) { gl_drawbuffer->modified = false; - -#ifdef YQ2_GL3_GLES - // OpenGL ES3 only supports GL_NONE, GL_BACK and GL_COLOR_ATTACHMENT* - // so this doesn't make sense here, see https://docs.gl/es3/glDrawBuffers - R_Printf(PRINT_ALL, "NOTE: gl_drawbuffer not supported by OpenGL ES!\n"); -#else // Desktop GL // TODO: stereo stuff //if ((gl4state.camera_separation == 0) || gl4state.stereo_mode != STEREO_MODE_OPENGL) { @@ -1896,7 +1874,6 @@ GL4_BeginFrame(float camera_separation) } glDrawBuffer(drawBuffer); } -#endif } /* texturemode stuff */ diff --git a/src/client/refresh/gl4/gl4_misc.c b/src/client/refresh/gl4/gl4_misc.c index e354f227..4bd2dad8 100644 --- a/src/client/refresh/gl4/gl4_misc.c +++ b/src/client/refresh/gl4/gl4_misc.c @@ -34,22 +34,15 @@ void GL4_SetDefaultState(void) { glClearColor(1, 0, 0.5, 0.5); -#ifndef YQ2_GL3_GLES - // in GLES this is only supported with an extension: - // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_multisample_compatibility.txt - // but apparently it's just enabled by default if set in the context? + glDisable(GL_MULTISAMPLE); -#endif glCullFace(GL_FRONT); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_BLEND); -#ifndef YQ2_GL3_GLES - // in GLES GL_FILL is the only supported mode glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); -#endif // TODO: gl1_texturealphamode? GL4_TextureMode(gl_texturemode->string); @@ -64,13 +57,10 @@ GL4_SetDefaultState(void) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#ifndef YQ2_GL3_GLES // see above if (gl_msaa_samples->value) { glEnable(GL_MULTISAMPLE); - // glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); TODO what is this for? } -#endif } static byte dottexture[8][8] = { @@ -126,14 +116,7 @@ GL4_ScreenShot(void) { int w=vid.width, h=vid.height; -#ifdef YQ2_GL3_GLES - // My RPi4's GLES3 doesn't like GL_RGB, so use GL_RGBA with GLES - // TODO: we could convert the screenshot to RGB before writing - // so the resulting file is smaller - static const int comps = 4; -#else // Desktop GL static const int comps = 3; -#endif byte *buffer = malloc(w*h*comps); if (!buffer) diff --git a/src/client/refresh/gl4/gl4_sdl.c b/src/client/refresh/gl4/gl4_sdl.c index bebae9f9..c266d61e 100644 --- a/src/client/refresh/gl4/gl4_sdl.c +++ b/src/client/refresh/gl4/gl4_sdl.c @@ -57,12 +57,7 @@ DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei le switch (severity) { -#ifdef YQ2_GL3_GLES - #define SVRCASE(X, STR) case GL_DEBUG_SEVERITY_ ## X ## _KHR : severityStr = STR; break; -#else // Desktop GL - #define SVRCASE(X, STR) case GL_DEBUG_SEVERITY_ ## X ## _ARB : severityStr = STR; break; -#endif - +#define SVRCASE(X, STR) case GL_DEBUG_SEVERITY_ ## X ## _ARB : severityStr = STR; break; case QGL_DEBUG_SEVERITY_NOTIFICATION: return; SVRCASE(HIGH, "Severity: High") SVRCASE(MEDIUM, "Severity: Medium") @@ -72,11 +67,7 @@ DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei le switch (source) { -#ifdef YQ2_GL3_GLES - #define SRCCASE(X) case GL_DEBUG_SOURCE_ ## X ## _KHR: sourceStr = "Source: " #X; break; -#else - #define SRCCASE(X) case GL_DEBUG_SOURCE_ ## X ## _ARB: sourceStr = "Source: " #X; break; -#endif +#define SRCCASE(X) case GL_DEBUG_SOURCE_ ## X ## _ARB: sourceStr = "Source: " #X; break; SRCCASE(API); SRCCASE(WINDOW_SYSTEM); SRCCASE(SHADER_COMPILER); @@ -88,11 +79,7 @@ DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei le switch(type) { -#ifdef YQ2_GL3_GLES - #define TYPECASE(X) case GL_DEBUG_TYPE_ ## X ## _KHR: typeStr = "Type: " #X; break; -#else - #define TYPECASE(X) case GL_DEBUG_TYPE_ ## X ## _ARB: typeStr = "Type: " #X; break; -#endif +#define TYPECASE(X) case GL_DEBUG_TYPE_ ## X ## _ARB: typeStr = "Type: " #X; break; TYPECASE(ERROR); TYPECASE(DEPRECATED_BEHAVIOR); TYPECASE(UNDEFINED_BEHAVIOR); @@ -228,22 +215,14 @@ int GL4_PrepareForWindow(void) gl4config.stencil = false; } -#ifdef YQ2_GL3_GLES3 - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); -#else // Desktop GL SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); -#endif // Set GL context flags. int contextFlags = 0; -#ifndef YQ2_GL3_GLES // Desktop GL (at least RPi4 doesn't like this for GLES3) contextFlags |= SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG; -#endif if (gl4_debugcontext && gl4_debugcontext->value) { @@ -344,21 +323,13 @@ int GL4_InitContext(void* win) GL4_SetVsync(); // Load GL pointrs through GLAD and check context. -#ifdef YQ2_GL3_GLES - if( !gladLoadGLES2Loader(SDL_GL_GetProcAddress)) -#else // Desktop GL if( !gladLoadGLLoader(SDL_GL_GetProcAddress)) -#endif { R_Printf(PRINT_ALL, "GL4_InitContext(): ERROR: loading OpenGL function pointers failed!\n"); return false; } -#ifdef YQ2_GL3_GLES3 - else if (GLVersion.major < 3) -#else // Desktop GL else if (GLVersion.major < 4 || (GLVersion.major == 4 && GLVersion.minor < 6)) -#endif { R_Printf(PRINT_ALL, "GL4_InitContext(): ERROR: glad only got GL version %d.%d!\n", GLVersion.major, GLVersion.minor); @@ -369,11 +340,7 @@ int GL4_InitContext(void* win) R_Printf(PRINT_ALL, "Successfully loaded OpenGL function pointers using glad, got version %d.%d!\n", GLVersion.major, GLVersion.minor); } -#ifdef YQ2_GL3_GLES - gl4config.debug_output = GLAD_GL_KHR_debug != 0; -#else // Desktop GL gl4config.debug_output = GLAD_GL_ARB_debug_output != 0; -#endif gl4config.anisotropic = GLAD_GL_ARB_texture_filter_anisotropic != 0; gl4config.major_version = GLVersion.major; @@ -382,25 +349,13 @@ int GL4_InitContext(void* win) // Debug context setup. if (gl4_debugcontext && gl4_debugcontext->value && gl4config.debug_output) { -#ifdef YQ2_GL3_GLES - glDebugMessageCallbackKHR(DebugCallback, NULL); - - // Call GL3_DebugCallback() synchronously, i.e. directly when and - // where the error happens (so we can get the cause in a backtrace) - glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR); -#else // Desktop GL glDebugMessageCallbackARB(DebugCallback, NULL); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); -#endif } // Window title - set here so we can display renderer name in it. char title[40] = {0}; -#ifdef YQ2_GL3_GLES3 - snprintf(title, sizeof(title), "Yamagi Quake II %s - OpenGL ES 3.0", YQ2VERSION); -#else snprintf(title, sizeof(title), "Yamagi Quake II %s - OpenGL 4.6", YQ2VERSION); -#endif SDL_SetWindowTitle(window, title); #if SDL_VERSION_ATLEAST(2, 26, 0) diff --git a/src/client/refresh/gl4/gl4_shaders.c b/src/client/refresh/gl4/gl4_shaders.c index 39a76ab9..2ca0542b 100644 --- a/src/client/refresh/gl4/gl4_shaders.c +++ b/src/client/refresh/gl4/gl4_shaders.c @@ -36,11 +36,7 @@ CompileShader(GLenum shaderType, const char* shaderSrc, const char* shaderSrc2) { GLuint shader = glCreateShader(shaderType); -#ifdef YQ2_GL3_GLES3 - const char* version = "#version 300 es\nprecision mediump float;\n"; -#else // Desktop GL const char* version = "#version 460\n"; -#endif const char* sources[3] = { version, shaderSrc, shaderSrc2 }; int numSources = shaderSrc2 != NULL ? 3 : 2; diff --git a/src/client/refresh/gl4/header/local.h b/src/client/refresh/gl4/header/local.h index bd4499a8..0e31ab89 100644 --- a/src/client/refresh/gl4/header/local.h +++ b/src/client/refresh/gl4/header/local.h @@ -34,23 +34,13 @@ // using system headers for their parsers/indexers but glad for real build // (in glad glFoo is just a #define to glad_glFoo or sth, which screws up autocompletion) // (you may have to configure your IDE to #define IN_IDE_PARSER, but not for building!) -#ifdef YQ2_GL3_GLES3 - #include -#else // desktop GL4 #define GL_GLEXT_PROTOTYPES 1 #include #include -#endif #else -#ifdef YQ2_GL3_GLES3 - #include "../glad-gles3/include/glad/glad.h" - // yes, this is a bit hacky, but it works :-P - #define glDepthRange glDepthRangef -#else // desktop GL4 - #include "../glad/include/glad/glad.h" -#endif +#include "../glad/include/glad/glad.h" #endif