/* October 2003 * Brian J.Ross * Brock University, Dept of Computer Science * COSC 3P98 Midterm solution B * * A simple gradient renderer. */ #if !defined(Linux) #include //Not Linux must be windows #endif #include #include #include #define MINDIM 0 #define MAXDIM 500 struct glob { float xmin; float xmax; }; struct glob global = {0.0, 500.0}; void drawGradient(bot_x, bot_y, top_x, top_y, r1, g1, b1, r2, g2, b2 ) float bot_x, bot_y, top_x, top_y; int r1, g1, b1, r2, g2, b2; { glBegin(GL_POLYGON); glColor3ub(r1, g1, b1); glVertex2f(bot_x, bot_y); glVertex2f(bot_x, top_y); glColor3ub(r2, g2, b2); glVertex2f(top_x, top_y); glVertex2f(top_x, bot_y); glEnd(); } void mydisplay(void) { glClear(GL_COLOR_BUFFER_BIT); drawGradient(30.0, 30.0, 250.0, 200.0, 50, 0, 20, 200, 200, 25); glFlush(); } int main(argc, argv) int argc; char **argv; { glutInit(&argc, argv); glutInitWindowSize(MAXDIM, MAXDIM); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutCreateWindow("Midterm solution B"); glutDisplayFunc(mydisplay); glMatrixMode(GL_PROJECTION); gluOrtho2D(global.xmin, global.xmax, global.xmin, global.xmax); glClearColor (1.0, 1.0, 1.0, 1.0); glutMainLoop(); return 0; }