// Copyright (c) David Kabala // Fall 2009 #include #include #include #include class SceneManager { protected: enum DrawExample {SINGLE_POLYGON, MANY_POLYGONS, POLYGON_CIRCLE}; DrawExample _Example; public: SceneManager(void) : _Example(SINGLE_POLYGON) { } void init(void) { } void reshape(int w, int h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-w/2.0,w/2.0,-h/2.0,h/2.0,-1.0,1.0); glMatrixMode(GL_MODELVIEW); glutPostRedisplay(); } void drawSinglePolygon(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); //Draw a single polygon glBegin(GL_POLYGON); glColor3f(1.0, 1.0, 1.0); /* white */ glVertex2i(0, 0); glVertex2i(150, 0); glVertex2i(150, 150); glVertex2i(0, 150); glEnd(); glFlush(); /* Single buffered, so needs a flush. */ } void drawManyPolygons(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); //Draw many polygon glBegin(GL_POLYGON); glColor3f(1.0, 1.0, 1.0); /* white */ glVertex2i(0, 0); glVertex2i(150, 0); glVertex2i(150, 150); glVertex2i(0, 150); glEnd(); glBegin(GL_POLYGON); glColor3f(0.0, 1.0, 0.0); /* green */ glVertex2i(-100, 100); glVertex2i(0, 100); glVertex2i(-50, 50); glVertex2i(-150, 50); glEnd(); glBegin(GL_POLYGON); glColor3f(1.0, 0.0, 0.0); /* red */ glVertex2i(50, 75); glVertex2i(100, 100); glVertex2i(75, 20); glVertex2i(0, 0); glEnd(); glFlush(); /* Single buffered, so needs a flush. */ } void drawPolygonCircle(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); const GLfloat PI = 3.14159; unsigned int steps = 60; GLfloat scale1 = 150.0; glBegin(GL_POLYGON); glColor3f(1.0, 1.0, 1.0); /* white */ //Draw a circle GLfloat theta; for(unsigned int i(0) ; i