Tom Kelliher, CS 320
Feb. 4, 1998
Announcements:
From last time:
Outline:
Assignment: Handout.
Polygon types:
GL_POLYGON
GL_TRIANGLES
, GL_QUADS
.
GL_TRIANGLE_STRIP
, GL_TRIANGLE_FAN
,
GL_QUAD_STRIP
.
Here's the window creating and model viewing code from the Sierpinski gasket:
glutInit(&argc,argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(0,0); glutCreateWindow("Sierpinski Gasket"); glutIdleFunc (display); glutMouseFunc (mouse); glClearColor(1.0, 1.0, 1.0, 0.0); /* white background */ glColor3f(1.0, 0.0, 0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 500.0, 0.0, 500.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glutDisplayFunc(clear); glutMainLoop();
Description:
glutInit(int *argc,char **argv)
: Initializes GLUT library,
parses any GLUT command line arguments.
glutInitDisplayMode(unsigned int mode)
: Selects
single-buffered, RGB color. Some mode possibilities:
GLUT_SINGLE
.
GLUT_DOUBLE
.
GLUT_RGB
.
GLUT_INDEX
.
glutInitWindowSize(int width, int height)
: Requested width and
height, in pixels, of window.
glutInitWindowPosition(int x, int y)
: Requested initial
position of window.
int glutCreateWindow(char *name)
: Create the window using
the given name. Value returned is window ID.
glutIdleFunc(void (*func)(void))
: Function which will run when
window system events (redraw, input, etc.) aren't being handled.
glutMouseFunc(void (*func)(int button, int state, int x, int y)
:
Set the mouse callback function.
glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
:
Specify clear values for the color buffers.
glColor3f(GLfloat red, GLfloat green, GLfloat blue)
: Set the
current color.
glMatrixMode(GLenum mode)
: Specify which matrix is current.
Some possibilities:
GL_MODELVIEW
: this matrix is used to position the camera.
GL_PROJECTION
: this matrix is used to select the
projection volume: clipping and depth of field.
glLoadIdentity(void)
: Replace the current matrix with the identity matrix.
glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
GLdouble zNear, GLdouble zFar)
:
Multiply the current matrix with an orthographic matrix. This produces a
clipped, parallel projection.
glutDisplayFunc(void (*func)(void))
: Sets the re-display
callback.
glutMainLoop(void)
: Run the event processing loop, calling
registered callbacks as necessary.