O'Reilly logo

OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition by Bill M. Licea-Kane, John M. Kessenich, Graham Sellers, Dave Shreiner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Binding Textures to Image Units

Just as sampler variables represent texture units in the OpenGL API, so do image variables represent a binding to an image unit in the OpenGL API. Image uniforms declared in a shader have a location that may be retrieved by calling glGetUniformLocation(). This is passed in a call to glUniform1i() to set the index of the image unit to which the image uniform refers. This binding may also be specified directly1 in the shader using a binding layout qualifier as shown in the declaration of image4 in Example 11.1. By default, an image uniform has the binding 0, and so if only one image is used in a shader, there is no need to explicitly set its binding to 0. The number of image units supported by the OpenGL implementation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required