aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Spear/App.hs2
-rw-r--r--Spear/Window.hs62
2 files changed, 34 insertions, 30 deletions
diff --git a/Spear/App.hs b/Spear/App.hs
index e85c46b..6473e1b 100644
--- a/Spear/App.hs
+++ b/Spear/App.hs
@@ -175,7 +175,7 @@ loop :: App s -> Window -> Game (AppState s) ()
175loop app window = do 175loop app window = do
176 -- For convenience, trigger an initial resize followed by a render of the 176 -- For convenience, trigger an initial resize followed by a render of the
177 -- application's initial state. 177 -- application's initial state.
178 (width, height) <- getWindowSize window 178 (width, height) <- getFramebufferSize window
179 resizeApp app (ResizeEvent width height) 179 resizeApp app (ResizeEvent width height)
180 renderApp app 180 renderApp app
181 181
diff --git a/Spear/Window.hs b/Spear/Window.hs
index a873362..2e30c0b 100644
--- a/Spear/Window.hs
+++ b/Spear/Window.hs
@@ -1,32 +1,32 @@
1module Spear.Window 1module Spear.Window
2 ( -- * Setup 2(
3 Dimensions, 3-- * Setup
4 WindowTitle, 4 Dimensions
5 5, WindowTitle
6 -- * Window 6-- * Window
7 Window, 7, Window
8 Width, 8, Width
9 Height, 9, Height
10 WindowEvent(..), 10, WindowEvent(..)
11 withWindow, 11, withWindow
12 pollWindowEvents, 12, pollWindowEvents
13 shouldWindowClose, 13, shouldWindowClose
14 swapBuffers, 14, swapBuffers
15 getWindowSize, 15, getWindowSize
16 16, getFramebufferSize
17 -- * Input 17-- * Input
18 pollInputEvents, 18, pollInputEvents
19 whenKeyDown, 19, whenKeyDown
20 whenKeyUp, 20, whenKeyUp
21 processKeys, 21, processKeys
22 processButtons, 22, processButtons
23 InputEvent(..), 23, InputEvent(..)
24 Key(..), 24, Key(..)
25 MouseButton(..), 25, MouseButton(..)
26 MouseProp(..), 26, MouseProp(..)
27 MousePos, 27, MousePos
28 MouseDelta, 28, MouseDelta
29 ) 29)
30where 30where
31 31
32import Spear.Game 32import Spear.Game
@@ -78,7 +78,7 @@ data Window = Window
78 78
79 79
80withWindow :: MonadIO io => Dimensions -> WindowTitle -> (Window -> IO a) -> io a 80withWindow :: MonadIO io => Dimensions -> WindowTitle -> (Window -> IO a) -> io a
81withWindow dim@(w, h) windowTitle run = liftIO $ do 81withWindow dim windowTitle run = liftIO $ do
82 window <- do 82 window <- do
83 success <- GLFW.init 83 success <- GLFW.init
84 unless success $ throw (WindowException "GLFW.initialize failed") 84 unless success $ throw (WindowException "GLFW.initialize failed")
@@ -149,6 +149,10 @@ swapBuffers = liftIO . GLFW.swapBuffers . glfwWindow
149getWindowSize :: MonadIO io => Window -> io (Width, Height) 149getWindowSize :: MonadIO io => Window -> io (Width, Height)
150getWindowSize = liftIO . GLFW.getWindowSize . glfwWindow 150getWindowSize = liftIO . GLFW.getWindowSize . glfwWindow
151 151
152-- | Get the window's framebuffer size.
153getFramebufferSize :: MonadIO io => Window -> io (Width, Height)
154getFramebufferSize = liftIO . GLFW.getFramebufferSize . glfwWindow
155
152getRequest :: MVar Bool -> IO Bool 156getRequest :: MVar Bool -> IO Bool
153getRequest mvar = 157getRequest mvar =
154 tryTakeMVar mvar >>= \x -> return $ fromMaybe False x 158 tryTakeMVar mvar >>= \x -> return $ fromMaybe False x