Demonstration Program: Used to illustrate OpenGL primatives
This is perhaps the simplest
OpenGL program using the glut toolkit.
Adapted from http://www.cs.uml.edu/~hmasterm/graphics.html
by Jorge Lobo, May 2000.
\*********************************************************************/
#include <GL\glut.h>
#include <math.h>
void display( void );
void reshape( GLsizei w, GLsizei h );
//global
GLsizei wh = 500, ww = 500; //initial window size
//rehaping routine called whenever window is resized or moved
void reshape( GLsizei w, GLsizei h
)
{
glViewport( 0,
0, w, h );
}
// Display Function: what is actually drawn to the screen
void display(void)
{
//clear the screen
and z buffer
glClearColor( 0.0, 0.0, 0.0,
0.0 );
glClear(GL_COLOR_BUFFER_BIT);
//set the color
glColor3f(1.0, 1.0, 1.0); //initially white
//set up other line parameters - INITIALLY COMMENTED OUT
//glLineWidth(3.0);
//glLineStipple(1,0x1c47);
//glEnable(GL_LINE_STIPPLE);
//draw the primitive
glBegin (GL_POINTS);
glVertex2f(-0.5, -0.5);
glVertex2f(0.5, -0.5);
glVertex2f(0.5, 0.5);
glVertex2f(-0.5,0.5);
glEnd();
//flush the buffer
glFlush();
}
int main( int argc, char** argv )
{
//Initialize the glut system
glutInit( &argc,argv );
//set up double buffered window with depth
glutInitDisplayMode(
GLUT_SINGLE | GLUT_RGB );
glutInitWindowSize(
ww, wh );
glutCreateWindow(
"Illustrations of OpenGL Primitives" );
// set up the viewing
projection; this code sets up an orthographic projection with a
// view volume
extending from -1.0 to 1.0 in x,y,z directions
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0,
-1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
// register callbacks
glutDisplayFunc( display );
glutReshapeFunc(
reshape );
// start the event loop
glutMainLoop();
return(0);
}