glBindImageTexture
Binds a texture level as an image that shaders can read and write pixel by pixel.
Part of the family glBind*
Signature
void glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
How it works
Samplers can only read, with filtering. Images give shaders raw read/write access to individual texels with imageLoad and imageStore — how a compute shader writes its output into a texture.
Image units are separate from texture units; the shader declares layout(binding = N, rgba16f) uniform image2D img;
Parameters
Image unit — matches layout(binding = N).
Texture to bind.
Mip level.
GL_TRUE to bind all layers of an array/cube/3D texture.
Which layer when layered is GL_FALSE.
What the shader will do.
Common values
- GL_READ_ONLY
- Only imageLoad.
- GL_WRITE_ONLY
- Only imageStore.
- GL_READ_WRITE
- Both.
Format used by the shader, must match the image declaration: GL_RGBA8, GL_RGBA16F, GL_R32F…
Tips & pitfalls
The texture must have immutable storage or be complete at that level; sRGB formats cannot be bound as images.
Example
1// GLSL: layout(binding = 0, rgba16f) uniform writeonly image2D outImage;
2glBindImageTexture(0, outputTex, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA16F);