graphics

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 8159f7aa387ff27df7e2ecb19251802d11cc2212
parent ee9dc87ce9f9e03e42812f9939eeb611dac413e1
Author: Brian Swetland <swetland@frotz.net>
Date:   Sat,  2 Feb 2013 06:00:03 -0800

dxapp: minimal and cheesy mouse support

Diffstat:
Mcommon/app.h | 1+
Mcommon/dxapp.cc | 23++++++++++++++++++++---
2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/common/app.h b/common/app.h @@ -39,6 +39,7 @@ public: virtual int init(void) = 0; virtual void render(void) = 0; virtual void release(void) {}; + virtual void mouse(int x, int y, int buttons) {}; int start(HINSTANCE hInstance, int nCmdShow); void stop(void); diff --git a/common/dxapp.cc b/common/dxapp.cc @@ -46,7 +46,7 @@ void App::stop(void) { static App *app; static int moving = 0; - +static int frame = 0; static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; @@ -75,9 +75,25 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l moving = 0; app->reconfigure(0); break; - case WM_MOUSEMOVE: -// printx("win: mouse!\n"); + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_RBUTTONDOWN: + case WM_RBUTTONUP: { + int x = (short) LOWORD(lParam); + int y = (short) HIWORD(lParam); + int b = LOWORD(wParam); + app->mouse(x, y, b & 3); break; + } + case WM_MOUSEMOVE: { + int b = LOWORD(wParam); + if (b & 3) { + int x = (short) LOWORD(lParam); + int y = (short) HIWORD(lParam); + app->mouse(x, y, b & 3); + } + break; + } case WM_ACTIVATEAPP: printx("win: activate: %d\n", wParam); break; @@ -100,6 +116,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi DispatchMessage(&msg); } else { app->render(); + frame++; } } app->stop();