September 2018
Intermediate to advanced
472 pages
15h 36m
English
If you'd rather not clutter up your vertex shader code with the layout qualifiers (or you're using a version of OpenGL that doesn't support them), you can define the attribute indexes within the OpenGL program. We can do so by calling glBindAttribLocation just prior to linking the shader program. For example, we'd add the following code to the main OpenGL program just before the link step:
glBindAttribLocation(programHandle, 0, "VertexPosition"); glBindAttribLocation(programHandle, 1, "VertexColor");
This would indicate to the linker that VertexPosition should correspond to generic attribute index 0 and VertexColor to index 1.
Similarly, we can specify the color number for the ...
Read now
Unlock full access