1

The title is my question. Is there any replacement of 'binding' layout qualifier for OpenGL v 4.1?

I'm using MacOS and Xcode so if I run OpenGL 4.2 I got an error of glewinit saying 'Missing GL version'.

If I run this code with OpenGL 4.1, of course, it can't recognize 'binding' keyword.

My vertex shader code is :

#version 410

layout (location=0) in vec3 pos;
layout (location=1) in vec2 texCoord;

out vec2 tc;

uniform mat4 mv_matrix;
uniform mat4 proj_matrix;

layout (binding=0) uniform sampler2D samp;  // not used in vertex shader

void main(void) {
    gl_Position = proj_matrix * mv_matrix * vec4(pos, 1.0);
    tc = texCoord;
}

and my fragment shader code is :

#version 410

in vec2 tc;  // interpolated incoming texture coordinate

out vec4 color;

uniform mat4 mv_matrix;
uniform mat4 proj_matrix;

layout (binding=0) uniform sampler2D samp;

void main(void) {
    color = texture(samp, tc);
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
shinerd
  • 11
  • 1

1 Answers1

-2

You just have to:

_Remove the layout qualifiers (including location assignment). like this:

uniform sampler2D samp;

BARUCH
  • 1
  • 2