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)
})
// transform to OpenGL coordinates
x = (x - width/2) / (width / 2)
y = (height/2 - y) / (height / 2)
return pixel.V(x, y)
return pixel.V(
x/width*w.bounds.W()+w.bounds.X(),
(height-y)/height*w.bounds.H()+w.bounds.Y(),
)
}
// MouseScroll returns the scroll amount (in both axis) since the last call to Window.Update.