Unregister class after jaggl_bootstrap_proc_table

master
Graham 5 years ago
parent 6006f24027
commit 1a6ff16586
  1. 26
      gl-natives/src/main/c/jaggl.c

@ -91,7 +91,6 @@ static GLXDrawable jaggl_drawable;
static bool jaggl_double_buffered; static bool jaggl_double_buffered;
#elif defined(_WIN32) #elif defined(_WIN32)
static HINSTANCE jaggl_instance; static HINSTANCE jaggl_instance;
static ATOM jaggl_class;
static HWND jaggl_window; static HWND jaggl_window;
static HDC jaggl_device; static HDC jaggl_device;
static HGLRC jaggl_context; static HGLRC jaggl_context;
@ -219,21 +218,18 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
} }
static void jaggl_bootstrap_proc_table(void) { static void jaggl_bootstrap_proc_table(void) {
if (!jaggl_class) { WNDCLASS c = {
WNDCLASS c = { .lpfnWndProc = DefWindowProc,
.lpfnWndProc = DefWindowProc, .hInstance = jaggl_instance,
.hInstance = jaggl_instance, .lpszClassName = "OpenRS2"
.lpszClassName = "OpenRS2" };
}; ATOM class_atom = RegisterClass(&c);
if (!class_atom) {
jaggl_class = RegisterClass(&c); return;
if (!jaggl_class) {
return;
}
} }
HWND hwnd = CreateWindow( HWND hwnd = CreateWindow(
MAKEINTATOM(jaggl_class), MAKEINTATOM(class_atom),
"OpenRS2", "OpenRS2",
0, 0,
0, 0,
@ -246,7 +242,7 @@ static void jaggl_bootstrap_proc_table(void) {
NULL NULL
); );
if (!hwnd) { if (!hwnd) {
return; goto destroy_class;
} }
HDC hdc = GetDC(hwnd); HDC hdc = GetDC(hwnd);
@ -293,6 +289,8 @@ destroy_device:
ReleaseDC(hwnd, hdc); ReleaseDC(hwnd, hdc);
destroy_window: destroy_window:
DestroyWindow(hwnd); DestroyWindow(hwnd);
destroy_class:
UnregisterClass(MAKEINTATOM(class_atom), jaggl_instance);
} }
#endif #endif

Loading…
Cancel
Save