PDA

View Full Version : Incresing texture border width



Lee_Jennifer_82
01-24-2016, 05:23 PM
Hello, I know the default border can be set as follow:


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

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?

Thanks.

GClements
01-24-2016, 07:03 PM
The border doesn't have a width. The "border" is everything that's outside of the texture.

mhagain
01-25-2016, 04:17 AM
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.

Lee_Jennifer_82
01-25-2016, 02:47 PM
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?

GClements
01-25-2016, 08:22 PM
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.