There's more...

In the preceding example, we used glCreateShaderProgramv to create each single-stage program. However, you can also use the more familiar glCreateProgram to do the same thing. In fact, if you want to create a program with more than one stage (say, a vertex shader and a geometry shader), you need to use glCreateProgram. However, since we want to use it with shader pipelines, it is important to use glProgramParameteri to designate it as a separable program. Here's an example of creating a single stage program using glCreateProgram, assuming that vertShader is the name of a previously-compiled vertex shader object:

GLuint program = glCreateProgram();glProgramParameteri(program, GL_PROGRAM_SEPARABLE, GL_TRUE);glAttachShader(program, ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.