Incresing texture border width

Hello, I know the default border can be set as follow:


float color[] = { 1.0f, 0.0f, 0.0f, 1.0f };
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color);

But I’d like to know how to increase or decrease the border width?


The border doesn’t have a width. The “border” is everything that’s outside of the texture.

The border width is set via the border parameter to glTexImage2D and cannot be subsequently changed. In older versions of OpenGL there were only two valid values for it: 0 or 1. Newer versions of OpenGL require it to be 0.

The idea behind texture border, border colour and clamp-to-border mode is that any texture addressing outside of the 0…1 range will, if a border is specified, use the border colour. A border width of anything other than 0 or 1 therefore makes no sense: texture border is binary; it’s either there or not. The fact that you seem to be asking to dynamically change this behaviour at runtime, and possibly set width other than 0 or 1, suggests that you have some specific behaviour in mind that you want to have happen. It may be more helpful if you tell us what you actually want to do here.

That’s what I was about to ask, I’m using OpenGL version 4.3 and it seems it doesn’t matter whether the border is set to 0 or 1. Why?

In the OpenGL 3+ core profile, the border parameter to glTexImage2D() etc must be zero, otherwise a GL_INVALID_VALUE error is generated. In theory, it should still work in a compatibility profile, although personally I wouldn’t count on it. Texture borders have a history of being poorly supported.