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 2 of 2

Thread: Rotations and Transformations, Move the player or move the world?

  1. #1
    Newbie Newbie
    Join Date
    Jan 2014

    Rotations and Transformations, Move the player or move the world?

    Hi, I am working on a top-down 2D cargame with SDL & OpenGL on Linux. (( like death rally or the original GTA ))

    One of the ways I could rotate the player-car is with glRotatef and translate with glTranslatef, then refresh with glLoadIdentity, or I could use maths like

    newxvertlocation[i]= xvertlocation[i]*cos(rot)-yvertlocation[i]*sin(rot);
    newyvertlocation[i] = xvertlocation[i]*sin(rot)+yvertlocation[i]*cos(rot);

    and add to the x/y position of the player to move it and assign Translate to that position to move the 'camera'.

    I guess what I am saying is that i could use glRotatef and glTranslatef to move the world around the player or the maths to move the player around the world.

    What do you recommend? What is conventional?

  2. #2
    Intern Contributor
    Join Date
    Sep 2013
    In the end it will probably not make a difference, but when you do the math on CPU side instead of uploading matrices to the GPU your performance might very well improve. Especially if you use the deprecated OpenGL functions and the build in matrices.

Posting Permissions

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