PDA

View Full Version : Texture maps in nested transforms



traDMB
11-27-2002, 02:17 PM
Hi,
I've got the following code:

glPushMatrix();
glTranslatef (0.178, 0.0, 0.0);
drawRightLeg();
glPopMatrix();

glPushMatrix();
glBindTexture(GL_TEXTURE_2D, texture[filter]);
glTranslatef (0.0, 0.0, 0.08);
glScalef (0.275, 0.152, 0.153);
drawSphere(1.0);
glPopMatrix();

glPushMatrix();
glRotatef ((GLfloat) EXTEN, 1.0, 0.0, 0.0);
glRotatef ((GLfloat) BTWIS, 0.0, 1.0, 0.0);
glRotatef ((GLfloat) ROT, 0.0, 0.0, 1.0);
drawBody();
glPopMatrix();

I just want the texture to map to that sphere inside the push/pop, but instead it's being applied to the whole object (the leg, torso, and body.. i left out some code).

How do I get it to just texture that one sphere?

Thanks!
- Jen

nexusone
11-27-2002, 02:39 PM
The glPush/pop have not effect on the texture setting.

If you just want to texture the sphere, then after drawing it, use glDisable(GL_TEXTURE_2D). Also remember to use glEnable(GL_TEXTURE_2D) before drawning the sphere, or on the next pass drawing the sphere will not have any texture.


then the rest will only be what ever color you have selected.



Originally posted by traDMB:
Hi,
I've got the following code:

glPushMatrix();
glTranslatef (0.178, 0.0, 0.0);
drawRightLeg();
glPopMatrix();

glPushMatrix();
glBindTexture(GL_TEXTURE_2D, texture[filter]);
glTranslatef (0.0, 0.0, 0.08);
glScalef (0.275, 0.152, 0.153);
drawSphere(1.0);
glPopMatrix();

glPushMatrix();
glRotatef ((GLfloat) EXTEN, 1.0, 0.0, 0.0);
glRotatef ((GLfloat) BTWIS, 0.0, 1.0, 0.0);
glRotatef ((GLfloat) ROT, 0.0, 0.0, 1.0);
drawBody();
glPopMatrix();

I just want the texture to map to that sphere inside the push/pop, but instead it's being applied to the whole object (the leg, torso, and body.. i left out some code).

How do I get it to just texture that one sphere?

Thanks!
- Jen



[This message has been edited by nexusone (edited 11-27-2002).]

traDMB
11-27-2002, 02:48 PM
Thanks - that did it! I just enable before I want to texture something and disable when I'm done.

- Jen

nexusone
11-27-2002, 02:55 PM
Of course if you had more then one texture to apply just disable at the end.

//Robot
glPushMatrix();
glEnable(GL_TEXTURE_2D);
//draw head
glPushMatrix();
glBindTexture( GL_TEXTURE_2D, head );
DrawHead();
glPopMatrix();
//draw body
glPushMatrix();
glBindTexture( GL_TEXTURE_2D, body );
DrawBody();
glPopMatrix();
glDisable(GL_TEXTURE_2D);
glPopMatrix();


Originally posted by traDMB:
Thanks - that did it! I just enable before I want to texture something and disable when I'm done.

- Jen