diff options
-rw-r--r-- | DisplayClass.cpp | 53 | ||||
-rw-r--r-- | DisplayClass.h | 3 | ||||
-rw-r--r-- | main.cpp | 2 |
3 files changed, 52 insertions, 6 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp index 86c167c..70c59cb 100644 --- a/DisplayClass.cpp +++ b/DisplayClass.cpp @@ -16,16 +16,16 @@ DisplayClass::~DisplayClass() { //delete tree; } -void DisplayClass::renderScene(unsigned long delta, std::bitset<256> keys) { - angle += delta*0.025; +void DisplayClass::renderScene(unsigned long delta, std::bitset<256>& keys) { + /*angle += delta*0.025; if(angle >= 360) - angle -= 360; + angle -= 360;*/ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Clean up matrix glTranslatef(0.0, -2.0, -20.0); // Then set up transformation - glRotatef(10, 1.0, 0.0, 0.0); +// glRotatef(10, 1.0, 0.0, 0.0); // glRotatef(angle, 0.0, 1.0, 0.0); // glRotatef(angle*2, 1.0, 0.0, 0.0); // glRotatef(angle*3, 0.0, 0.0, 1.0); @@ -55,3 +55,48 @@ void DisplayClass::renderScene(unsigned long delta, std::bitset<256> keys) { glFlush(); } + +void DisplayClass::keyhandler(std::bitset<256>& keys){ + static float abstand = 0; + if(keys.any()) { + glLoadIdentity(); + + static float rotm[16] = { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1}; + char h = '2'; + if(keys.test(h)) + glRotatef(3, 1, 0, 0); + + h = '4'; + if(keys.test(h)) + glRotatef(-3, 0, 1, 0); + + h = '6'; + if(keys.test(h)) + glRotatef(3, 0, 1, 0); + + h = '8'; + if(keys.test(h)) + glRotatef(-3, 1, 0, 0); + + h = '+'; + if(keys.test(h)) + abstand -= 0.2; + + h = '-'; + if(keys.test(h)) + abstand += 0.2; + + glMultMatrixf(rotm); + glGetFloatv(GL_MODELVIEW_MATRIX, rotm); + + glLoadIdentity(); + glTranslatef(0, 0, abstand); + glMultMatrixf(rotm); + +// glutPostRedisplay(); + } +} diff --git a/DisplayClass.h b/DisplayClass.h index c792179..5b646ed 100644 --- a/DisplayClass.h +++ b/DisplayClass.h @@ -14,7 +14,7 @@ class DisplayClass DisplayClass(int x, int y, int z); virtual ~DisplayClass(); - void renderScene(unsigned long delta, std::bitset<256> keys); + void renderScene(unsigned long delta, std::bitset<256>& keys); private: struct Renderer { @@ -29,6 +29,7 @@ class DisplayClass int x, y, z; //Cubehole cubehole0, cubehole1, cubehole2, cubehole3, cubehole4, cubehole5; std::list<Triangle> triangles; + void keyhandler(std::bitset<256>& keys); //BSPTree *tree; }; #endif /*_DISPLAYCLASS_H_*/ @@ -240,7 +240,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine ticks += delta; - static DisplayClass render(5, 5, 15); + static DisplayClass render(5, 5, 5); render.renderScene(delta, keys); SwapBuffers(hDC); } |