From 56a7e6afb08f9bb2f9f4d2d9054259b3e7011329 Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Thu, 30 Aug 2012 12:41:52 +0200 Subject: Viewport now recomputed on resize; added GLFW symbols to export list --- Spear.lkshw | 4 ++-- Spear/App/Application.hs | 21 ++++++++++++++++++--- 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 @@ Version of workspace file format: 1 Time of storage: - "Wed Aug 29 20:01:37 CEST 2012" + "Thu Aug 30 12:40:21 CEST 2012" Name of the workspace: "Spear" File paths of contained packages: ["demos/simple-scene/simple-scene.cabal","Spear.cabal"] Maybe file path of an active package: - Just "Spear.cabal" \ No newline at end of file + 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 , Context , SpearWindow , Update +, Size(..) +, DisplayBits(..) +, WindowMode(..) +, Opened(..) -- * Setup , setup , quit @@ -12,6 +16,9 @@ module Spear.App.Application -- * Main loop , run , runCapped + -- * Helpers +, swapBuffers +, getParam ) where @@ -42,8 +49,9 @@ newtype SpearWindow = SpearWindow { rkey :: Resource } -- | Set up an application 'SpearWindow'. -setup :: Dimensions -> [DisplayBits] -> WindowMode -> Context -> Setup SpearWindow -setup (w, h) displayBits windowMode (major, minor) = do +setup :: Dimensions -> [DisplayBits] -> WindowMode -> Context + -> WindowSizeCallback -> Setup SpearWindow +setup (w, h) displayBits windowMode (major, minor) onResize' = do glfwInit setupIO $ do @@ -56,6 +64,8 @@ setup (w, h) displayBits windowMode (major, minor) = do windowTitle $= "Spear Game Framework" GL.viewport $= (Position 0 0, Size (fromIntegral w) (fromIntegral h)) + windowSizeCallback $= (onResize onResize') + initialiseTimingSubsystem rkey <- register quit @@ -119,4 +129,9 @@ runCapped' ddt timer update = do let dt = getDelta t'' when (dt < ddt) $ gameIO $ Timer.sleep (ddt - dt) runCapped' ddt timer' update - + + +onResize :: WindowSizeCallback -> Size -> IO () +onResize callback s@(Size w h) = do + GL.viewport $= (Position 0 0, Size (fromIntegral w) (fromIntegral h)) + callback s -- cgit v1.2.3