aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Sunet <jeannekamikaze@gmail.com>2012-08-30 12:41:52 +0200
committerMarc Sunet <jeannekamikaze@gmail.com>2012-08-30 12:41:52 +0200
commit56a7e6afb08f9bb2f9f4d2d9054259b3e7011329 (patch)
tree21e67873b4c89a81a41c6bf6537f749788e3f6e8
parent8b83b3f317cf730998ca27e81d18cac0845f8585 (diff)
Viewport now recomputed on resize; added GLFW symbols to export list
-rw-r--r--Spear.lkshw4
-rw-r--r--Spear/App/Application.hs21
2 files changed, 20 insertions, 5 deletions
diff --git a/Spear.lkshw b/Spear.lkshw
index 0042a1e..0f8f6de 100644
--- a/Spear.lkshw
+++ b/Spear.lkshw
@@ -1,10 +1,10 @@
1Version of workspace file format: 1Version of workspace file format:
2 1 2 1
3Time of storage: 3Time of storage:
4 "Wed Aug 29 20:01:37 CEST 2012" 4 "Thu Aug 30 12:40:21 CEST 2012"
5Name of the workspace: 5Name of the workspace:
6 "Spear" 6 "Spear"
7File paths of contained packages: 7File paths of contained packages:
8 ["demos/simple-scene/simple-scene.cabal","Spear.cabal"] 8 ["demos/simple-scene/simple-scene.cabal","Spear.cabal"]
9Maybe file path of an active package: 9Maybe file path of an active package:
10 Just "Spear.cabal" \ No newline at end of file 10 Just "demos/simple-scene/simple-scene.cabal" \ No newline at end of file
diff --git a/Spear/App/Application.hs b/Spear/App/Application.hs
index 49fbbc7..a547c37 100644
--- a/Spear/App/Application.hs
+++ b/Spear/App/Application.hs
@@ -5,6 +5,10 @@ module Spear.App.Application
5, Context 5, Context
6, SpearWindow 6, SpearWindow
7, Update 7, Update
8, Size(..)
9, DisplayBits(..)
10, WindowMode(..)
11, Opened(..)
8 -- * Setup 12 -- * Setup
9, setup 13, setup
10, quit 14, quit
@@ -12,6 +16,9 @@ module Spear.App.Application
12 -- * Main loop 16 -- * Main loop
13, run 17, run
14, runCapped 18, runCapped
19 -- * Helpers
20, swapBuffers
21, getParam
15) 22)
16where 23where
17 24
@@ -42,8 +49,9 @@ newtype SpearWindow = SpearWindow { rkey :: Resource }
42 49
43 50
44-- | Set up an application 'SpearWindow'. 51-- | Set up an application 'SpearWindow'.
45setup :: Dimensions -> [DisplayBits] -> WindowMode -> Context -> Setup SpearWindow 52setup :: Dimensions -> [DisplayBits] -> WindowMode -> Context
46setup (w, h) displayBits windowMode (major, minor) = do 53 -> WindowSizeCallback -> Setup SpearWindow
54setup (w, h) displayBits windowMode (major, minor) onResize' = do
47 glfwInit 55 glfwInit
48 56
49 setupIO $ do 57 setupIO $ do
@@ -56,6 +64,8 @@ setup (w, h) displayBits windowMode (major, minor) = do
56 windowTitle $= "Spear Game Framework" 64 windowTitle $= "Spear Game Framework"
57 GL.viewport $= (Position 0 0, Size (fromIntegral w) (fromIntegral h)) 65 GL.viewport $= (Position 0 0, Size (fromIntegral w) (fromIntegral h))
58 66
67 windowSizeCallback $= (onResize onResize')
68
59 initialiseTimingSubsystem 69 initialiseTimingSubsystem
60 70
61 rkey <- register quit 71 rkey <- register quit
@@ -119,4 +129,9 @@ runCapped' ddt timer update = do
119 let dt = getDelta t'' 129 let dt = getDelta t''
120 when (dt < ddt) $ gameIO $ Timer.sleep (ddt - dt) 130 when (dt < ddt) $ gameIO $ Timer.sleep (ddt - dt)
121 runCapped' ddt timer' update 131 runCapped' ddt timer' update
122 132
133
134onResize :: WindowSizeCallback -> Size -> IO ()
135onResize callback s@(Size w h) = do
136 GL.viewport $= (Position 0 0, Size (fromIntegral w) (fromIntegral h))
137 callback s