From 17d1731d661f9ab1586ed0e1a141de8da6639169 Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Mon, 6 Mar 2017 15:51:59 +0100
Subject: [PATCH] fix Window.MousePosition (new coordinate system)

---
 pixelgl/input.go | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/pixelgl/input.go b/pixelgl/input.go
index f2ba4c0..94f2406 100644
--- a/pixelgl/input.go
+++ b/pixelgl/input.go
@@ -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.
-- 
GitLab