// Some experiments in 2-D graphics. #include #include #define LLX 50.0 #define LLY 50.0 GLfloat height = 100.0; GLfloat width = 100.0; void redisplay(void); // Experiment 0: Implement the following functions. See stubs below. // You also need to add one line near the beginning of main()!!! void paint(void); void line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); void boxOutline(GLfloat llx, GLfloat lly, GLfloat width, GLfloat height); void boxFill(GLfloat llx, GLfloat lly, GLfloat width, GLfloat height); int main(int argc, char *argv[]) { int scale; glutInit(&argc, argv); if (argc != 2) { printf("Work with me --- I need a scale factor!!!\n"); return 1; } // Get scale from command line and use to adjust width and height. width *= (scale / 100.0); height *= (scale / 100.0); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(300, 300); glutInitWindowPosition(50, 50); glutCreateWindow("Two Dimensional Drawing"); glClearColor(1.0, 1.0, 1.0, 0.0); glutDisplayFunc(redisplay); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 300.0, 0.0, 300.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glutPostRedisplay(); //paint(); glutMainLoop(); return 0; } void redisplay(void) { // Experiment 1 after getting program to work: Comment-out following // paint() call, un-comment paint() call in main and determine what the // difference is. Restore original call sequence when finished. paint(); // Experiment 2 after getting program to work: Comment-out following // glFlush() call and determine the difference. glFlush(); } void paint(void) { // Clear window, draw red box outline at LLX, LLY, width of width, // height of height. Draw blue vertical and horizontal lines bisecting // box. Draw green box filled in upper right quadrant of red box. } void line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { } void boxOutline(GLfloat llx, GLfloat lly, GLfloat width, GLfloat height) { // Wind counter-clockwise (CCW). // llx = x coordinate of lower left vertex. // lly = y coordinate of lower left vertex. } void boxFill(GLfloat llx, GLfloat lly, GLfloat width, GLfloat height) { // Wind CCW. // llx = x coordinate of lower left vertex. // lly = y coordinate of lower left vertex. }