Robotics C++ Physics II AP Physics B Electronics Java Astronomy Other Courses Summer Session  

Primitives

 

 

Syntax

 

glBegin (parameter)

 

    appropriate functions...

 

glEnd();

 

Parameter

Definition

GL_POINTS

Single points

GL_LINES

Non-connected lines

GL_LINE_STRIP

Series of connected lines

GL_LINE_LOOP

Closed loop of connected lines

GL_TRIANGLES

Single triangles

GL_TRIANGLE_STRIP

Series of connected triangles

GL_TRIANGLE_FAN

Set of triangles containing a common central vertex

GL_QUADS

Quadralaterals

GL_QUAD_STRIP

Series of connected quadralaterals

GL_POLYGON

Polygon with an arbitrary number of vertices

 

 

Appropriate Functions Within GlBegin() - glEnd()

 

glVertex ()

glColor()

glIndex()

glNormal()

glTextCoord()

glEvalCoord()

glEvalPoint()

glMaterial()

glEdgeFlag()

glCallList()

glCallLists()

glVertex()

 

Modifying Point Size

 

  void glPointSize (GLFloat size);

  The default is 1.0.

 

Drawing Lines in 3D

 

  glVertex3f (-2.0, -1.0, 0.0);                //placed between glBegin() and glEnd() as described above

  glVertex3f(3.0, 1.0, 0.0);                   //placed between glBegin() and glEnd() as described above

  Start and end points are specified.

  f specifies that the values are floats

 

Modifying Line Width

 

  void glLineWidth(GLFloat width);

  Default is 1.0

  Use glGet() with GL_LINE_WIDTH described earlier to find the current width

 

Antialiasing

 

  Pass GL_POINT_SMOOTH to glEnable()

  Smoothes and compensates for finite number of pixels

 

Stipple Patterns for Lines

 

  void glLineStipple(GLint factor, GLushort pattern;

  Specifies a mask that determines which portions of a line are drawn

  factor defaults to 1 with a range up to 256 and specifies how many times each bit in pattern is repeated

     before moving on

  pattern specifies a 16 bit pattern. Any bits will result in the corresponding bits being drawn, otherwise

     they are not drawn. Note that they are applied in reverse order.

 

Drawing Polygons in 3D

 

  void glPolygonMode(GLenum face, GLenum mode);

  Points provides specify a region that is then filled with color

  face parameter set to GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK 

  mode parameter can assume any of the following values

 

Value

Definition

GL_POINT

Each vertex specified is rendered as a single point, which can be controlled by points states discussed earlier. This produces the same effect as calling glBegin() with GL_POINTS

GL_LINE

This will draw the edges of the polygon as a set of lines. Any of the lines states discussed previously will affect how the lines are drawn. This is similar to calling glBegin() with GL_LINE_LOOP

GL_FILL

The default state, which renders the polygon with the interior field. This is the only state in which polygon stipple and polygon smoothing will take effect

 

Polygon Face Culling

 

  Using culling, you tell OpenGL not to render one side of the polygon

  Pass GL_CULL_FACE to glEnable()        //tells not to render one side

  void glCullFace(GLenum mode);                //tells which face to not render

  mode can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK 

 

Hiding Polygon Edges

 

  Allows you to not have all of the edges appear. Use one of the following

  void GLEdgeFlag(GLboolean isEdge);

  void glEdgeFlag(const GLboolean *isEdge);

 

Triangles

 

glVertex3f(-2.0, -1.0, 0.0);

glVertex3f(3.0, 1.0, 0.0);

glVertex3f(0.0, 3.0, 0.0);