fixed build on windows master
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Mon, 26 Oct 2020 11:56:32 +0000 (13:56 +0200)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Mon, 26 Oct 2020 11:56:32 +0000 (13:56 +0200)
.gitignore
Makefile
test_win.c

index 0932ecf..67fb88b 100644 (file)
@@ -2,3 +2,4 @@
 *.d
 *.swp
 test
+test.exe
index cf2a010..91bf8b6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,7 @@ sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/')
 ifeq ($(sys), mingw)
        src += test_win.c
        CFLAGS += -DBUILD_WIN32
+       LDFLAGS += -lgdi32
 else
        src += test_x11.c
        CFLAGS += -DBUILD_X11
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);
 }