Skip to content

Commit 39842e7

Browse files
committed
OpenGL: Rely on predefined macro __VERSION__ in GLSL language specification, rather than rolling our own. This predefined macro has been a language feature in all GLSL versions we support. See Section 3.3 Preprocessor.
1 parent cb90d28 commit 39842e7

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

code/globalincs/def_files.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ char *Default_main_fragment_shader =
15361536
"varying vec4 position;\n"
15371537
"varying vec3 lNormal;\n"
15381538
"\n"
1539-
"#if GLSL_VERSION == 120\n"
1539+
"#if __VERSION__ == 120\n"
15401540
" #define MAX_LIGHTS 2\n"
15411541
"#else\n"
15421542
" #define MAX_LIGHTS 8\n"
@@ -1727,7 +1727,7 @@ char *Default_main_fragment_shader =
17271727
" float dist;\n"
17281728
" #pragma optionNV unroll all\n"
17291729
" for (int i = 0; i < MAX_LIGHTS; ++i) {\n"
1730-
" #if GLSL_VERSION > 120\n"
1730+
" #if __VERSION__ > 120\n"
17311731
" if (i > n_lights)\n"
17321732
" break;\n"
17331733
" #endif\n"
@@ -1737,15 +1737,15 @@ char *Default_main_fragment_shader =
17371737
" lightDir = normalize(gl_LightSource[i].position.xyz);\n"
17381738
" float attenuation = 1.0;\n"
17391739
" #ifndef FLAG_DEFERRED\n"
1740-
" #if GLSL_VERSION > 120\n"
1740+
" #if __VERSION__ > 120\n"
17411741
" if (gl_LightSource[i].position.w == 1.0) {\n"
17421742
" #else\n"
17431743
" if (gl_LightSource[i].position.w == 1.0 && i != 0) {\n"
17441744
" #endif\n"
17451745
" // Positional light source\n"
17461746
" dist = distance(gl_LightSource[i].position.xyz, position.xyz);\n"
17471747
" lightDir = (gl_LightSource[i].position.xyz - position.xyz);\n"
1748-
" #if GLSL_VERSION > 120\n"
1748+
" #if __VERSION__ > 120\n"
17491749
" if (gl_LightSource[i].spotCutoff < 91.0) { // Tube light\n"
17501750
" float beamlength = length(gl_LightSource[i].spotDirection);\n"
17511751
" vec3 beamDir = normalize(gl_LightSource[i].spotDirection);\n"
@@ -1904,11 +1904,11 @@ char* Default_fxaa_fragment_shader =
19041904
"#extension GL_EXT_gpu_shader4 : enable\n"
19051905
"#define FXAA_EARLY_EXIT 1\n"
19061906
"#define FXAA_DISCARD 1\n"
1907-
"#if GLSL_VERSION == 120\n"
1907+
"#if __VERSION__ == 120\n"
19081908
" #define FXAA_GLSL_120 1\n"
19091909
" #define FXAA_GLSL_130 0\n"
19101910
"#endif\n"
1911-
"#if GLSL_VERSION > 120\n"
1911+
"#if _VERSION__ > 120\n"
19121912
" #define FXAA_GLSL_120 0\n"
19131913
" #define FXAA_GLSL_130 1\n"
19141914
"#endif\n"

code/graphics/gropenglshader.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,6 @@ static char *opengl_load_shader(shader_type type_id, char *filename, int flags)
309309
sprintf(version_string, "#version %d \n", GLSL_version);
310310
sflags += version_string;
311311

312-
if (GLSL_version >= 330) {
313-
sflags += "#define GLSL_VERSION 330\n";
314-
}
315-
else if (GLSL_version == 130) {
316-
sflags += "#define GLSL_VERSION 130\n";
317-
}
318-
else {
319-
sflags += "#define GLSL_VERSION 120\n";
320-
}
321-
322312
#ifdef __APPLE__
323313
sflags += "#define APPLE\n";
324314
#endif

0 commit comments

Comments
 (0)