View Full Version : Updating Ortho vs Updating Vertices

06-25-2012, 01:25 PM
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.

06-25-2012, 02:24 PM
Why do you do that via the projection matrix? That's exactly what the model-view matrix is for.

Dark Photon
06-25-2012, 02:36 PM
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.

06-26-2012, 06:08 AM
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?

06-26-2012, 06:44 AM
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.