(WGL) Bind different callback for Vulkan

This commit is contained in:
twinaphex 2020-07-17 02:31:12 +02:00
parent ea920b1aaf
commit df73277ca8
3 changed files with 105 additions and 26 deletions

View File

@ -1133,6 +1133,70 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message,
} }
#endif #endif
#ifdef HAVE_VULKAN
LRESULT CALLBACK WndProcVK(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam)
{
LRESULT ret;
bool quit = false;
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
switch (message)
{
case WM_MOUSEMOVE:
case WM_POINTERDOWN:
case WM_POINTERUP:
case WM_POINTERUPDATE:
case WM_DEVICECHANGE:
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
case WM_NCLBUTTONDBLCLK:
#if _WIN32_WINNT >= 0x0500 /* 2K */
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
taskbar_is_created = true;
#endif
#ifdef HAVE_DINPUT
if (input_get_ptr() == &input_dinput)
{
void* input_data = input_get_data();
if (input_data && dinput_handle_message(input_data,
message, wparam, lparam))
return 0;
}
#endif
break;
case WM_DROPFILES:
case WM_SYSCOMMAND:
case WM_CHAR:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
case WM_SYSKEYDOWN:
case WM_CLOSE:
case WM_DESTROY:
case WM_QUIT:
case WM_MOVE:
case WM_SIZE:
case WM_COMMAND:
ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam);
if (quit)
return ret;
#if _WIN32_WINNT >= 0x0500 /* 2K */
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
taskbar_is_created = true;
#endif
break;
case WM_CREATE:
create_vk_context(hwnd, &g_win32->quit);
if (DragAcceptFiles_func)
DragAcceptFiles_func(hwnd, true);
return 0;
}
return DefWindowProc(hwnd, message, wparam, lparam);
}
#endif
#ifdef HAVE_GDI #ifdef HAVE_GDI
LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam) WPARAM wparam, LPARAM lparam)

View File

@ -60,6 +60,8 @@ int win32_change_display_settings(const char *str, void *devmode_data,
void create_graphics_context(HWND hwnd, bool *quit); void create_graphics_context(HWND hwnd, bool *quit);
void create_vk_context(HWND hwnd, bool *quit);
void create_gdi_context(HWND hwnd, bool *quit); void create_gdi_context(HWND hwnd, bool *quit);
bool win32_get_video_output(DEVMODE *dm, int mode, size_t len); bool win32_get_video_output(DEVMODE *dm, int mode, size_t len);
@ -124,11 +126,16 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam); WPARAM wparam, LPARAM lparam);
#endif #endif
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE) || defined(HAVE_VULKAN) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message, LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam); WPARAM wparam, LPARAM lparam);
#endif #endif
#if defined(HAVE_VULKAN)
LRESULT CALLBACK WndProcVK(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
#endif
LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam); WPARAM wparam, LPARAM lparam);

View File

@ -444,7 +444,13 @@ void create_graphics_context(HWND hwnd, bool *quit)
#endif #endif
break; break;
case GFX_CTX_VULKAN_API: case GFX_CTX_NONE:
default:
break;
}
}
void create_vk_context(HWND hwnd, bool *quit)
{ {
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
RECT rect; RECT rect;
@ -466,13 +472,6 @@ void create_graphics_context(HWND hwnd, bool *quit)
g_win32_inited = true; g_win32_inited = true;
#endif #endif
} }
break;
case GFX_CTX_NONE:
default:
break;
}
}
static void gfx_ctx_wgl_swap_interval(void *data, int interval) static void gfx_ctx_wgl_swap_interval(void *data, int interval)
{ {
@ -743,7 +742,16 @@ static void *gfx_ctx_wgl_init(void *video_driver)
win32_window_reset(); win32_window_reset();
win32_monitor_init(); win32_monitor_init();
switch (win32_api)
{
case GFX_CTX_VULKAN_API:
wndclass.lpfnWndProc = WndProcVK;
break;
default:
wndclass.lpfnWndProc = WndProcWGL; wndclass.lpfnWndProc = WndProcWGL;
break;
}
if (!win32_window_init(&wndclass, true, NULL)) if (!win32_window_init(&wndclass, true, NULL))
goto error; goto error;