mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
devicescale: Bug fix: SetProcessDPIAware needs to be called
This commit is contained in:
parent
d18fc36040
commit
7b759faf36
@ -32,7 +32,34 @@ package devicescale
|
||||
// }
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var (
|
||||
user32 = syscall.NewLazyDLL("user32")
|
||||
)
|
||||
|
||||
var (
|
||||
procSetProcessDPIAware = user32.NewProc("SetProcessDPIAware")
|
||||
)
|
||||
|
||||
func setProcessDPIAware() error {
|
||||
r, _, e := syscall.Syscall(procSetProcessDPIAware.Addr(), 0, 0, 0, 0)
|
||||
if e != 0 {
|
||||
return fmt.Errorf("devicescale: SetProcessDPIAware failed: error code: %d", e)
|
||||
}
|
||||
if r == 0 {
|
||||
return fmt.Errorf("devicescale: SetProcessDPIAware failed: returned value: %d", r)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func impl() float64 {
|
||||
if err := setProcessDPIAware(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
dpi := C.int(0)
|
||||
if errmsg := C.GoString(C.getDPI(&dpi)); errmsg != "" {
|
||||
panic(errmsg)
|
||||
|
Loading…
Reference in New Issue
Block a user