From a8de930d347caa3f4de1b0b2c5bcd6d4ab47d9cf Mon Sep 17 00:00:00 2001 From: Jesse Millikan Date: Tue, 3 Mar 2015 18:38:41 -0500 Subject: [PATCH] Apparently working GLUT hack for running examples in recent Ubuntu --- game-in-haskell-book.cabal | 5 +++++ src/Animated.hs | 3 +++ src/Hunted/Main.hs | 3 +++ src/Music.hs | 3 +++ src/Shapes.hs | 3 +++ src/StateFRP.hs | 2 ++ 6 files changed, 19 insertions(+) diff --git a/game-in-haskell-book.cabal b/game-in-haskell-book.cabal index 74d9987..a3541a7 100644 --- a/game-in-haskell-book.cabal +++ b/game-in-haskell-book.cabal @@ -27,6 +27,7 @@ executable shapes-demo , bytestring , gloss == 1.9.2.1 , gloss-rendering == 1.9.2.1 + , GLUT == 2.5.1.1 hs-source-dirs: src default-language: Haskell2010 @@ -53,6 +54,7 @@ executable frp-demo , gloss-rendering == 1.9.2.1 , elerea == 2.8.0 , random == 1.1 + , GLUT == 2.5.1.1 hs-source-dirs: src default-language: Haskell2010 @@ -67,6 +69,7 @@ executable animated , gloss-rendering == 1.9.2.1 , elerea == 2.8.0 , random == 1.1 + , GLUT == 2.5.1.1 hs-source-dirs: src default-language: Haskell2010 @@ -82,6 +85,7 @@ executable music , elerea == 2.8.0 , random == 1.1 , ALUT == 2.3.0.2 + , GLUT == 2.5.1.1 hs-source-dirs: src default-language: Haskell2010 @@ -120,6 +124,7 @@ executable extended , random == 1.1 , ALUT == 2.3.0.2 , containers + , GLUT == 2.5.1.1 hs-source-dirs: src default-language: Haskell2010 diff --git a/src/Animated.hs b/src/Animated.hs index 1bab1d5..01ffbf4 100644 --- a/src/Animated.hs +++ b/src/Animated.hs @@ -12,6 +12,8 @@ import Control.Applicative ((<*>), (<$>)) import FRP.Elerea.Simple import System.Random +import qualified Graphics.UI.GLUT as GLUT + type Pos = Point data Player = Player { position :: Pos, movement :: Maybe PlayerMovement } deriving Show @@ -78,6 +80,7 @@ monsterSpeed = 5 main :: IO () main = do + (_,_) <- GLUT.getArgsAndInitialize (directionKey, directionKeySink) <- external (False, False, False, False) randomGenerator <- newStdGen glossState <- initState diff --git a/src/Hunted/Main.hs b/src/Hunted/Main.hs index 53a1e3b..7134b59 100644 --- a/src/Hunted/Main.hs +++ b/src/Hunted/Main.hs @@ -10,6 +10,8 @@ import Control.Monad (unless, join) import Control.Monad.Fix (fix) import FRP.Elerea.Simple as Elerea +import qualified Graphics.UI.GLUT as GLUT + width :: Int width = 640 @@ -18,6 +20,7 @@ height = 480 main :: IO () main = do + (_,_) <- GLUT.getArgsAndInitialize (directionKey, directionKeySink) <- external (False, False, False, False) (shootKey, shootKeySink) <- external (False, False, False, False) (windowSize,windowSizeSink) <- external (fromIntegral width, fromIntegral height) diff --git a/src/Music.hs b/src/Music.hs index 33fcfbd..fea68e2 100644 --- a/src/Music.hs +++ b/src/Music.hs @@ -15,6 +15,8 @@ import Sound.ALUT hiding (Static, direction) import System.IO ( hPutStrLn, stderr ) import Data.List (intersperse) +import qualified Graphics.UI.GLUT as GLUT + type Pos = Point data Player = Player { position :: Pos, movement :: Maybe PlayerMovement } deriving Show @@ -89,6 +91,7 @@ monsterSpeed = 5 main :: IO () main = do + (_,_) <- GLUT.getArgsAndInitialize (directionKey, directionKeySink) <- external (False, False, False, False) randomGenerator <- newStdGen glossState <- initState diff --git a/src/Shapes.hs b/src/Shapes.hs index 30cd069..8c61842 100644 --- a/src/Shapes.hs +++ b/src/Shapes.hs @@ -7,12 +7,15 @@ import System.Exit ( exitSuccess ) import Control.Concurrent (threadDelay) import Control.Monad (when, unless) +import qualified Graphics.UI.GLUT as GLUT + windowWidth, windowHeight :: Int windowWidth = 640 windowHeight = 480 main :: IO () main = do + (_,_) <- GLUT.getArgsAndInitialize glossState <- initState withWindow windowWidth windowHeight "Game-Demo" $ \win -> do loop glossState win diff --git a/src/StateFRP.hs b/src/StateFRP.hs index 9217c30..3405f4f 100644 --- a/src/StateFRP.hs +++ b/src/StateFRP.hs @@ -1,5 +1,6 @@ {-# LANGUAGE PackageImports, RecursiveDo #-} import "GLFW-b" Graphics.UI.GLFW as GLFW +import qualified Graphics.UI.GLUT as GLUT import Graphics.Gloss import Graphics.Gloss.Rendering import System.Exit ( exitSuccess ) @@ -38,6 +39,7 @@ monsterSpeed = 5 main :: IO () main = do + (_,_) <- GLUT.getArgsAndInitialize (directionKey, directionKeySink) <- external (False, False, False, False) randomGenerator <- newStdGen glossState <- initState