0

I am writing a simple OpenGL app, that applies a 2D texture to a triangle strip. My fragment shader does not compile (I am using PyOpenGL):

    FRAGMENT_SHADER = shaders.compileShader("""#version 130
    in vec4 color_v;
    layout(location = 0) out vec4 color_out;
    void main()
    {
        color_out = color_v;
    };""", gl.GL_FRAGMENT_SHADER)

The error callback:

RuntimeError: ("Shader compile failure (0): ERROR: 0:3: 'layout' : syntax error syntax         
error\n\n", ['#version 130\n        in vec4 color_v;\n        layout(location = 0) out 
vec4 color_out;\n        void main()\n        {\n            color_out = color_v;\n        
};'], GL_FRAGMENT_SHADER)

and the call to load the texture into the FBO:

gl.glFramebufferTexture2D(gl.GL_FRAMEBUFFER, gl.GL_COLOR_ATTACHMENT0, gl.GL_TEXTURE_2D, self.ID, 0)

Can anyone help, please?

Raoul
  • 1,872
  • 3
  • 26
  • 48
  • ok, so it seems the `layout` call was introduced in GLSL 1.50, which would cause the problem. How was this done in previous versions? – Raoul Jul 09 '14 at 20:39
  • 1
    `glBindAttribLocation()` before linking or `glGetAttribLocation()` after linking. Or [`ARB_explicit_attrib_location`](http://www.opengl.org/registry/specs/ARB/explicit_attrib_location.txt). – genpfault Jul 09 '14 at 20:49

0 Answers0