glfw: fix mut scale bug

pull/4113/head
yuyi 2020-03-25 20:44:21 +08:00 committed by GitHub
parent 60fbceea43
commit aa0643f785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -40,7 +40,7 @@ pub const (
pub const (
KEY_ESCAPE = 256
key_space = 32
key_space = 32
KEY_LEFT_SUPER = 343
)
@ -147,10 +147,13 @@ pub fn create_window(c WinCfg) &glfw.Window {
// println('create window wnd=$cwindow ptr==$c.ptr')
C.glfwSetWindowUserPointer(cwindow, c.ptr)
scale := 1.0
mut scale := f32(1.0)
$if windows {
C.glfwGetWindowContentScale(cwindow, &scale, &scale)
}
$else {
scale = 1.0
}
window := &glfw.Window {
data: cwindow,
@ -257,10 +260,13 @@ pub fn get_cursor_pos(cwindow voidptr) (f64, f64) {
y := f64(0)
C.glfwGetCursorPos(cwindow, &x, &y)
scale := 1.0
mut scale := f32(1.0)
$if windows {
C.glfwGetWindowContentScale(cwindow, &scale, &scale)
}
$else {
scale = 1.0
}
return x/scale, y/scale
}