Using program pipelines

Program pipeline objects were introduced as part of the separable shader objects extension, and moved into core OpenGL with version 4.1. They allow programmers to mix and match shader stages from multiple separable shader programs. To understand how this works and why it may be useful, let's go through a hypothetical example. 

Suppose we have one vertex shader and two fragment shaders. Suppose that the code in the vertex shader will function correctly with both fragment shaders. I could simply create two different shader programs, reusing the OpenGL shader object containing the vertex shader. However, if the vertex shader has a lot of uniform variables, then every time that I switch between the two shader programs, ...

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.