Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: glRotate problem

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    24

    glRotate problem

    Hi,

    Ive created 2 sphears and rendering them something like this:

    glPushMatrix();
    glTranslatef();
    glRotate(ang, 1, y, z);
    draw sphear
    glPopMatrix();

    glPushMatrix();
    glTranslatef();
    glRotate(ang, x, y, 1);
    draw sphear
    glPopMatrix();


    The first sphear rotates ok, (around x)
    but the second one rotates around both x and z

    Whats causing that?
    Doesnt glPushMatrix means to load a clean matrix without any transformation?

    (I dont want to use glLoadidentity()
    but maybe thats the only way?

    Hope not, then i need to relocate whole my world

    Thanks guys.

  2. #2
    Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    377

    Re: glRotate problem

    glpushmatrix pushes the current matrix to the matrix stack (clever name for such a function )
    glloadidentity sets the current matrix to identity and is perhaps what you mean by a 'clean matrix'


    [This message has been edited by satan (edited 02-14-2002).]

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    24

    Re: glRotate problem

    Ok,
    but how do i rotate the sphears without having the first affecting the other?

    Without using glLoadIdentity()

    tx

  4. #4
    Guest

    Re: glRotate problem

    Unless of course, you had left some value for x when you rotate the 2nd sphere

    Originally posted by Dies_Irae:
    Ok,
    but how do i rotate the sphears without having the first affecting the other?

    Without using glLoadIdentity()

    tx


  5. #5
    Junior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    Belmont, CA, USA
    Posts
    224

    Re: glRotate problem

    Everything appears ok to me except for the x, y, and z variables in the glRotate calls.

    If you want to rotate around the X axis, the call should be:

    glRotate(ang, 1, 0, 0);

    If you want to rotate around the Z axis, the call should be:

    glRotate(ang, 0, 0, 1);

    I bet you put the x, y, and z values in because of the translations. Don't do that.

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    24

    Re: glRotate problem

    Hey,

    Yea sorry its like that, dont know why i typed like that,


    glRotate(90, 1, 0, 0)

    glRotate(90, 0, 0, 1)


    If you Push and Pop matricies around them ,
    the 2nd one should not rotate

    (x 90 z 90) if thats true there must be something else with my code, time for some serious debuging

    Thanks guys. (Or ladies)

  7. #7
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    24

    Re: glRotate problem

    Ah crap, just a small mistake

    tx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •