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

Thread: Updating Ortho vs Updating Vertices

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    16

    Updating Ortho vs Updating Vertices

    Im writing a program that displays a stream of coordinates. The program is designed to center on the newest point. This means that the points are constantly moving (relative to the screens coordinate system, the points themselves never change their geographical coordinates).

    My question is is it more efficient set update glOrtho it everytime a new point comes in (in an attempt to keep the projection centered on the newest point) or map glOrtho once and convert each point to a new relative position everytime a new point comes in.

    To clarify... My viewport represent a 50mx50m plot of land, I am recieving a stream from a GPS. My viewport centers on the newest point. Should I:
    1. Set GlOrtho(-25,25,-25,25,0,1) and draw vertex's by their geographical location. Everytime a new point comes in I would restate GlOrtho to center on the next point. Or
    2. Set GlOrtho(0,50,0,50,0,1) and draw vertex's relative to the newest point (the newest point is (2 m, 2 m) would draw at (25,25) and another point at (3 m, 3 m) would draw at (26, 26). Everytime a new point comes in I would have to reconvert each point to their new relative coordinates.


    The number of coordinates increase the longer the program is running I expect to reach millions of coordinates.
    Last edited by Beiufin; 06-25-2012 at 02:08 PM.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    Why do you do that via the projection matrix? That's exactly what the model-view matrix is for.

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,213
    And to answer your question, it's cheap to change the MODELVIEW matrix once. Versus sift through a large number of points and "adjust" them. Not to mention the floating-point round-off errors that accumulate unless you keep two copies: one the master verts, and one the modified verts.

    So yeah, use the MODELVIEW.

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    16
    Alright so Ill use modelview matrix transformations (glTranslate) for point movement but I still have to initially set glOrtho right?
    and If I wanted to zoom in and out I would have to change glOrtho correct?

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    Yes, you need a projection.

    and If I wanted to zoom in and out I would have to change glOrtho correct?
    Yes, since translating would not change the size on screen with an orthographic projection. You need some scaling factor by which you multiply the values of left, right, top and bottom.

Posting Permissions

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