GL_EXT_texture_border_clamp#

Supported Hardware#

Series6, Series6XE, Series6XT

Valid APIs#

OpenGL ES 2.0, OpenGL ES 3.x

Description#

When sampling from a texture, if the requested UV coordinates reference a place outside of the texture, a wrapping behaviour is needed to specify what happens. OpenGL ES has three strategies depending on version:

  • OpenGL ES 2.0 allows either clamping the UVs to the edge of the texture or wrapping around to the start of the valid range.

  • OpenGL ES 3.0 added mirrored repeat, which acts as if the texture was flipped each time it wraps the coordinates.

This extension adds an additional behaviour - returning an application-defined border colour. This allows a shader to draw a texture to the screen with a dedicated border colour if so desired. It also gives the shader a cheap way to detect that a UV coordinate has gone out of range, without complex shader logic.

Example#

// Set the texture's border colour to opaque red
//                        Red   Green Blue  Alpha
GLfloat borderColour[] = {1.0f, 0.0f, 0.0f, 1.0f};
glBindTexture(GL_TEXTURE_2D, texture)
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR_EXT, borderColour);
// Set the texture to use the border clamp wrapping mode.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER_EXT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER_EXT);