-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a40626e
commit 20ca1c9
Showing
3 changed files
with
37 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package strife | ||
|
||
import ( | ||
"runtime" | ||
|
||
"github.com/veandco/go-sdl2/sdl" | ||
) | ||
|
||
func defaultDpi() float32 { | ||
if runtime.GOOS == "windows" { | ||
return 96.0 | ||
} else if runtime.GOOS == "darwin" { | ||
return 72.0 | ||
} | ||
panic("no dpi for this os") | ||
} | ||
|
||
// returns the dpi, and the default dpi | ||
func GetDisplayDPI(displayIndex int) (float32, float32) { | ||
_, hdpi, _, err := sdl.GetDisplayDPI(displayIndex) | ||
if err != nil { | ||
return 0, defaultDpi() | ||
} | ||
return hdpi, defaultDpi() | ||
} |
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,25 +1,7 @@ | ||
package strife | ||
|
||
import ( | ||
"runtime" | ||
// +build !windows | ||
|
||
"github.com/veandco/go-sdl2/sdl" | ||
) | ||
package strife | ||
|
||
func defaultDpi() float32 { | ||
if runtime.GOOS == "windows" { | ||
return 96.0 | ||
} else if runtime.GOOS == "darwin" { | ||
return 72.0 | ||
} | ||
panic("no dpi for this os") | ||
} | ||
func EnableDPI() { | ||
|
||
// returns the dpi, and the default dpi | ||
func GetDisplayDPI(displayIndex int) (float32, float32) { | ||
_, hdpi, _, err := sdl.GetDisplayDPI(displayIndex) | ||
if err != nil { | ||
return 0, defaultDpi() | ||
} | ||
return hdpi, defaultDpi() | ||
} |
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