Texture matrix problems

I have 2 textures which one of them, I need to alter its matrix (scaling.). What I am currently doing is:

bindthefirsttexture();

glPushMatrix();
glMatrixMode(GL_TEXTURE);
glLoadIdentity();

glScalef(2,2,0);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

bindthesecondtexture();

do some other stuff here.

However, that matrix transformation is applied on the second texture too! What am i doing wrong here?
Thanks

I think you need to reset your texture matrix before drawing the second one.

glMatrixMode(GL_TEXTURE);
glLoadIdentity();

You need to push the matrix stack after loading the texture matrix, otherwise you’re pushing the modelview stack.

Edit: And pop the stack before switching back to the modelview.

glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
do stuff
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
do the other stuff

Hope that helps

[This message has been edited by yakuza (edited 12-08-2002).]

Thanks, makes sense.
I will try that later and tell you.

That didnt work, it didnt scale the matrix. Any other ideas?

Make sure you did your drawing after scaling the texture matrix, but before popping the texture matrix stack, otherwise you lose the changes you made.

glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glScalef();
Draw_stuff_that_uses_scaled_texture_matrix();
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
do the other stuff

Correct, thanks!