Linking Shaders Together into an OpenGL Program

Now that we’ve loaded and compiled a vertex shader and a fragment shader, the next step is to bind them together into a single program.

Understanding OpenGL Programs

An OpenGL program is simply one vertex shader and one fragment shader linked together into a single object. Vertex shaders and fragment shaders always go together. Without a fragment shader, OpenGL wouldn’t know how to draw the fragments that make up each point, line, and triangle; and without a vertex shader, OpenGL wouldn’t know where to draw these fragments.

We know that the vertex shader calculates the final position of each vertex on the screen. We also know that when OpenGL groups these vertices into points, lines, and triangles ...

Get OpenGL ES 2 for Android 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.