View Full Version : Strange changing textures

05-11-2001, 12:44 PM
Im making a cannon game. My problem is when I shoot my cannonball ( a texturemapped triangle strip ) one object in my scene changes to a different texture for that duration. FI call glBindTexture with the right texture before it is drawn, why is it binding the wrong texture?

Do I have to disable the texture after im done texturing the other objects??


05-11-2001, 01:59 PM
If that object isn't supposed to use a texture, then yes, you must disable texturing before rendering it (how would OpenGL know otherwise?).

Assuming that this isn't the problem, then you are obviously not binding the proper texture object. So, try this. In your debugger, set a breakpoint when it binds the texture for the object that changes textures. Then, after the object is drawn, insert the following lines:

int DebugInt;
glGetIntegerv(GL_TEXTURE_2D_BINDING, &DebugInt);

Set a breakpoint after this line. If the value you bound matches the value you got, then the value you used in glBindTexture is wrong. It may have been overwritten somehow with the value of the new texture.

05-12-2001, 11:34 AM
thanks, but see, until I shoot the cannon it has the right texture. Its the powerbar for my cannon, it uses orthographic drawing, and heres the code for it.

gluOrtho2D(0, 640, 0, 480);
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexCoord2f(0.0f, 0.0f); glVertex2f(160.0, 100.0);
glTexCoord2f(1.0f, 0.0f); glVertex2f(480.0, 100.0);
glTexCoord2f(1.0f, 1.0f); glVertex2f(480.0, 75.0);
glTexCoord2f(0.0f, 1.0f); glVertex2f(160.0, 75.0);

So somehow the when i bind the cannonball texture onto the cannonball (it wont do that until its fired) it over-writes texture[2] into the texture[1] (thats the texture it changes to). Ive temporarily tried changing the powerbars texture into 0 and 1 but they didn't change, only the third.

Any more help would be appreciated, thanks!

[This message has been edited by iNsaNEiVaN (edited 05-12-2001).]

[This message has been edited by iNsaNEiVaN (edited 05-12-2001).]

05-12-2001, 11:46 AM
As I suggested, look at the actual values for Texture[1] and Texture[2]. Are they the same after the cannon fires? If so, then you're probably overwritting it yourself (possibly via a wild write). You can set various breakpoints to check to see if it changes and where.

05-12-2001, 12:10 PM
I'm about as beginner as it gets. Which command in Win32 opengl overwrites textures? This program isn't even very complicated!