summaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2010-02-09 21:33:57 +0100
committerConstantin Riß <constantin.riss@dre.de>2010-02-09 21:33:57 +0100
commite2ba8593b4911e546072be899c7246d68d92c10a (patch)
tree5cc7cd344f50a7f8f2603e85582230f92e4aab63 /main.cpp
parent57935140306a95ba35f713d399f2d917a121d9c3 (diff)
downloadc3d-e2ba8593b4911e546072be899c7246d68d92c10a.tar
c3d-e2ba8593b4911e546072be899c7246d68d92c10a.zip
.....................^^
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index 4bfbf85..6eeb0e8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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);
}
}