diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-01-16 16:43:22 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-22 22:16:07 +0100 |
commit | 821f30f7358ec3f0217b05a8d4af7101daf61678 (patch) | |
tree | 37e05e1df5237f7aad6ff93e52bdd83fd21731e1 /src/video | |
parent | 90fd8f8cda72d8ce985f11c0f7bc1b3bcab68a6e (diff) | |
download | openttd-821f30f7358ec3f0217b05a8d4af7101daf61678.tar.xz |
Codechange: [OpenGL] Use GLSL version 1.50 if available.
Diffstat (limited to 'src/video')
-rw-r--r-- | src/video/opengl.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/video/opengl.cpp b/src/video/opengl.cpp index 2f92b2717..b5ce12dee 100644 --- a/src/video/opengl.cpp +++ b/src/video/opengl.cpp @@ -500,15 +500,23 @@ static bool VerifyProgram(GLuint program) */ bool OpenGLBackend::InitShaders() { + const char *ver = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION); + if (ver == nullptr) return false; + + int glsl_major = ver[0] - '0'; + int glsl_minor = ver[2] - '0'; + + bool glsl_150 = (IsOpenGLVersionAtLeast(3, 2) || glsl_major > 1 || (glsl_major == 1 && glsl_minor >= 5)); + /* Create vertex shader. */ GLuint vert_shader = _glCreateShader(GL_VERTEX_SHADER); - _glShaderSource(vert_shader, lengthof(_vertex_shader_direct), _vertex_shader_direct, nullptr); + _glShaderSource(vert_shader, glsl_150 ? lengthof(_vertex_shader_direct_150) : lengthof(_vertex_shader_direct), glsl_150 ? _vertex_shader_direct_150 : _vertex_shader_direct, nullptr); _glCompileShader(vert_shader); if (!VerifyShader(vert_shader)) return false; /* Create fragment shader. */ GLuint frag_shader = _glCreateShader(GL_FRAGMENT_SHADER); - _glShaderSource(frag_shader, lengthof(_frag_shader_direct), _frag_shader_direct, nullptr); + _glShaderSource(frag_shader, glsl_150 ? lengthof(_frag_shader_direct_150) : lengthof(_frag_shader_direct), glsl_150 ? _frag_shader_direct_150 : _frag_shader_direct, nullptr); _glCompileShader(frag_shader); if (!VerifyShader(frag_shader)) return false; |