/* Module : DrawPolylineFile.cpp * Author : Robert W. Lindeman * Email : gogo@wpi.edu * Course : CS-543 * * Description : Most of this code is from Emmanuel Agu, adapted from * Sandy Hill, UMass-Amherst. * * Read in a GRS (short for 'gross' : a homegrown primitive * file format for polyline drawings ), and draw the polylines in a window * * Date : 2005/10/20 * * History: * Revision Date Changed By * -------- ---------- ---------- * 01.00 2005/10/20 gogo * First release. * * (c) Copyright 2005, Worcester Polytechnic Institute. */ /* -- INCLUDE FILES ------------------------------------------------------ */ #include #include #include #include #include #include /* -- DATA STRUCTURES ---------------------------------------------------- */ /* -- GLOBAL VARIABLES --------------------------------------------------- */ /* -- LOCAL VARIABLES ---------------------------------------------------- */ /* ----------------------------------------------------------------------- */ /* Function : void myInit( void ) * * Description : Initialize OpenGL and the window where things will be * drawn. * * Parameters : void * * Returns : void */ void myInit( void ) { glClearColor( 1.0,1.0,1.0,0.0 ); glColor3f( 0.0f, 0.0f, 0.0f ); glPointSize( 1.0 ); glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); gluOrtho2D( 0.0, 640.0, 0.0, 480.0 ); } /* ----------------------------------------------------------------------- */ /* Function : void drawPolyLineFile( char *fileName ) * * Description : Read in and draw the polylines contained in the file * 'fileName'. * * Parameters : char *fileName : Name of the file to read data from. * * Returns : void */ void drawPolyLineFile( char *fileName ) { } /* ----------------------------------------------------------------------- */ /* Function : void myDisplay( void ) * * Description : This function gets called everytime the window needs to * be redrawn. * * Parameters : void * * Returns : void */ void myDisplay( void ) { drawPolyLineFile( "dino.dat" ); } /* ----------------------------------------------------------------------- */ /* Function : int main( int argc, char** argv ) * * Description : This is the main function. It sets up the rendering * context, and then reacts to user events. * * Parameters : int argc : Number of command-line arguments. * char *argv[] : Array of command-line arguments. * * Returns : int : Return code to pass to the shell. */ int main( int argc, char *argv[] ) { // Initialize GLUT. glutInit( &argc, argv ); // Set the mode to draw in. glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB ); // Set the window size in screen pixels. glutInitWindowSize( 640, 480 ); // Set the window position in screen pixels. glutInitWindowPosition( 100, 150 ); // Create the window. glutCreateWindow( "Program to draw Polylines in GRS format" ); // Set the callback funcion to call when we need to draw something. glutDisplayFunc( myDisplay ); // Initialize some things. myInit( ); // Now that we have set everything up, loop responding to events. glutMainLoop( ); } /* ----------------------------------------------------------------------- */