Advertisement
aditya369

MyFramework.h

Nov 28th, 2011
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. #include "OpenGLFramework.h"
  2. #include "LorenzAttractor.h"
  3.  
  4. #ifndef __MY_FRAMEWORK__
  5. #define __MY_FRAMEWORK__
  6.  
  7. using namespace openGLFramework;
  8.  
  9. class MyFramework : public virtual OpenGLFramework {
  10.     private:
  11.         LorenzAttractor *lorenzAttractor;
  12.         unsigned int numLorenzAttractors;
  13.  
  14.     public:
  15.         MyFramework() {
  16.             lorenzAttractor = NULL;
  17.         }
  18.  
  19.         ~MyFramework() {
  20.             delete lorenzAttractor;
  21.         }
  22.  
  23.         void setNumberOfLorenzAttractors(unsigned int number) {
  24.             numLorenzAttractors = number;
  25.         }
  26.  
  27.         void initLorenzAttractor(unsigned int i, float sx, float sy, float sz, float r, float g, float b) {
  28.  
  29.             if(lorenzAttractor == NULL) {
  30.                 lorenzAttractor = new LorenzAttractor[numLorenzAttractors];
  31.             }
  32.  
  33.             if(lorenzAttractor == NULL) {
  34.                 cout << "Lorenz Attractor construction failed" << endl;
  35.             }
  36.  
  37.             if(i >= numLorenzAttractors || i < 0) {
  38.                 cout << "Array Out of bounds. Check value of 'i'." << endl;
  39.             }
  40.  
  41.             lorenzAttractor[i].setAttributes(sx, sy, sz, r, g, b);
  42.         }
  43.  
  44.         void draw() {
  45.             if( 1 == getNumberOfSubWindows() ) {
  46.                     setWindowContext(0);
  47.  
  48.                     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  49.                     glLoadIdentity();
  50.                     glMatrixMode(GL_MODELVIEW);
  51.            
  52.                     invokeGlutLookAt();
  53.  
  54.                     draw3DCoordinateAxis();
  55.  
  56.                     for(unsigned int i = 0; i < numLorenzAttractors; i++) {
  57.                         lorenzAttractor[i].simulate();
  58.                     }
  59.  
  60.                     glutSwapBuffers();
  61.             } else if( getNumberOfSubWindows() == numLorenzAttractors ) {
  62.                 for(unsigned int i = 0; i < numLorenzAttractors; i++) {
  63.                     setWindowContext(i);
  64.  
  65.                     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  66.                     glLoadIdentity();
  67.                     glMatrixMode(GL_MODELVIEW);
  68.            
  69.                     invokeGlutLookAt();
  70.  
  71.                     draw3DCoordinateAxis();
  72.                     lorenzAttractor[i].simulate();
  73.  
  74.                     glutSwapBuffers();
  75.                 }
  76.             }
  77.         }
  78. };
  79.  
  80. #endif //__MY_FRAMEWORK__
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement