From 742703e31e611cad32afeadb994945c93a4be2ce Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Sun, 22 Jan 2017 01:03:16 +0100 Subject: [PATCH] Add initialization for SDL We continue to use the WinMain for the migration. --- blupi.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/blupi.cpp b/blupi.cpp index 41ba8e2..987cd5e 100644 --- a/blupi.cpp +++ b/blupi.cpp @@ -3,6 +3,8 @@ #define WIN32_LEAN_AND_MEAN +#define SDL_MAIN_HANDLED +#include #include #include #include @@ -586,6 +588,12 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) wc.lpszClassName = NAME; RegisterClass(&wc); + SDL_SetMainReady (); + auto res = SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO); + if (res < 0) + return false; + + // Create a window. if ( g_bFullScreen ) { @@ -838,7 +846,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, { if ( !GetMessage(&msg, NULL, 0, 0) ) { - return static_cast (msg.wParam); + goto out; } TranslateMessage(&msg); DispatchMessage(&msg); @@ -850,6 +858,8 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, } } +out: + SDL_Quit (); return static_cast (msg.wParam); }