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?

4
  • 1
    Where's your #version directive? What's the value of GL_SHADING_LANGUAGE_VERSION? Commented Jan 22, 2013 at 16:53
  • If I add #version, it gives me another error: GLSL error: #version must occur before any other statement in the program Commented Jan 22, 2013 at 17:02
  • However it doesn't complaint in the vertex shader. Commented Jan 22, 2013 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, please start. Commented Jan 22, 2013 at 19:33

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.