Interface Blocks

Shader variables shared with the application or between stages can be, and sometimes must be, organized into blocks of variables. Uniform variables can be organized into uniform blocks, input and output variables into in and out blocks, and shader storage buffers into buffer blocks.

These all have a similar form. First, we’ll use uniform to demonstrate.

uniform b {       // "uniform" or "in" or "out" or "buffer"    vec4 v1;      // list of variables    bool v2;      // ...};                // access members as "v1" and "v2"

Or:

uniform b {     // "uniform" or "in" or "out" or "buffer"    vec4 v1;    // list of variables    bool v2;    // ...} name;         // access ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth 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.