Direct State AccessGL 4.5
glTextureParameteriv
Sets a texture setting that takes several integers at once, such as the channel swizzle.
Signature
void glTextureParameteriv(GLuint texture, GLenum pname, const GLint *params);
How it works
The array form, for settings with more than one value. The common one is GL_TEXTURE_SWIZZLE_RGBA, which says where each channel the shader reads comes from. A one-channel GL_R8 glyph atlas with the swizzle { GL_ONE, GL_ONE, GL_ONE, GL_RED } reads in the shader as white with the glyph shape in alpha, so ordinary text shaders work unchanged, using a quarter of the memory of RGBA.
Parameters
textureGLuint
The texture.
pnameGLenum
Which setting.
Common values
- GL_TEXTURE_SWIZZLE_RGBA
- 4 values, each GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_ZERO or GL_ONE.
- GL_TEXTURE_BORDER_COLOR
- 4 values used outside the texture with GL_CLAMP_TO_BORDER (often via glTextureParameterfv).
paramsconst GLint *
Pointer to the values.
Tips & pitfalls
Direct State Access (GL 4.5): the object is passed as a parameter, so nothing needs to be bound and no global state is disturbed.
Example
example.cpp
1GLint swz[] = { GL_ONE, GL_ONE, GL_ONE, GL_RED };
2glTextureParameteriv(atlas, GL_TEXTURE_SWIZZLE_RGBA, swz);