PDA

View Full Version : Texture matrix problems



kaysoft
12-08-2002, 09:29 AM
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

GameMaker
12-08-2002, 10:21 AM
I think you need to reset your texture matrix before drawing the second one.

glMatrixMode(GL_TEXTURE);
glLoadIdentity();

yakuza
12-08-2002, 10:30 AM
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).]

kaysoft
12-08-2002, 01:25 PM
Thanks, makes sense.
I will try that later and tell you.

kaysoft
12-09-2002, 08:14 AM
That didnt work, it didnt scale the matrix. Any other ideas?

yakuza
12-09-2002, 08:48 AM
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

kaysoft
12-09-2002, 11:22 AM
Correct, thanks!