Merge pull request #74 from liamg/fix-mouse-pos-bug

fix offset bug
This commit is contained in:
Liam Galvin 2018-11-27 13:22:59 +00:00 committed by GitHub
commit 99e0baf6b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -17,9 +17,12 @@ func (gui *GUI) glfwScrollCallback(w *glfw.Window, xoff float64, yoff float64) {
}
}
func (gui *GUI) mouseMoveCallback(w *glfw.Window, xpos float64, ypos float64) {
func (gui *GUI) mouseMoveCallback(w *glfw.Window, px float64, py float64) {
scale := gui.scale()
px = px / float64(scale)
py = py / float64(scale)
px, py := w.GetCursorPos()
x := uint16(math.Floor((px - float64(gui.renderer.areaX)) / float64(gui.renderer.CellWidth())))
y := uint16(math.Floor((py - float64(gui.renderer.areaY)) / float64(gui.renderer.CellHeight())))