September 2018
Intermediate to advanced
472 pages
15h 36m
English
As of OpenGL 4.2, we now have the ability to specify the default value of the sampler's binding (the value of the sampler uniform) within GLSL. In the previous example, we set the value of the uniform variable from the OpenGL side using the following code:
int loc = glGetUniformLocation(programHandle, "Tex1"); glUniform1i(loc, 0);
Instead, if we're using OpenGL 4.2, we can specify the default value within the shader using the layout qualifier, as shown in the following statement:
layout (binding=0) uniform sampler2D Tex1;
This simplifies the code on the OpenGL side and makes this one less thing we need to worry about. The example code that accompanies this book uses this technique to specify the ...
Read now
Unlock full access