Next: GLUT Utilities for Complex
Up: OpenGL Quick Reference Guide
Previous: Miscellaneous Display Control Functions:
OpenGL Basic Drawing
With the exception of glRect(), most drawing is done by creating
geometric objects using glBegin()...glEnd() combination, where
between each such pair you specify a collection of vertices that
define the object. Along with specifying vertices, you can
specify a number of attributes that affect how the vertices will
appear. These include things such as color, surface normals (for
shading), and texture coordinates (for texture mapping).
Draw a rectangle on the z=0 plane. The arguments give the
(x,y) coordinates of any two opposite corners of the
rectangle. Some forms include glRectd(), which takes
four double's, glRectf(), which takes four
float's, glRectfv() takes two vectors, each consisting
of two float's.
- glBegin(GLenum mode)...glEnd(void):
Define an object, where mode may be any of:
There is a limited set of commands that can be placed within
glBegin()..glEnd() pairs. These include glVertex*(),
glColor*(), glNormal*(), glTexCoord*(),
glMaterial*(), and glCallList().
See the reference manual for the exact specification
of vertex order and orientation.
- GL_POINTS: set of points
- GL_LINES: set of line segments (not connected)
- GL_LINE_STRIP: chain of connected line segments
- GL_LINE_LOOP: closed polygon (may self intersect)
- GL_TRIANGLES: set of triangles (not connected)
- GL_TRIANGLE_STRIP: linear chain of triangles
- GL_TRIANGLE_FAN: fan of triangles (joined to one point)
- GL_QUADS: set of quadrangles (not connected)
- GL_QUAD_STRIP: linear chain of quadrangles
- GL_POLYGON: a convex polygon
Specify the coordinates of a vertex.
Specify the surface normal for subsequent vertices. The normal
should be of unit length after the modelview transformation
is applied. Call glEnable(GL_NORMALIZE) to have OpenGL
do normalization automatically.
Specify the color of subsequent vertices. This is normally
used if lighting is not enabled. Otherwise, colors are
defined by glMaterial*(), defined below under lighting.
- glLineWidth(GLfloat width):
Sets the line width for subsequent line drawing. The argument
is the width of the line (in pixels). (Note that not all widths
are necessarily supported.)
Please report any errors or send comments to
Last updated: Sat, Feb 8, 2003.