// Copyright (c) David Kabala // Fall 2009 #include #include #include #include class SceneManager { protected: enum DrawExample {SINGLE_QUAD, MANY_QUADS, QUAD_STRIP}; DrawExample _Example; public: SceneManager(void) : _Example(SINGLE_QUAD) { } 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 drawSingleQuad(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); //Draw a single quad glBegin(GL_QUADS); 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 drawManyQuads(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); //Draw many quad glBegin(GL_QUADS); glColor3f(1.0, 1.0, 1.0); /* white */ glVertex2i(0, 0); glVertex2i(150, 0); glVertex2i(150, 150); glVertex2i(0, 150); glColor3f(0.0, 1.0, 0.0); /* green */ glVertex2i(-100, 100); glVertex2i(0, 100); glVertex2i(-50, 50); glVertex2i(-150, 50); 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 drawQuadStrip(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); const GLfloat PI = 3.14159; unsigned int steps = 60; GLfloat scale1 = 150.0; GLfloat scale2 = 175.0; glBegin(GL_QUAD_STRIP); glColor3f(1.0, 1.0, 1.0); /* white */ //Draw quads allong a disk GLfloat theta; for(unsigned int i(0) ; i