Skip to content

Commit

Permalink
libgui|GLShader: Default to GLSL version 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 28, 2017
1 parent ddd3580 commit 8adb74b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions doomsday/sdk/libgui/src/graphics/glshader.cpp
Expand Up @@ -114,9 +114,11 @@ Block GLShader::prefixToSource(Block const &source, Block const &prefix)

void GLShader::compile(Type shaderType, IByteArray const &source)
{
static QByteArray const DEFAULT_VERSION("#version 120\n");

#ifndef LIBGUI_GLES2
// With non-ES OpenGL, ignore the precision attributes.
static QByteArray prefix("#ifndef GL_ES\n#define lowp\n#define mediump\n#define highp\n#endif\n");
static QByteArray const PREFIX("#ifndef GL_ES\n#define lowp\n#define mediump\n#define highp\n#endif\n");
#endif

DENG2_ASSERT(shaderType == Vertex || shaderType == Fragment);
Expand All @@ -142,7 +144,13 @@ void GLShader::compile(Type shaderType, IByteArray const &source)

// Prepare the shader source. This would be the time to substitute any
// remaining symbols in the shader source.
Block src = prefixToSource(source, prefix + predefs);
Block src = prefixToSource(source, PREFIX + predefs);

// If version has not been specified, use the default one.
if (!src.contains("#version"))
{
src = DEFAULT_VERSION + src;
}

char const *srcPtr = src.constData();
LIBGUI_GL.glShaderSource(d->name, 1, &srcPtr, 0);
Expand Down

0 comments on commit 8adb74b

Please sign in to comment.