Polygon Details
  • Polygons may be drawn as solid, outlines, points, or stipped  patterns, similiar to lines

  •  
  •  void glPolygonMode(GLenum face, GLenum mode); Controls the drawing mode for a polygon's front and back faces. The parameter face can be GL_FRONT_AND_BACK, GL_FRONT, or GL_BACK; mode can be GL_POINT, GL_LINE, or GL_FILL to indicate whether the polygon should be drawn as points, outlined, or filled. 

  •  
  • By default, both the front and back faces are drawn filled. For example, you can have the front faces filled and the back faces outlined with two calls to this routine: 

  • glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_BACK, GL_LINE);
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Reversing and Culling Polygon Faces
  • Polygons are considered "front facing" if their verticies are oriented in counter-clockwise fashion
  •  Most objects can be constructed from objects that have a consistent facing attributes
  •  Culling of clockwise-orientated polygons will occur by default
  •  glFrontFace( GL_CW | GL_CCW ) defines how "front facing" is defined
  •  glCullFace(GLFRONT | GL_BACK | GL_FRONT_AND_BACK ) defines which face orientation is culled.

  •  

     
     
     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Polygon Stipling
  • Polygons can be colored by a screen-aligned  pattern similiar to line stippling
  •  glPolygonStipple() defines the pattern
  •  Stippling must be enabled with glEnable(GL_POLYGON_STIPPLE)
  •  Figure 2-11
  • This can be used as a "poor man's transparency"

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Edges can be turned on/off 
  • Figures 2-12 + 2-13

  •  

     
     
     
     
     
     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Normal Vectors
  • The normal vector specifies the direction of the polygonal surface 
  •  Normals are used to define the lighting of a surface
  •  glNormal() specifies the normal direction

  •  

     
     
     

    void glNormal3{bsidf}(TYPEnx, TYPEny, TYPEnz);
    void glNormal3{bsidf}v(const TYPE *v);

    Sets the current normal vector as specified by the arguments.
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Vertex arrays 
  • Vertex arrays are an OpenGL enhancement (v1.1)
  •  They can enhance performance if used correctly
  •  We will cover this topic in future sessions 

  •  

     
     
     
     
     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Homework
  • Compile "shapes.c" and execute.  Become familiar with the different techniques to draw lines and polygons

  •  
  •  Using "lines.c" as a framework plot the function y=sin(x)  and y=cos(x) using different line stipple patterns and different colors.  Here's a sample makefile

  •  
  •  Extra credit:  Use text annotation for the axes and coordinate intervals

  •  

     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

End of Presentation
  • Fin 8
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

End of Presentation
  • Fin 9
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

End of Presentation
  • Fin 10
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •