// Copyright (c) David Kabala // Fall 2009 #include #include #include #include class SceneManager { protected: enum DrawExample {SINGLE_LINE, MANY_LINES, COSINE_CURVE_LINES, COSINE_CURVE_LINE_STRIP, BOX_LINE_LOOP}; DrawExample _Example; public: SceneManager(void) : _Example(SINGLE_LINE) { } void init(void) { glLineWidth(3.0f); } 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 drawSingleLine(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); //Draw a single line glBegin(GL_LINES); glColor3f(1.0, 1.0, 1.0); /* white */ glVertex2i(0, 0); glVertex2i(150, 0); glEnd(); glFlush(); /* Single buffered, so needs a flush. */ } void drawManyLines(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); //Draw many line glBegin(GL_LINES); glColor3f(1.0, 1.0, 1.0); /* white */ glVertex2i(0, 0); glVertex2i(100, 0); glColor3f(0.0, 1.0, 0.0); /* green */ glVertex2i(0, 100); glVertex2i(50, 50); glColor3f(1.0, 0.0, 0.0); /* red */ glVertex2i(-150, 25); glVertex2i(150, 25); glEnd(); glFlush(); /* Single buffered, so needs a flush. */ } void drawCosineCurveLines(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); const GLfloat PI = 3.14159; unsigned int steps = 60; GLfloat scale = 50.0; glBegin(GL_LINES); glColor3f(1.0, 1.0, 1.0); /* white */ //Draw lines allong the cosine curve GLfloat x; for(unsigned int i(0) ; i