Opengl 4.0 Texture issue

Asked by At

Hi I am trying to render texture on a rectangle. I am using GL_CLAMP_TO_BORDER because I dont want texture to repeat itself.

glTextureParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTextureParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

I am expecting output to be something like this : Notice non-texels are grey which is its face color. enter image description here

But I am getting this output : enter image description here

Area mentioned in no 2 I guess can be resolved if I enable the blending but I am not getting any solution for Area 1. I know I havn't shared any code because I really can't ,is there any additional gl calls I need to make to resolve the issue ?

1 Answers

5
Nicol Bolas On Best Solutions

GL_CLAMP_TO_BORDER clamps to the border color defined in the texture/sampler object. That is, texture coordinates outside the [0, 1] range will fetch that border color.

If you didn't set that border color, it will likely be black.

The clamping mode you probably want is GL_CLAMP_TO_EDGE. That means that the color you get for out-of-range fetches is the color of the nearest edge texels of the texture.