diff options
author | Constantin Riß <constantin.riss@dre.de> | 2010-02-09 21:33:57 +0100 |
---|---|---|
committer | Constantin Riß <constantin.riss@dre.de> | 2010-02-09 21:33:57 +0100 |
commit | e2ba8593b4911e546072be899c7246d68d92c10a (patch) | |
tree | 5cc7cd344f50a7f8f2603e85582230f92e4aab63 | |
parent | 57935140306a95ba35f713d399f2d917a121d9c3 (diff) | |
download | c3d-e2ba8593b4911e546072be899c7246d68d92c10a.tar c3d-e2ba8593b4911e546072be899c7246d68d92c10a.zip |
.....................^^
-rw-r--r-- | DisplayClass.cpp | 50 | ||||
-rw-r--r-- | DisplayClass.h | 3 | ||||
-rw-r--r-- | main.cpp | 25 |
3 files changed, 29 insertions, 49 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp index 3294fac..86c167c 100644 --- a/DisplayClass.cpp +++ b/DisplayClass.cpp @@ -3,49 +3,7 @@ DisplayClass::Renderer DisplayClass::render; DisplayClass::DisplayClass(int x, int y, int z) : angle(0) { - /*cubehole0 = Cubehole(3.0, 6.0, 3.0, 0.0, 0.0, 0.0, 2.5, 2.5, - vmml::vec4f(1.0, 0.85, 0.06, 0.5), - vmml::vec4f(1.0, 0.85, 0.06, 0.5), - vmml::vec4f(1.0, 0.85, 0.06, 0.5), - vmml::vec4f(1.0, 0.85, 0.06, 0.5)); - cubehole1 = Cubehole(2.5, 6.0, 2.5, 0.0, 0.0, 0.0, 2.0, 2.0, - vmml::vec4f(0.0, 0.85, 0.06, 0.5), - vmml::vec4f(0.0, 0.85, 0.06, 0.5), - vmml::vec4f(0.0, 0.85, 0.06, 0.5), - vmml::vec4f(0.0, 0.85, 0.06, 0.5)); - cubehole2 = Cubehole(2.0, 6.0, 2.0, 0.0, 0.0, 0.0, 1.5, 1.5, - vmml::vec4f(1.0, 0.0, 0.06, 0.5), - vmml::vec4f(1.0, 0.0, 0.06, 0.5), - vmml::vec4f(1.0, 0.0, 0.06, 0.5), - vmml::vec4f(1.0, 0.0, 0.06, 0.5)); - cubehole3 = Cubehole(1.5, 6.0, 1.5, 0.0, 0.0, 0.0, 1.0, 1.0, - vmml::vec4f(1.0, 0.85, 0.06, 0.5), - vmml::vec4f(1.0, 0.85, 0.06, 0.5), - vmml::vec4f(1.0, 0.85, 0.06, 0.5), - vmml::vec4f(1.0, 0.85, 0.06, 0.5)); - cubehole4 = Cubehole(1.0, 6.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, - vmml::vec4f(0.0, 0.85, 0.06, 0.5), - vmml::vec4f(0.0, 0.85, 0.06, 0.5), - vmml::vec4f(0.0, 0.85, 0.06, 0.5), - vmml::vec4f(0.0, 0.85, 0.06, 0.5)); - cubehole5 = Cubehole(0.5, 6.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, - vmml::vec4f(1.0, 0.0, 0.06, 0.5), - vmml::vec4f(1.0, 0.0, 0.06, 0.5), - vmml::vec4f(1.0, 0.0, 0.06, 0.5), - vmml::vec4f(1.0, 0.0, 0.06, 0.5)); - - std::list<Triangle> triangles = cubehole0.getTriangles(); - std::list<Triangle> t1 = cubehole1.getTriangles(); - triangles.splice(triangles.end(), t1); - std::list<Triangle> t2 = cubehole2.getTriangles(); - triangles.splice(triangles.end(), t2); - std::list<Triangle> t3 = cubehole3.getTriangles(); - triangles.splice(triangles.end(), t3); - std::list<Triangle> t4 = cubehole4.getTriangles(); - triangles.splice(triangles.end(), t4); - std::list<Triangle> t5 = cubehole5.getTriangles(); - triangles.splice(triangles.end(), t5);*/ - + // Temparray temp(20, x, y, z); // triangles=temp.getTriangles(); this->x=x; @@ -58,7 +16,7 @@ DisplayClass::~DisplayClass() { //delete tree; } -void DisplayClass::renderScene(unsigned long delta) { +void DisplayClass::renderScene(unsigned long delta, std::bitset<256> keys) { angle += delta*0.025; if(angle >= 360) angle -= 360; @@ -67,8 +25,8 @@ void DisplayClass::renderScene(unsigned long delta) { glLoadIdentity(); // Clean up matrix glTranslatef(0.0, -2.0, -20.0); // Then set up transformation - glRotatef(-10, 1.0, 0.0, 0.0); - glRotatef(angle, 0.0, 1.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); // glRotatef(-angle*5, 1.0, 1.0, 1.0); diff --git a/DisplayClass.h b/DisplayClass.h index 3ec767b..c792179 100644 --- a/DisplayClass.h +++ b/DisplayClass.h @@ -6,6 +6,7 @@ #include "BSPTree.h" #include "gl.h" #include "House.h" +#include <bitset> class DisplayClass { @@ -13,7 +14,7 @@ class DisplayClass DisplayClass(int x, int y, int z); virtual ~DisplayClass(); - void renderScene(unsigned long delta); + void renderScene(unsigned long delta, std::bitset<256> keys); private: struct Renderer { @@ -1,6 +1,7 @@ #include "DisplayClass.h" #include "gl.h" #include <cstdlib> +#include <bitset> #ifdef _WIN32 #else @@ -19,6 +20,8 @@ //#define DEFAULT_HEIGHT 200 //#define DEFAULT_WIDTH 200 +std::bitset<256> keys; + void initGL(bool multisample); void resize(int width, int height); @@ -237,8 +240,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine ticks += delta; - static DisplayClass render(3, 3, 3); - render.renderScene(delta); + static DisplayClass render(5, 5, 15); + render.renderScene(delta, keys); SwapBuffers(hDC); } @@ -255,6 +258,14 @@ LRESULT CALLBACK wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { case WM_SIZE: resize(LOWORD(lParam), HIWORD(lParam)); return 0; + + case WM_KEYDOWN: + keys.set(wParam, true); + return 0; + + case WM_KEYUP: + keys.set(wParam, false); + return 0; default: return DefWindowProc(hWnd, uMsg, wParam, lParam); @@ -383,6 +394,16 @@ int main(int argc, char *argv[]) { case ClientMessage: if(static_cast<Atom>(event.xclient.data.l[0]) == windele) running = false; + break; + + case KeyPress: + keys.set(event.xkey.keycode, true); + if(XKeycodeToKeysym(disp, event.xkey.keycode, 0) == XK_Escape) running = false; + + break; + + case KeyRelease: + keys.set(event.xkey.keycode, false); } } |