Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: OpenGL Rotation/Translation Problem

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012

    OpenGL Rotation/Translation Problem


    I use glRotatef & glTranslatef to "rotate my camera".

    glRotatef(-zanglecamera, 0, 0, 1);
    glRotatef(-yanglecamera[1], 0, 1, 0);
    glRotatef(-xanglecamera[0], 1, 0, 0);
    glTranslatef(-xposcamera, -yposcamera, -zposcamera);

    The problem is that my input is translation and rotation in a global-coordinate-system. That means that the x-axis stays the same after rotation around the z axis.
    The same is true for the translation after the rotation. This does not work with the code shown above as opengl rotates the coordinate system.

    I think the translation problem is solved by doing the translation before the rotation. If that is true then i still have the problem with the rotations.

    I hope someone can help me with this problem.

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2013
    Why don't you make the use of homogeneous matrices?
    You can calculate the translation and rotation matrices and then apply a uniform matrix for all of them (rotation+translation) by loading the matrix before your drawing.

  3. #3
    Member Regular Contributor
    Join Date
    Jan 2011
    Paris, France
    Have you test with only two rotations axis at the same time ?

    With three rotations axis, the result is sometime very surprising because the last rotation "modify/destroy" the two firsts rotations that are make before ...

    If you want to rotate around an arbitrary axis, take a look at or for example

Tags for this Thread

Posting Permissions

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