/* simple.c * * Some real simple examples using GLUT. * Draws a triangle/square defined in display(). * * Bruce M. Bolden * October 9, 2001 * */ #include // prototypes void DrawColoredTriangle(); void DrawColoredSquare(); void display(); void DrawColoredTriangle() { glBegin( GL_POLYGON ); glColor3f(1.0, 0.0, 0.0); // Red glVertex2f( 0.0, 0.0 ); glColor3f(0.0, 1.0, 0.0); // Green glVertex2f( 0.5, 1.0 ); glColor3f(0.0, 0.0, 1.0); // Blue glVertex2f( 1.0, 0.0 ); glEnd(); } void DrawColoredSquare() { glBegin( GL_POLYGON ); glColor3f(1.0, 0.0, 0.0); // Red glVertex2f( -0.5, -0.5 ); glColor3f(0.0, 1.0, 0.0); // Green glVertex2f( -0.5, 0.5 ); glColor3f(0.0, 0.0, 1.0); // Blue glVertex2f( 0.5, 0.5 ); glColor3f(1.0, 1.0, 0.0); // Yellow glVertex2f( 0.5, -0.5 ); glEnd(); } void display() { glClear( GL_COLOR_BUFFER_BIT ); DrawColoredTriangle(); //DrawColoredSquare(); glBegin( GL_POLYGON ); glVertex2f( -0.5, -0.5 ); glVertex2f( -0.5, 0.5 ); glVertex2f( 0.5, 0.5 ); glVertex2f( 0.5, -0.5 ); glEnd(); glFlush(); } int main( int argc, char** argv ) { glutInit( &argc, argv ); glutCreateWindow( "Simple" ); glutDisplayFunc( display ); glutMainLoop(); }