// Copyright (c) David Kabala // Fall 2009 #include #include #include #include class SceneManager { protected: enum DrawExample {SINGLE_POINT, MANY_POINTS, COSINE_CURVE}; DrawExample _Example; public: SceneManager(void) : _Example(SINGLE_POINT) { } void init(void) { glPointSize(5.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 drawSinglePoint(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); //Draw a single point glBegin(GL_POINTS); glColor3f(1.0, 1.0, 1.0); /* white */ glVertex2i(0, 0); glEnd(); glFlush(); /* Single buffered, so needs a flush. */ } void drawManyPoints(void) const { //Clear the Draw Buffer glClear(GL_COLOR_BUFFER_BIT); //Draw many point glBegin(GL_POINTS); glColor3f(1.0, 1.0, 1.0); /* white */ glVertex2i(0, 0); glVertex2i(100, 0); glVertex2i(0, 100); glVertex2i(50, 50); glVertex2i(-150, 25); glEnd(); glFlush(); /* Single buffered, so needs a flush. */ } void drawCosineCurve(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_POINTS); glColor3f(1.0, 1.0, 1.0); /* white */ //Draw points allong the cosine curve GLfloat x; for(unsigned int i(0) ; i