How it works...

The process is very similar to the process shown in the Getting a list of active vertex input attributes and locations recipe. I will focus on the main differences.

The first and most obvious is that we use GL_UNIFORM instead of GL_PROGRAM_INPUT as the interface that we are querying in glGetProgramResourceiv and glGetProgramInterfaceiv. Second, we query for the block index (using GL_BLOCK_INDEX in the properties array). The reason for this is that some uniform variables are contained within a uniform block (see the Using uniform blocks and uniform buffer objects recipe). For this example, we only want information about uniforms that are not within blocks. The block index will be -1 if the uniform variable is not within a ...

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.