fix Window.MousePosition (new coordinate system)

This commit is contained in:
faiface 2017-03-06 15:51:59 +01:00
parent 146797bad5
commit 17d1731d66
1 changed files with 4 additions and 5 deletions

View File

@ -30,11 +30,10 @@ func (w *Window) MousePosition() pixel.Vec {
width, height = float64(wi), float64(hi) width, height = float64(wi), float64(hi)
}) })
// transform to OpenGL coordinates return pixel.V(
x = (x - width/2) / (width / 2) x/width*w.bounds.W()+w.bounds.X(),
y = (height/2 - y) / (height / 2) (height-y)/height*w.bounds.H()+w.bounds.Y(),
)
return pixel.V(x, y)
} }
// MouseScroll returns the scroll amount (in both axis) since the last call to Window.Update. // MouseScroll returns the scroll amount (in both axis) since the last call to Window.Update.