13.003 Computational Geometry and Visualization
OpenGL GLUT Library
#include <GL/gl.h> /* OpenGL library */
#include <GL/glu.h> /* OpenGL utility library */
#include "/mit/13.003/include/glut.h" /* GLUT library */
/**************************************************************
* Main program - Open window with initial window size, title
* bar, RGBA display mode, and handle input events.
*************************************************************/
void main(int argc, char **argv)
{
glutInit(&argc, argv); /* Initialize GLUT */
glutInitDisplayMode(GLUT_RGB); /* Set RGB (not indexed) color mode */
glutCreateWindow("OpenGL Example 1 - Square"); /* Create window */
glutReshapeFunc(reshapeCB); /* Register reshape callback */
glutDisplayFunc(displayCB); /* Register display callback */
glutMainLoop(); /* Enter the event loop */
}
/***************************************************************
* This callback function is automatically called whenever
* the window changes shape.
**************************************************************/
void reshapeCB(int width, int height)
{
glViewport(0, 0, width, height); /* set viewport to fill window */
}
/***************************************************************
* This callback function is automatically called whenever
* the window needs to be redrawn.
**************************************************************/
void displayCB(void)
{
...
}