From 4e3efa239c9bcb5dd26b4ad9a4d43d4d6a266e6f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 18 Dec 2009 13:31:07 +0100 Subject: Use multi-pass rendering with seperate ambient and light shaders --- src/zoom.cpp | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/zoom.cpp') diff --git a/src/zoom.cpp b/src/zoom.cpp index e0050c5..8193d6a 100644 --- a/src/zoom.cpp +++ b/src/zoom.cpp @@ -22,6 +22,8 @@ #include "config.h" #include "gl.h" +#include + #ifdef _WIN32 #else @@ -69,7 +71,7 @@ bool WGLInit(HINSTANCE hInstance, HWND *hWnd, HDC *hDC, HGLRC *hRC) { if (!RegisterClass(&wc)) { MessageBox(0, "Failed To Register The Window Class.", "ERROR", MB_OK|MB_ICONEXCLAMATION); - return false; // Exit And Return FALSE + return false; } DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; @@ -421,24 +423,29 @@ int main() { case GenericEvent: if(event.xcookie.extension == xi_opcode && XGetEventData(disp, &event.xcookie)) { - XIRawEvent *rawEvent = reinterpret_cast(event.xcookie.data); - - float deltaX = 0, deltaY = 0; - double *rawValuator = rawEvent->raw_values; - - if(XIMaskIsSet(rawEvent->valuators.mask, 0)) { - deltaX = (float)*rawValuator; - ++rawValuator; + switch(event.xcookie.evtype) { + case XI_RawMotion: + XIRawEvent *rawEvent = reinterpret_cast(event.xcookie.data); + + float deltaX = 0, deltaY = 0; + double *rawValuator = rawEvent->raw_values; + + if(rawEvent->valuators.mask_len >= 1) { + if(XIMaskIsSet(rawEvent->valuators.mask, 0)) { + deltaX = (float)*rawValuator; + ++rawValuator; + } + + if(XIMaskIsSet(rawEvent->valuators.mask, 1)) { + deltaY = (float)*rawValuator; + ++rawValuator; + } + } + + if(deltaX != 0 || deltaY != 0) + game.turn(deltaX, deltaY); } - if(XIMaskIsSet(rawEvent->valuators.mask, 1)) { - deltaY = (float)*rawValuator; - ++rawValuator; - } - - if(deltaX != 0 || deltaY != 0) - game.turn(deltaX, deltaY); - XFreeEventData(disp, &event.xcookie); } } -- cgit v1.2.3