|
|
@@ -28,7 +28,6 @@ static double __timeStart;
|
|
|
static double __timeAbsolute;
|
|
|
static bool __vsync = WINDOW_VSYNC;
|
|
|
static HINSTANCE __hinstance = 0;
|
|
|
-static HWND __attachToWindow = 0;
|
|
|
static HWND __hwnd = 0;
|
|
|
static HDC __hdc = 0;
|
|
|
static HGLRC __hrc = 0;
|
|
|
@@ -787,7 +786,7 @@ bool initializeGL(WindowCreationParams* params)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-Platform* Platform::create(Game* game, void* attachToWindow)
|
|
|
+Platform* Platform::create(Game* game)
|
|
|
{
|
|
|
GP_ASSERT(game);
|
|
|
|
|
|
@@ -797,8 +796,6 @@ Platform* Platform::create(Game* game, void* attachToWindow)
|
|
|
// Get the application module handle.
|
|
|
__hinstance = ::GetModuleHandle(NULL);
|
|
|
|
|
|
- __attachToWindow = (HWND)attachToWindow;
|
|
|
-
|
|
|
// Read window settings from config.
|
|
|
WindowCreationParams params;
|
|
|
params.fullscreen = false;
|
|
|
@@ -890,65 +887,52 @@ Platform* Platform::create(Game* game, void* attachToWindow)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!__attachToWindow)
|
|
|
+
|
|
|
+ // Register our window class.
|
|
|
+ WNDCLASSEX wc;
|
|
|
+ wc.cbSize = sizeof(WNDCLASSEX);
|
|
|
+ wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
|
|
+ wc.lpfnWndProc = (WNDPROC)__WndProc;
|
|
|
+ wc.cbClsExtra = 0;
|
|
|
+ wc.cbWndExtra = 0;
|
|
|
+ wc.hInstance = __hinstance;
|
|
|
+ wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
|
|
+ wc.hIconSm = NULL;
|
|
|
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
|
+ wc.hbrBackground = NULL; // No brush - we are going to paint our own background
|
|
|
+ wc.lpszMenuName = NULL; // No default menu
|
|
|
+ wc.lpszClassName = L"gameplay";
|
|
|
+
|
|
|
+ if (!::RegisterClassEx(&wc))
|
|
|
{
|
|
|
- // Register our window class.
|
|
|
- WNDCLASSEX wc;
|
|
|
- wc.cbSize = sizeof(WNDCLASSEX);
|
|
|
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
|
|
- wc.lpfnWndProc = (WNDPROC)__WndProc;
|
|
|
- wc.cbClsExtra = 0;
|
|
|
- wc.cbWndExtra = 0;
|
|
|
- wc.hInstance = __hinstance;
|
|
|
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
|
|
- wc.hIconSm = NULL;
|
|
|
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
|
- wc.hbrBackground = NULL; // No brush - we are going to paint our own background
|
|
|
- wc.lpszMenuName = NULL; // No default menu
|
|
|
- wc.lpszClassName = L"gameplay";
|
|
|
-
|
|
|
- if (!::RegisterClassEx(&wc))
|
|
|
- {
|
|
|
- GP_ERROR("Failed to register window class.");
|
|
|
- goto error;
|
|
|
- }
|
|
|
+ GP_ERROR("Failed to register window class.");
|
|
|
+ goto error;
|
|
|
+ }
|
|
|
|
|
|
- if (params.fullscreen)
|
|
|
+ if (params.fullscreen)
|
|
|
+ {
|
|
|
+ DEVMODE dm;
|
|
|
+ memset(&dm, 0, sizeof(dm));
|
|
|
+ dm.dmSize= sizeof(dm);
|
|
|
+ dm.dmPelsWidth = width;
|
|
|
+ dm.dmPelsHeight = height;
|
|
|
+ dm.dmBitsPerPel = DEFAULT_COLOR_BUFFER_SIZE;
|
|
|
+ dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
|
|
+
|
|
|
+ // Try to set selected mode and get results. NOTE: CDS_FULLSCREEN gets rid of start bar.
|
|
|
+ if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
|
|
{
|
|
|
- DEVMODE dm;
|
|
|
- memset(&dm, 0, sizeof(dm));
|
|
|
- dm.dmSize= sizeof(dm);
|
|
|
- dm.dmPelsWidth = width;
|
|
|
- dm.dmPelsHeight = height;
|
|
|
- dm.dmBitsPerPel = DEFAULT_COLOR_BUFFER_SIZE;
|
|
|
- dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
|
|
-
|
|
|
- // Try to set selected mode and get results. NOTE: CDS_FULLSCREEN gets rid of start bar.
|
|
|
- if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
|
|
- {
|
|
|
- params.fullscreen = false;
|
|
|
- GP_ERROR("Failed to start game in full-screen mode with resolution %dx%d.", width, height);
|
|
|
- goto error;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!initializeGL(¶ms))
|
|
|
+ params.fullscreen = false;
|
|
|
+ GP_ERROR("Failed to start game in full-screen mode with resolution %dx%d.", width, height);
|
|
|
goto error;
|
|
|
-
|
|
|
- // Show the window.
|
|
|
- ShowWindow(__hwnd, SW_SHOW);
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- // Attach to a previous windows
|
|
|
- __hwnd = (HWND)__attachToWindow;
|
|
|
- __hdc = GetDC(__hwnd);
|
|
|
|
|
|
- SetWindowLongPtr(__hwnd, GWLP_WNDPROC, (LONG)(WNDPROC)__WndProc);
|
|
|
+ if (!initializeGL(¶ms))
|
|
|
+ goto error;
|
|
|
|
|
|
- if (!initializeGL(NULL))
|
|
|
- goto error;
|
|
|
- }
|
|
|
+ // Show the window.
|
|
|
+ ShowWindow(__hwnd, SW_SHOW);
|
|
|
|
|
|
#ifdef GP_USE_GAMEPAD
|
|
|
// Initialize XInputGamepads.
|
|
|
@@ -992,9 +976,6 @@ int Platform::enterMessagePump()
|
|
|
if (_game->getState() != Game::RUNNING)
|
|
|
_game->run();
|
|
|
|
|
|
- if (__attachToWindow)
|
|
|
- return 0;
|
|
|
-
|
|
|
// Enter event dispatch loop.
|
|
|
MSG msg;
|
|
|
while (true)
|