summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-3.2.20/test/testnativew32.c
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-08-30 16:53:58 -0700
committer3gg <3gg@shellblade.net>2025-08-30 16:53:58 -0700
commit6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch)
tree34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/test/testnativew32.c
parent8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff)
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/test/testnativew32.c')
-rw-r--r--src/contrib/SDL-3.2.20/test/testnativew32.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/test/testnativew32.c b/src/contrib/SDL-3.2.20/test/testnativew32.c
new file mode 100644
index 0000000..815c932
--- /dev/null
+++ b/src/contrib/SDL-3.2.20/test/testnativew32.c
@@ -0,0 +1,88 @@
1/*
2 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely.
11*/
12
13#include "testnative.h"
14
15#ifdef TEST_NATIVE_WINDOWS
16
17#include <windows.h>
18
19static void *CreateWindowNative(int w, int h);
20static void DestroyWindowNative(void *window);
21
22NativeWindowFactory WindowsWindowFactory = {
23 "windows",
24 CreateWindowNative,
25 DestroyWindowNative
26};
27
28LRESULT CALLBACK
29WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
30{
31 switch (msg) {
32 case WM_CLOSE:
33 DestroyWindow(hwnd);
34 break;
35 case WM_DESTROY:
36 PostQuitMessage(0);
37 break;
38 default:
39 return DefWindowProc(hwnd, msg, wParam, lParam);
40 }
41 return 0;
42}
43
44static void *
45CreateWindowNative(int w, int h)
46{
47 HWND hwnd;
48 WNDCLASS wc;
49
50 wc.style = 0;
51 wc.lpfnWndProc = WndProc;
52 wc.cbClsExtra = 0;
53 wc.cbWndExtra = 0;
54 wc.hInstance = GetModuleHandle(NULL);
55 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
56 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
57 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
58 wc.lpszMenuName = NULL;
59 wc.lpszClassName = TEXT("SDL Test");
60
61 if (!RegisterClass(&wc)) {
62 MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"),
63 MB_ICONEXCLAMATION | MB_OK);
64 return 0;
65 }
66
67 hwnd =
68 CreateWindow(TEXT("SDL Test"), TEXT(""), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
69 CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL),
70 NULL);
71 if (!hwnd) {
72 MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"),
73 MB_ICONEXCLAMATION | MB_OK);
74 return 0;
75 }
76
77 ShowWindow(hwnd, SW_SHOW);
78
79 return hwnd;
80}
81
82static void
83DestroyWindowNative(void *window)
84{
85 DestroyWindow((HWND)window);
86}
87
88#endif