textures flickering

Textures in my JOGL game tend to flicker, or rather small parts of them flicker. For example, if I texture the side of a billboard-tree with a 256*256 texture, much of the side of the texture is transparent (since the tree is not nearly a square), but a mysterious vertical line along the very left edge will flicker on a off, while similar but less-noticable lines flicker in the opaque part as well. I don’t think this can be “my fault” since I’m just telling JOGL to put a texture there, it’s handling the pixel calculations. Perhaps the vertical line appears when JOGL mistakenly offsets some pixels by 1 and the ones on the right (opaque side) of the image scroll to the left now and then? The line is indeed the same colors as the opaque part of the image. I really don’t know what else to think. O yea, textured grass flickers as well, but only in some places, and in patches instead of lines. Any ideas why these things happen and how I can fix them? Mipmapping or something?

Try clamping the textures:
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_S_WRAP, GL_CLAMP);
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_T_WRAP, GL_CLAMP);

This will prevent pixels being feteched from the other side of the texture at the edges. Which might be what you are seeing.

i’ll try that, thanks

uh, i’m getting compiler errors that variables GL_TEXTURE_S_WRAP and GL_TEXTURE_T_WRAP don’t exist… what do I import?

It should be GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T.

Hmm. It says GL_TEXTURE_S_WRAP and GL_TEXTURE_T_WRAP in my old red book. They must have changed it since the book was printed.

wow, it… worked! thanks!

hmmm… well the lines are gone, but now once in a while a thick vertical strip of each transparently-textured object will simply vanish for one repaint and reappear in the next. Any more magical solutions?

You don’t happen to have a screenshot or a demo. It’s diffucult to know whats happening from just that description.

Btw. Can it be z-fighting?

z-fighting? I haven’t heard that term, but do you mean two objects with the same z values flip-flopping? I’m not positive of the answer to that, but I don’t think it should matter which one is drawn first if they have the same z value… should it? Because sometimes one will obscure the other incorrectly in such a case but there’s no way I can think of to re-compare them if they have the same z, at least no sensible way