fixed build on windows
[gph-gfx] / test_win.c
index f1e75a5..ff13e56 100644 (file)
@@ -18,7 +18,7 @@ static HWND win;
 static HINSTANCE hinst;
 static HDC dc;
 static int win_width, win_height;
-
+static int quit;
 
 int WINAPI WinMain(HINSTANCE hinst_, HINSTANCE hprev, char *cmdline, int showcmd)
 {
@@ -56,16 +56,63 @@ int WINAPI WinMain(HINSTANCE hinst_, HINSTANCE hprev, char *cmdline, int showcmd
 end:
 
        ggfx_shutdown();
-       ReleaseDC(dc);
+       ReleaseDC(win, dc);
        DestroyWindow(win);
        UnregisterClass("gphgfxtest", hinst);
        return 0;
 }
 
+
+static void redraw(void)
+{
+       RECT rect;
+       HBRUSH brush;
+
+       rect.left = rect.top = 0;
+       rect.right = win_width;
+       rect.bottom = win_height;
+
+       brush = CreateSolidBrush(RGB(128, 0, 0));
+
+       FillRect(dc, &rect, brush);
+}
+
+static void reshape(int x, int y)
+{
+}
+
+static void keydown(int key, int x, int y)
+{
+       switch(key) {
+       case 27:
+               quit = 1;
+               break;
+       }
+}
+
+static void keyup(int key, int x, int y)
+{
+}
+
+static void button(int bn, int st, int x, int y)
+{
+}
+
+static void motion(int x, int y)
+{
+}
+
 static int create_window(const char *title, int width, int height)
 {
-       if(!(win = CreateWindow("gphgfxtest", title, WS_OVERLAPPEDWINDOW, 0, 0, width,
-                                       height, 0, 0, hinst, 0))) {
+       RECT rect;
+
+       rect.left = rect.top = 0;
+       rect.right = width;
+       rect.bottom = height;
+       AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, 0);
+
+       if(!(win = CreateWindow("gphgfxtest", title, WS_OVERLAPPEDWINDOW, 0, 0,
+                               rect.right - rect.left, rect.bottom - rect.top, 0, 0, hinst, 0))) {
                fprintf(stderr, "failed to create window\n");
                return -1;
        }
@@ -162,5 +209,5 @@ static void handle_mbutton(int bn, int st, WPARAM wparam, LPARAM lparam)
 {
        int x = lparam & 0xffff;
        int y = lparam >> 16;
-       mouse(bn, st, x, y);
+       button(bn, st, x, y);
 }