mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-04 15:04:28 +01:00
ui: Check the return value of ReleaseDC()
This commit is contained in:
parent
96a43bcb4d
commit
3619a796dc
@ -20,16 +20,21 @@ package ui
|
|||||||
//
|
//
|
||||||
// #include <windows.h>
|
// #include <windows.h>
|
||||||
//
|
//
|
||||||
// static int getDPI() {
|
// static char* getDPI(int* dpi) {
|
||||||
// HDC dc = GetWindowDC(0);
|
// HDC dc = GetWindowDC(0);
|
||||||
// int dpi = GetDeviceCaps(dc, LOGPIXELSX);
|
// *dpi = GetDeviceCaps(dc, LOGPIXELSX);
|
||||||
// ReleaseDC(0, dc);
|
// if (!ReleaseDC(0, dc)) {
|
||||||
// return dpi;
|
// return "ReleaseDC failed";
|
||||||
|
// }
|
||||||
|
// return "";
|
||||||
// }
|
// }
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
func deviceScale() float64 {
|
func deviceScale() float64 {
|
||||||
dpi := int(C.getDPI())
|
dpi := C.int(0)
|
||||||
|
if errmsg := C.GoString(C.getDPI(&dpi)); errmsg != "" {
|
||||||
|
panic(errmsg)
|
||||||
|
}
|
||||||
return float64(dpi) / 96
|
return float64(dpi) / 96
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user