Results 1 to 4 of 4

Thread: [solved]resetting position after glTranslatef

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011
    Posts
    16

    [solved]resetting position after glTranslatef

    Hi
    I am totally new to opengl.
    I am in a question of how to reset the position after applying it a time.
    ex - I am using following code to draw a cube.
    glTranslatef(0, 1, 0);
    glColor4f(0.3, 0.3, 0.3, 0.3 );
    glutSolidCube(2);
    After doing above how to rest the position to draw a new cube?
    Actually by calling
    glTranslatef(0, -1, 0);
    I could do that.
    Instead any inbuild method for resetting?
    I mean resetting colors, position ,etc...

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    458

    Re: resetting position after glTranslatef


    Code :
    glPushMatrix();
    // do transformations
    // draw
    glPopMatrix();
    // we're in state before all done transformations.

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: resetting position after glTranslatef

    Use glPushMatrix before the first translation, then glPopMatrix after drawing the first cube, to go back to the transformation saved by push matrix. This works for transformation matrices only (ie. rotation, translation, scaling, shear, etc).

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2011
    Posts
    16

    Re: resetting position after glTranslatef

    Thank you _arts_ and ZbuffeR.

    It worked for me.

Similar Threads

  1. FSAA Resetting...
    By DragonMesh in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-09-2013, 07:42 PM
  2. resetting openGL state
    By Ranjith in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-19-2009, 06:49 AM
  3. resetting the color
    By kodonnell in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-15-2001, 12:08 PM
  4. resetting the scene
    By fox in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 05-23-2001, 08:37 AM
  5. Resetting Vertex Array states
    By vibi in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-29-2000, 12:52 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