Skip to content

Commit a0aa2c9

Browse files
SiegeLordExSiegeLord
authored andcommitted
Don't automatically add a #version to GL3 shaders on MacOS.
This messes up with custom shaders. MacOS is happy to use any specific version above 330, depending on which features you are actually using in the shader source.
1 parent 93d7315 commit a0aa2c9

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/opengl/ogl_shader.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,7 @@ static bool glsl_attach_shader_source(ALLEGRO_SHADER *shader,
124124
if ((*handle) == 0) {
125125
return false;
126126
}
127-
#ifdef ALLEGRO_MACOSX
128-
{
129-
const char *version_string = glGetString(GL_SHADING_LANGUAGE_VERSION);
130-
int version[2];
131-
sscanf(version_string, "%d.%d", &version[0], &version[1]);
132-
char version_line[] = "#version XXXXXXXXXX";
133-
ASSERT(version[0] < 10 && version[1] < 100);
134-
snprintf(version_line, sizeof(version_line), "#version %d%d\n", version[0], version[1]);
135-
136-
const char *sources[] = {version_line, source};
137-
138-
glShaderSource(*handle, 2, sources, NULL);
139-
}
140-
#else
141127
glShaderSource(*handle, 1, &source, NULL);
142-
#endif
143128
glCompileShader(*handle);
144129
glGetShaderiv(*handle, GL_COMPILE_STATUS, &status);
145130
if (status == 0) {

src/shader_source.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static const char *default_glsl_vertex_source =
3838
"}\n";
3939

4040
static const char *default_glsl_pixel_source =
41+
"#version 330 core\n"
4142
"#ifdef GL_ES\n"
4243
"precision lowp float;\n"
4344
"#endif\n"
@@ -99,6 +100,7 @@ static const char *default_glsl_minimal_pixel_source =
99100
"}\n";
100101

101102
static const char *default_glsl_vertex_source_gl3 =
103+
"#version 330 core\n"
102104
"in vec4 " ALLEGRO_SHADER_VAR_POS ";\n"
103105
"in vec4 " ALLEGRO_SHADER_VAR_COLOR ";\n"
104106
"in vec2 " ALLEGRO_SHADER_VAR_TEXCOORD ";\n"
@@ -120,6 +122,7 @@ static const char *default_glsl_vertex_source_gl3 =
120122
"}\n";
121123

122124
static const char *default_glsl_pixel_source_gl3 =
125+
"#version 330 core\n"
123126
"#ifdef GL_ES\n"
124127
"precision lowp float;\n"
125128
"#endif\n"
@@ -163,6 +166,7 @@ static const char *default_glsl_pixel_source_gl3 =
163166
"}\n";
164167

165168
static const char *default_glsl_minimal_pixel_source_gl3 =
169+
"#version 330 core\n"
166170
"#ifdef GL_ES\n"
167171
"precision lowp float;\n"
168172
"#endif\n"

0 commit comments

Comments
 (0)