Shaders & programsGL 2.0
glLinkProgram
Links the attached shaders into an executable program.
Signature
void glLinkProgram(GLuint program);
How it works
Linking checks that the stages fit together: every in of the fragment shader must match an out of the vertex shader with the same name and type, uniforms with the same name must have the same type, and so on.
Like compiling, it never fails loudly. Check glGetProgramiv(GL_LINK_STATUS) and read glGetProgramInfoLog.
Parameters
programGLuint
Program to link.
Example
example.cpp
1glLinkProgram(program);
2GLint ok = GL_FALSE;
3glGetProgramiv(program, GL_LINK_STATUS, &ok);
4if (!ok) {
5 char log[1024];
6 glGetProgramInfoLog(program, sizeof(log), nullptr, log);
7 std::fprintf(stderr, "Link error:\n%s\n", log);
8}