mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-16 01:54:38 +02:00
#15 Windows: Alt+Enter switches betwen window and fullscreen modes, win32 console mode only for DEBUG configuration
This commit is contained in:
@@ -75,7 +75,7 @@
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>STB_VORBIS_NO_STDIO;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>MINIMAL;STB_VORBIS_NO_STDIO;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
@@ -86,8 +86,8 @@
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wcrt.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
@@ -1,13 +1,16 @@
|
||||
#ifdef _DEBUG
|
||||
#include "crtdbg.h"
|
||||
#endif
|
||||
/* // VS2015 ?
|
||||
#include <stdint.h>
|
||||
|
||||
void __cdecl operator delete(void *ptr, unsigned int size) {
|
||||
//
|
||||
}
|
||||
*/
|
||||
#ifdef MINIMAL
|
||||
#if _MSC_VER == 1900 // VS2015
|
||||
#include <malloc.h>
|
||||
void __cdecl operator delete(void *ptr, unsigned int size) { free(ptr); }
|
||||
// add "/d2noftol3" to compiler additional options
|
||||
// add define _NO_CRT_STDIO_INLINE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "game.h"
|
||||
|
||||
DWORD getTime() {
|
||||
@@ -177,10 +180,29 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
// keyboard
|
||||
case WM_CHAR :
|
||||
case WM_SYSCHAR :
|
||||
break;
|
||||
case WM_KEYDOWN :
|
||||
case WM_KEYUP :
|
||||
case WM_SYSKEYDOWN :
|
||||
case WM_SYSKEYUP :
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_SYSKEYUP:
|
||||
if (msg == WM_SYSKEYDOWN && wParam == VK_RETURN) { // switch to fullscreen or window
|
||||
static WINDOWPLACEMENT pLast;
|
||||
DWORD style = GetWindowLong(hWnd, GWL_STYLE);
|
||||
if (style & WS_OVERLAPPEDWINDOW) {
|
||||
MONITORINFO mInfo = { sizeof(mInfo) };
|
||||
if (GetWindowPlacement(hWnd, &pLast) && GetMonitorInfo(MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY), &mInfo)) {
|
||||
RECT &r = mInfo.rcMonitor;
|
||||
SetWindowLong(hWnd, GWL_STYLE, style & ~WS_OVERLAPPEDWINDOW);
|
||||
MoveWindow(hWnd, r.left, r.top, r.right - r.left, r.bottom - r.top, FALSE);
|
||||
}
|
||||
} else {
|
||||
SetWindowLong(hWnd, GWL_STYLE, style | WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPlacement(hWnd, &pLast);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Input::setDown(keyToInputKey(wParam), msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN);
|
||||
break;
|
||||
// mouse
|
||||
@@ -240,9 +262,10 @@ void freeGL(HGLRC hRC) {
|
||||
wglDeleteContext(hRC);
|
||||
}
|
||||
|
||||
|
||||
#ifndef _DEBUG
|
||||
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||
#else
|
||||
int main() {
|
||||
#ifdef _DEBUG
|
||||
_CrtMemState _ms;
|
||||
_CrtMemCheckpoint(&_ms);
|
||||
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
|
||||
@@ -263,7 +286,7 @@ int main() {
|
||||
SetWindowLong(hWnd, GWL_WNDPROC, (LONG)&WndProc);
|
||||
ShowWindow(hWnd, SW_SHOWDEFAULT);
|
||||
|
||||
DWORD time, lastTime = getTime(), fpsTime = lastTime + 1000, fps = 0;
|
||||
DWORD lastTime = getTime(), fpsTime = lastTime + 1000, fps = 0;
|
||||
MSG msg;
|
||||
|
||||
do {
|
||||
@@ -273,7 +296,7 @@ int main() {
|
||||
} else {
|
||||
joyUpdate();
|
||||
|
||||
time = getTime();
|
||||
DWORD time = getTime();
|
||||
if (time <= lastTime)
|
||||
continue;
|
||||
|
||||
|
Reference in New Issue
Block a user