Skip to content

Commit de40b56

Browse files
committed
Added API call to indicate DPI awareness.
1 parent e6202d3 commit de40b56

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

.github/workflows/cibuild.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ jobs:
422422

423423
build-freebsd-x64:
424424
name: FreeBSD ${{ matrix.Configuration }} ${{ matrix.Platform }}
425-
runs-on: macos-12
425+
runs-on: macos-13
426426
strategy:
427427
fail-fast: false
428428
matrix:
@@ -489,7 +489,7 @@ jobs:
489489

490490
build-macos-x64:
491491
name: macOS ${{ matrix.Configuration }} ${{ matrix.Platform }}
492-
runs-on: macos-12
492+
runs-on: macos-13
493493
strategy:
494494
fail-fast: false
495495
matrix:

SamTFE/Sources/SeriousSam/SeriousSam.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,11 +1162,35 @@ void QuitScreenLoop(void)
11621162
}
11631163
}
11641164

1165+
#ifdef PLATFORM_WIN32
1166+
// [Cecil] Game application is DPI-aware
1167+
static BOOL _bDPIAware = FALSE;
1168+
// Make game application be aware of the DPI scaling on Windows Vista and later
1169+
static void SetDPIAwareness(void) {
1170+
// Load the library
1171+
HMODULE hUser = LoadLibraryA("User32.dll");
1172+
1173+
if (hUser == NULL) return;
1174+
1175+
// Try to find the DPI awareness method
1176+
typedef BOOL (*CSetAwarenessFunc)(void);
1177+
CSetAwarenessFunc pFunc = (CSetAwarenessFunc)GetProcAddress(hUser, "SetProcessDPIAware");
1178+
1179+
if (pFunc == NULL) return;
1180+
1181+
// Mark game application as DPI-aware
1182+
_bDPIAware = pFunc();
1183+
};
1184+
#endif // PLATFORM_WIN32
11651185

11661186
int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
11671187
{
11681188
(void)hPrevInstance;
11691189

1190+
#ifdef PLATFORM_WIN32
1191+
SetDPIAwareness();
1192+
#endif // PLATFORM_WIN32
1193+
11701194
if( !Init( hInstance, nCmdShow, lpCmdLine )) return FALSE;
11711195

11721196
// initialy, application is running and active, console and menu are off

SamTSE/Sources/SeriousSam/SeriousSam.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,11 +1162,35 @@ void QuitScreenLoop(void)
11621162
}
11631163
}
11641164

1165+
#ifdef PLATFORM_WIN32
1166+
// [Cecil] Game application is DPI-aware
1167+
static BOOL _bDPIAware = FALSE;
1168+
// Make game application be aware of the DPI scaling on Windows Vista and later
1169+
static void SetDPIAwareness(void) {
1170+
// Load the library
1171+
HMODULE hUser = LoadLibraryA("User32.dll");
1172+
1173+
if (hUser == NULL) return;
1174+
1175+
// Try to find the DPI awareness method
1176+
typedef BOOL (*CSetAwarenessFunc)(void);
1177+
CSetAwarenessFunc pFunc = (CSetAwarenessFunc)GetProcAddress(hUser, "SetProcessDPIAware");
1178+
1179+
if (pFunc == NULL) return;
1180+
1181+
// Mark game application as DPI-aware
1182+
_bDPIAware = pFunc();
1183+
};
1184+
#endif // PLATFORM_WIN32
11651185

11661186
int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
11671187
{
11681188
(void)hPrevInstance;
11691189

1190+
#ifdef PLATFORM_WIN32
1191+
SetDPIAwareness();
1192+
#endif // PLATFORM_WIN32
1193+
11701194
if( !Init( hInstance, nCmdShow, lpCmdLine )) return FALSE;
11711195

11721196
// initialy, application is running and active, console and menu are off

0 commit comments

Comments
 (0)