View Full Version : How to clear a texture color?

07-30-2004, 01:18 PM

I am trying to figure out if there is a siomple way to clear the color of a texture. The reason I ask is that I am loading an image into a sub region of the texture, and then using that area to be mapped to quads for an image viewer. This all works great, but there is a issue where at the right and bottom edges I get a black line from linear interpolation with the black area of the rest of the texture I am not using.

I am using GL_CLAMP_TO_EDGE_SGIS to elimiate this problem on the border of the texture, but this has no effect on my "interior" border aliasing effect. What I would like to do is set the color of the texture to match my background color that I'm compositing the image on, so the effect will dissappear. I know I could manually create a larger image and add a pixel row of color to the right and bottom, but I thought there might be something more straightforward.

I tried this little snippet, but it didnt work...

glTexImage2D(GL_TEXTURE_2D,0,3, tex_width , tex_height, 0,GL_RGB,GL_UNSIGNED_BYTE,NULL);

glClearColor(back_color.Red()/256.0f, back_color.Green()/256.0f, back_color.Blue()/256.0f, 1.0f );


Any easy ways to clear the texture color? Will glClear(GL_TEXTURE_BIT) work if I do it correctly?

Thanks in advance for any help!


07-31-2004, 08:59 PM
There is noway to clear a textureunless you'reusing render to texture.

glTexSubImage2D is your only simple option.

08-02-2004, 03:44 PM
Thanks for the response Dorbie.