Texture mapping issue

I have a weird texture mapping issue. When I move away from my objects, parts of the texture gets trashy.
http://www.members.home.net/deseric/ok.jpg http://www.members.home.net/deseric/bad.jpg http://www.members.home.net/deseric/bad2.jpg

please, don’t tell me it is because the texture is too ugly and the implementation is rejecting it!!

This is the code I use before rendering the object :

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glBindTexture(GL_TEXTURE_2D, texnum );

I am rendering my object using immediate mode.

I have an Ati Radeon, It might be a driver issue but I am not too certain because when I use microsoft software implementation, I actually get a texture id from glGenTexture, but my object is NOT texture mapped.
No errors are get for glGetError();

To add to it, if I use mipmaps, then everything works fine in both hardware and software…

[This message has been edited by Gorg (edited 03-09-2001).]

I’m dont know if this is your problem but every example I’ve ever seen calls glBindTexture before glTexParameteri and glTexEnv. Hope that solves your problem!

[This message has been edited by BwB (edited 03-09-2001).]

Already tried that in despair!!

It actually doesn’t matter when you call glBind because opengl uses states. So if it has to render a texture, it uses the current texture states it has whenever they have been set.

Originally posted by Gorg:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glBindTexture(GL_TEXTURE_2D, texnum );
(edited 03-09-2001).]

The wrap calls are changing the state of the last bound texture not the one pointed to by your variable texnum. Like the last guy said bind the texture first. It may help to see the code you used to create your texture.

Like I said I tried it before. And I tried again just in case. No luck. I’ll keep it before now though.

This is my loading code :

I simply load a raw file in buffer.

glGenTextures( 1, &texnum );
glBindTexture( GL_TEXTURE_2D, texnum );
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer ); // doesn’t work with this
or
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, 64, 64, GL_RGB, GL_UNSIGNED_BYTE, buffer ); work with this

[This message has been edited by Gorg (edited 03-09-2001).]

[This message has been edited by Gorg (edited 03-09-2001).]

It looks like bad mipmaps to me. What are your filtering modes set to? Remember that the default texture filter modes in OpenGL use mipmapping. If your texture does not have mipmaps but has a filter mode set that requires them, the texture should be marked by the driver as inconsistent and disabled behind your app’s back.

Based on the description of your problem, I suspect that it is the MS renderer that is correct.

  • Matt

Silly me. You are totally right Matt. I actually didn’t bother to look at the default value in the red book, and I assumed the filtering mode wasn’t using mipmaps.

Ah inexperience. I have to stop assuming!!

Originally posted by Gorg:
[b]Already tried that in despair!!

It actually doesn’t matter when you call glBind because opengl uses states. So if it has to render a texture, it uses the current texture states it has whenever they have been set.[/b]

This is an error made very often and I just wanted to emphasize this:
Texture objects store the TexParameter as part of the texture object, so if you call glBindTexture for the first time it will have the default parameters for wrap, minification, magnification, border color, and priority which are not what you might have just set.
(Read OpenGL 1.2.1 specs page 133 BindTexture and chapter 3.8.7 on default parameters.)