The Coordinate System
- Everything we have done so far has been 2D, but OpenGL is a 3D system.
- In the last program, we messed with the way world is set up with the glOrtho command
- This command sets up a "viewing box", or view volume
- Items inside of the view box are displayed
- Items outside of the view box are clipped.
- This command takes the left, right, bottom, top , near and far coordinates of a view box.
- Coordinate System
- The X axis is as expected,
- The Y axis is up and down
- The Z axis is into the screen, but we may change this.
-
- Figures are rendered by projecting the images onto the near screen.
- This is the view frame.
- Much more on this later.
- The view frame is then scaled to fit into the provided window.
- This may involve skewing the final image.
- Again, more on this later.
- Sometimes we wish to keep the system square
- In the Glut reshape routine, find the min of the width and height of the window
- And set the viewport to this.
- There is MUCH more on this to come in chapter 4.
- It is worth playing with the examples pages 28-32
- For now, keep your drawings in the view box.
- He discusses clipping
- This is the process removing points outside of the view volume.
- Or perhaps better, only drawing thins that are within the view volume
- This is a complex process, again, more on this later.
- The OpenGL State Machine
- OpenGL maintains a set of state variables
- These variables control many portions of the drawing pipeline
- The color things are drawn with.
- The view volume
- The width of lines and size of points
- glPointSize(2);
- glLineWidth()
- Fill mode for polygons
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE );
- GL_FRONT, GL_BACK
- GL_LINE, GL_FILL, GL_POINT
- Fill works best with simple polygons.
- Complex polygons confuse fill routines, but we will see that later too.