summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2010-02-09 23:27:41 +0100
committerConstantin Riß <constantin.riss@dre.de>2010-02-09 23:27:41 +0100
commite1290a7a045457d514518cfc5f928f613c962765 (patch)
tree8700b4880c007e4b636aa204e540ef0f3a067004
parentd605b3f57bec467e6be82c23f4fbd9d48cd3e9e1 (diff)
downloadc3d-e1290a7a045457d514518cfc5f928f613c962765.tar
c3d-e1290a7a045457d514518cfc5f928f613c962765.zip
schrottes tastenhandling
-rw-r--r--DisplayClass.cpp53
-rw-r--r--DisplayClass.h3
-rw-r--r--main.cpp2
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_*/
diff --git a/main.cpp b/main.cpp
index f092e34..9e79b61 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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);
}