0

I am trying to get UBOs working, however I get a compilation error in the fragment shader:

ERROR 0:5:"(": synrax error.

Fragment Shader:

layout(std140) uniform Colors
{
    vec3  SCol;
    vec3  WCol;
    float DCool;
    float DWarm;
}colors;

Where am I going wrong?

genpfault
  • 51,148
  • 11
  • 85
  • 139
user1128265
  • 2,891
  • 10
  • 29
  • 34
  • 1
    Where's your `#version` directive? What's the value of `GL_SHADING_LANGUAGE_VERSION`? – genpfault Jan 22 '13 at 16:53
  • If I add #version, it gives me another error: GLSL error: #version must occur before any other statement in the program – user1128265 Jan 22 '13 at 17:02
  • However it doesn't complaint in the vertex shader. – user1128265 Jan 22 '13 at 17:03
  • 2
    Please post your *entire* shader, and tell us what line 5 is. And if you're not [using a #version declaration](http://www.opengl.org/wiki/GLSL_Core_Language#Version), please *start*. – Nicol Bolas Jan 22 '13 at 19:33

1 Answers1

1

At the begining of your fragment shader source file (the very first line) put this:

#version 140

This means that you are telling the GLSL compiler that you use the version 1.40 of the shading language (you can, of course, use a higher version - see Wikipedia for details).

Alternatively, if your OpenGL driver (and/or hardware) doesn't support GLSL 1.40 fully (which is part of OpenGL 3.1), but only GLSL 1.30 (OpenGL 3.0), you can try the following:

#version 130
#extension GL_ARB_uniform_buffer_object : require

However, this one will work only if your OpenGL 3.0 driver supports the GL_ARB_uniform_buffer_object extension.

Hope this helps.

Tomek
  • 353
  • 2
  • 7