Search code examples
copenglglslsdl

OpenGL error: unrecognized layout identifier `binding'


my fragment shader

#version 330
layout(std430, binding = 0) buffer TVertex
{
   mediump vec4 vertex[]; 
};

results in

error: unrecognized layout identifier `binding'

I'm using SDL on ubuntu with

SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 3 );

which gives me

Mesa DRI Intel(R) HD Graphics 4400 (HSW GT2) 
4.5 (Core Profile) Mesa 21.2.6

what am I doing wrong?


Solution

  • Setting the binding point inside the shader is only supported starting with version 4.2, your shader is specified to use verrsin 3.3. See the docs Either you change your version to #version 420. Or you set the binding point inside your application with

    GLuint bindingPoint = 0;
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, bindingPoint, bufferObject);