Quite simple GL_TEXTURE_BORDER_COLOR seems to do precicely nothing.
I got it set to clamp, and cant think of any reason why it does nothhing at all, is there something else I need to enable?.
width
The width of the texture image. Must be 2n + 2(border) for some integer n.
height
The height of the texture image. Must be 2m + 2(border) for some integer m.
border
The width of the border. Must be either 0 or 1.
…
This is very strange. It only crashes if you use a 256* 256 texture, use a 6464 or 128128 and in runs, until you select that texture, then it slows right down and draws a nonesense texture.
Well, texture border color and texture borders are a bit different. When you set the border parameter in glTexImage2D to 1, what you are saying is that you are passing in a 258x258 (or 66x66, or 130x30) image. OpenGL then uses the border pixels in these images as, well, borders.
Texture border color simply sets a single color that the very edge of the texture should be. With GL_CLAMP, a texture coordinate of (0.0f, 0.0f) should give you 1/4 of the lower left hand pixel, and 3/4 of the border color.
Is the border color you want significantly different from the texture color? It’s hard to notice sometimes, especially when the texture resolution is high.
Hmmm,
So I dont need to set the border in glTexImage2d();
But still I get nothing. In the book I have it says I can use the border_color and clamping to make a texture appear in one spot on a polygon, as it will clamp the edges to the border color with alpha of 0, then using alpha test it will only texture where the coords are between 0 and 1, and leave the rest of the poly untouched.
Is this possible then? and if the border colour defaults to 0,0,0,0 why when you clamp a texture doesnt it draw black around it.
Whenever I have GL_CLAMP on, I can clearly see at the border of the texture where it is being blended with the border color.
Maybe a driver thing? If your graphics card decides to use GL_CLAMP_TO_EDGE_EXT instead of GL_CLAMP, that would definitely get rid of the texture border effects.
Why? Because the border is half a texel outside the (0,0)-(1,1) texture area (the “edge” as in GL_CLAMP_TO_EDGE is half a texel inside). Plain GL_CLAMP actually clamps it half way between the last texel of the texture and the border.
To see your border and the texture fading away into it, you’ll need to specify texture coordinates like
glTexCoord2f(-0.5/64,-0.5/64); // For a 64x64 texture
glTexCoord2f(1+0.5/64,1+0.5/64);
Anyway, yes, a bit of a pain. OpenGL’s texture coordinates make more sense when you’re doing “nearest colour” rather than bilinear interpolation because in the latter case the pure texture colours end up in the middles of texels.