








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: McGraw; Class: Introduction:Computer Graphics; Subject: Computer Science; University: West Virginia University; Term: Fall 2008;
Typology: Study notes
1 / 14
This page cannot be seen from the preview
Don't miss anything!









Computer Science and Electrical Engineering Dept. West Virginia University
August 25, 2008
(^1) The GLUT API Initialization Window creation and management Callback function registration Font rendering Simple geometric objects
2 GLUT program structure
The GLUT API
GLUT is event-driven. We will register callback functions at startup and GLUT will call the functions as needed. GLUT functions: Initialization Window creation and management : OS independent Callback function registration : event driven Font rendering : using OpenGL Simple geometric objects : using OpenGL
All functions are named as glut*
The GLUT API Initialization
Must be called before the window is created. Command line options are system dependent.
Configures the frame buffer, as determined by mode. The flags specified by mode can include color, depth, stencil buffer, and single/double buffering modes.
Others: glutInitWindowPosition glutInitWindowSize
The GLUT API Window creation and management
The window name is displayed in the title bar.
Sets a flag indicating that the current window needs to be redrawn.
Swap front / back buffers when double buffering is enabled.(Usually implemented by just swapping pointers, not by copying buffer contents.)
Also, commands for setting / getting current window.
The GLUT API Callback function registration
These functions set the callback function for the current window.
The function pointed to by func will be called from within the event loop when the redisplay flag is set. The callback function typically contains the OpenGL drawing commands.
The function pointed to by func will be called from within the event loop while windowing system events are not being handled. The callback function typically contains code which performs some animation (but not rendering).
Call glutPostRedisplay at the end of the callback function so that the results of the animation will be displayed.
The GLUT API Callback function registration
This is event loop from which the registered callbacks are made. This function does not return.
The GLUT API Font rendering
Render the given character using the specified bitmapped font.
Render the given character using the specified stroke font.
Bitmap (Raster text): bitmapped font Stroke : Built from geometric primitives
GLUT program structure
Initialize GLUT : glutInit* functions Create window : glutCreateWindow Register callbacks : glut*Func functions Initialize OpenGL state : Color buffer clear color, camera parameters Enter event loop : glutMainLoop
Look at the example from HW 1.
GLUT program structure
Read chapter 2. Review the OpenGL and glut online resources from the course homepage, especially the online red book, and glut documentation.