Results 1 to 4 of 4

Thread: Texture maps in nested transforms

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Ann Arbor, MI
    Posts
    3

    Texture maps in nested transforms

    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.0;
    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

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Texture maps in nested transforms

    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.0;
    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).]

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Ann Arbor, MI
    Posts
    3

    Re: Texture maps in nested transforms

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

    - Jen

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Texture maps in nested transforms

    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

Similar Threads

  1. nested FBO render to texture? RT1(RT2(), RT2())?
    By Zarniwoop in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 07-04-2010, 02:08 PM
  2. texture maps
    By tpthyd in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-02-2009, 05:51 AM
  3. Non Power of 2 texture maps
    By dlshores in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 01-06-2006, 11:07 AM
  4. triangular texture maps
    By jono_123 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-17-2004, 12:45 PM
  5. video texture maps
    By imported_jahshaka in forum OpenGL: Linux
    Replies: 1
    Last Post: 05-25-2001, 12:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean