summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorCsaba Hruska <csaba.hruska@gmail.com>2018-09-21 20:01:13 +0300
committerKosyrev Serge <_deepfire@feelingofgreen.ru>2018-09-21 20:01:13 +0300
commita5880684868824b34689df4589106730ad1c7fc0 (patch)
treeb62f9ee5bc049919b4b482325b489baf5f5f572f /examples
parent91b11accd5c1b3fccd21851b5841d790738b815c (diff)
pickInt: sample from mouse position as well
Diffstat (limited to 'examples')
-rw-r--r--examples/pickInt.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/pickInt.hs b/examples/pickInt.hs
index 36bc36c..2703e91 100644
--- a/examples/pickInt.hs
+++ b/examples/pickInt.hs
@@ -64,11 +64,14 @@ main = do
64 toScreen = screenM screenW screenH 64 toScreen = screenM screenW screenH
65 "viewProj" @= pure (mat4ToM44F $! (Vc.fromProjective $! Vc.translation cvpos) Vc..*. toScreen) 65 "viewProj" @= pure (mat4ToM44F $! (Vc.fromProjective $! Vc.translation cvpos) Vc..*. toScreen)
66 66
67 (curX, curY) <- GLFW.getCursorPos win
67 let pickPoints = -- should be fb 0 fb 1 (pick) 68 let pickPoints = -- should be fb 0 fb 1 (pick)
68 [ (0, 0) -- black 0 69 [ (clamp curX 800, clamp curY 600)
70 , (0, 0) -- black 0
69 , (200, 200) -- ..blue, ffff0000 2 71 , (200, 200) -- ..blue, ffff0000 2
70 , (600, 400) -- ..red, ff0000ff 1 72 , (600, 400) -- ..red, ff0000ff 1
71 ] :: [(Int, Int)] 73 ] :: [(Int, Int)]
74 clamp v m = min (pred m) $ max 0 (floor v)
72 75
73 -- render to render texture 76 -- render to render texture
74 LambdaCubeGL.renderFrame pipePick 77 LambdaCubeGL.renderFrame pipePick
@@ -186,3 +189,4 @@ initWindow title width height = do
186 Just win <- GLFW.createWindow width height title Nothing Nothing 189 Just win <- GLFW.createWindow width height title Nothing Nothing
187 GLFW.makeContextCurrent $ Just win 190 GLFW.makeContextCurrent $ Just win
188 return win 191 return win
192