View Full Version : Rotations and Transformations, Move the player or move the world?

01-13-2014, 10:19 PM
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?

01-13-2014, 11:41 PM
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.