OpenGL as a State Machine
  •  Code sets state variables of the state machine (current color for example)
  •  States stay in effect until they are changed
  •  Examples of State Variables
    • Viewing/Projection Matricies
    • Line/Polygon stipple patterns
    • Pixel packing conventions
    • Lighting specification
    • Material specification

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

OpenGL State Variables
  • Most state variables are set by glEnable() or glDisable()

  • Example:  glEnable(GL_BLEND);
  •  Each State variable has a default value
  •  Current values may be queried by the following methods:

  •  glGetBooleanv()
     glGetDoublev()
     glGetFloatv()
     glGetIntegerv()
     glGetPointerv()
     glIsEnabled()
  •  Choose the appropriate query depending on the desired return value
  • A collection of state variables can be saved on the attribute stack with glPushAttrib()
  • Attributes can be restored by glPopAttrib()

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

The Rendering Pipeline
  • Most OpenGL implementations have a series of processing stages known as the rendering pipeline
  •  This pipeline is not required, but serves as a way to characterize the functions of OGL.  (Most hardware implementations have this type of pipeline)

  •   Note that pixel and vertex data travel down separate paths until the rasterization phase

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Display Lists

     
  • Display listing is a way to cache data locally
  • Immediate mode rendering is the alternative to display list rendering
  • Display list mode can provide huge performance gains (but ...)

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Evaluators

     
  • All geometric primitives are expressed by vertices
  • Parametric curves and surfaces may be described by higher-level functions (such as control points)
  • The continuous function is then polygonalized here.
  • Examples:
    •  Sphere
    •  Bezier curve or surface

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Per-vertex operations
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Primitive Assembly
     
  • Figure 1-2 w/Primitive Assembly section highlighted
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Pixel Operations
     


     

  • Pixel data takes a different route through the pipeline 
  • Example OGL calls:
    • Scale and Bias: glPixelTransfer(GL_RED_BIAS)
      glPixelTransfer(GL_RED_SCALE)
    • Pixel Formatting: glPixelStore( GLenum pname,  TYPE param);

     
     
     
     
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Texture Assembly
     

     
  • Texture performance enhancements
  • Automatic texture generation

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Rasterization
     

     
  • Rasterization is the process of converting geometric primitives into fragments, or "potential" pixels
  • Color and depth information is generated for each fragment