Introduction to OpenGL

Tom Kelliher, CS 320

Feb. 14, 2000

Administrivia

Announcements

Assignment

Read 3.1--3.4.

From Last Time

Primitive basics.

Outline

  1. Finish up primitive basics: polygons, text, general curved surfaces.

  2. Color and color models.

  3. 2-D viewing.

Coming Up

Control, interaction.

OpenGL API

Polygon Basics

  1. Convex and concave polygons.
    1. Definitions.

    2. Concave polygons can present problems.

    3. Often, hardware and software supports triangles.

    4. 2-D polygon convexity test: for all interior point, it is ``to the right'' when traversing the edges clockwise.

    5. Draw a polygon that won't pass Sze-Ling's ``turn right'' test.

  2. OpenGL polygon types: GL_POLYGON, GL_TRIANGLES, GL_QUADS, GL_TRIANGLE_STRIP, GL_QUAD_STRIP, GL_TRIANGLE_FAN.

    What are the strip and fan types?

Text

  1. Stroke text:
    1. Specified by vertices.

    2. Can send it through the graphics pipeline to manipulate it (point size, italics face).

    3. Computational-, storage-expensive

    4. Example: Postscript.

  2. Raster text:
    1. Specified by a bit-map.

    2. A font is often stored as a strip. Individual characters are copied to the frame buffer via bitblt operations.

    3. Can't process through the graphics pipeline. Changing the point size by changing the pixel size: blockiness. Or by using several ``strips.''

    4. Computational-, storage-inexpensive.

General Curved Surfaces

Tessellation: Mesh of convex polygons. 2-D, 3-D.

Example: circle formed by GL_TRIANGLE_FAN.

Color

Additive color model:

Tristimulus value.

Notes:

  1. Color is continuous.

  2. Our visual system perceives light as a three-color system.

  3. Basic tenet of three-color theory: If two colors produce the same tristimulus values, then they are visually indistinguishable.

  4. Additive: RGB. Subtractive: CMY.

  5. OpenGL has two color modes: RGB and indexed.

RGB Color Mode

  1. Depth of the frame buffer. True color: 24 bits. Number of colors?

  2. We specify a color as a point within the color cube:

    glColor3f(1.0, 0.0, 0.0);
    

  3. Alpha value provides opacity factor:
    glClearColor(1.0, 1.0, 1.0, 1.0);
    

Indexed Color Mode

  1. Many frame buffers have limited depth, say eight bits. However, the graphics controller may be able to display 16M colors.

  2. Suppose: frame buffer has depth k bits. Each color is specified using m bits.

    At any point in time, we should be able to specify any colors from the total collection of colors.

    Use of a color-lookup table:

  3. Shading, for 3-D graphics, requires a large # of colors. So, we'll stick with RGB mode.

Viewing

2-D viewing:

  1. Objects inside the viewing/clipping rectangle are visible:

    What is clipping?

  2. The default viewing volume is and centered at the origin.

The orthographic projection:

  1. Projects the point onto .

  2. In 2-D, we generally want to place objects at z=0.

  3. OpenGL specification:
    void glOrtho(GLdouble left, GLdouble right,
                 GLdouble bottom, GLdouble top,
                 GLdouble near, GLdouble far);
    
    void glOrtho2d(GLdouble left, GLdouble right,
                   GLdouble bottom, GLdouble top);
    
    ``Multiply the current matrix with an orthographic matrix'' --- make the projection matrix the current matrix.

  4. The OpenGL camera defaults to being positioned at the origin, pointed in the -z direction. The camera can ``see'' behind itself.

OpenGL matrices:

  1. Modelview matrix: positions objects in front of the camera.

    Translation, rotation, scaling.

  2. Projection matrix: determines shape of the viewing volume.

    Orthographic, perspective.



Thomas P. Kelliher
Sun Feb 13 17:27:54 EST 2000
Tom Kelliher