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
    Posts
    1

    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
    Senior Member Regular Contributor
    Join Date
    Sep 2013
    Posts
    186
    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.

Similar Threads

  1. Let player move with keyboard buttons
    By jasmine in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-21-2016, 05:34 AM
  2. storing transformations and rotations
    By Spaceaholic in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-18-2011, 12:08 PM
  3. background bmp image moves as both player move plz
    By asadkhanno1 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-08-2010, 04:19 PM
  4. Most common way to move around in a 3D world?
    By marce in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 08-05-2009, 10:37 AM
  5. Move the camera, or the world?
    By SuperFly in forum OpenGL: Advanced Coding
    Replies: 12
    Last Post: 11-02-2000, 04:47 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