-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from chickensoft-games/feat/native-resolution
feat: determine correct scale factor and native pixel resolution on windows
- Loading branch information
Showing
19 changed files
with
513 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace Chickensoft.Platform.Windows; | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Gdi32 { | ||
public const string GDI32 = "gdi32.dll"; | ||
public const int DESKTOP_VERT_RES = 117; | ||
public const int DESKTOP_HORZ_RES = 118; | ||
|
||
[LibraryImport( | ||
GDI32, | ||
SetLastError = true, | ||
StringMarshalling = StringMarshalling.Utf16, | ||
EntryPoint = "CreateDCW" | ||
)] | ||
internal static partial IntPtr CreateDC( | ||
string pwszDriver, // typically null for display | ||
string pwszDevice, // "\\.\DISPLAYx" | ||
string pwszOutput, // null | ||
IntPtr lpInitData // IntPtr.Zero | ||
); | ||
|
||
[LibraryImport(GDI32, SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
internal static partial bool DeleteDC(IntPtr hdc); | ||
|
||
[LibraryImport(GDI32, SetLastError = true)] | ||
internal static partial int GetDeviceCaps(IntPtr hdc, int nIndex); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
extends Control | ||
|
||
func _ready() -> void: | ||
print("ready") | ||
var displays = Displays.new() | ||
var scaleFactor = displays.GetDisplayScaleFactor(get_window()) | ||
var window := get_window() | ||
var scaleFactor = displays.GetDisplayScaleFactor(window) | ||
print("scale factor: ", scaleFactor) | ||
var resolution = displays.GetNativeResolution(window) | ||
print("native resolution: ", resolution) |
15 changes: 15 additions & 0 deletions
15
sandbox/Chickensoft.Platform.SandboxRef/.vscode/launch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "🕹 Debug Game", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build", | ||
"program": "${env:GODOT}", | ||
"args": [], | ||
"cwd": "${workspaceFolder}", | ||
"stopAtEntry": false, | ||
"console": "integratedTerminal" | ||
}, | ||
] | ||
} |
Oops, something went wrong.