From 0fc9ec28ef446c135c3c00dfb646350af00b21eb Mon Sep 17 00:00:00 2001 From: banx Date: Fri, 13 Dec 2013 15:47:50 -0800 Subject: [PATCH 1/5] removing duplicate call for fromIntegral --- gloss/Graphics/Gloss/Geometry/Angle.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gloss/Graphics/Gloss/Geometry/Angle.hs b/gloss/Graphics/Gloss/Geometry/Angle.hs index 1badc1e..4865cb3 100644 --- a/gloss/Graphics/Gloss/Geometry/Angle.hs +++ b/gloss/Graphics/Gloss/Geometry/Angle.hs @@ -1,4 +1,3 @@ - -- | Geometric functions concerning angles. If not otherwise specified, all angles are in radians. module Graphics.Gloss.Geometry.Angle ( degToRad @@ -21,6 +20,6 @@ radToDeg r = r * 180 / pi -- | Normalise an angle to be between 0 and 2*pi radians {-# INLINE normaliseAngle #-} normaliseAngle :: Float -> Float -normaliseAngle f = f - 2 * pi * (fromIntegral . floor') (f / (2 * pi)) +normaliseAngle f = f - 2 * pi * floor' (f / (2 * pi)) where floor' :: Float -> Int floor' x = fromIntegral (floor x :: Int) From a097fd6575624714d2d3cdf764258cb266753d3e Mon Sep 17 00:00:00 2001 From: Tuong Nguyen Manh Date: Sat, 14 Dec 2013 09:59:03 +0100 Subject: [PATCH 2/5] Remove automatic key handling from playIO --- gloss/Graphics/Gloss/Interface/IO/Game.hs | 11 ++++++++--- gloss/Graphics/Gloss/Interface/Pure/Game.hs | 1 + gloss/Graphics/Gloss/Internals/Interface/Game.hs | 8 ++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/gloss/Graphics/Gloss/Interface/IO/Game.hs b/gloss/Graphics/Gloss/Interface/IO/Game.hs index 4f45e61..ea12c3a 100644 --- a/gloss/Graphics/Gloss/Interface/IO/Game.hs +++ b/gloss/Graphics/Gloss/Interface/IO/Game.hs @@ -1,7 +1,7 @@ {-# LANGUAGE ExplicitForAll #-} --- | This game mode lets you manage your own input. Pressing ESC will still abort the program, --- but you don't get automatic pan and zoom controls like with `displayInWindow`. +-- | This game mode lets you manage your own input. Pressing ESC will not abort the program. +-- You also don't get automatic pan and zoom controls like with `displayInWindow`. module Graphics.Gloss.Interface.IO.Game ( module Graphics.Gloss.Data.Display , module Graphics.Gloss.Data.Picture @@ -28,4 +28,9 @@ playIO :: forall world -- It is passed the period of time (in seconds) needing to be advanced. -> IO () -playIO = playWithBackendIO defaultBackendState +playIO display backColor simResolution + worldStart worldToPicture worldHandleEvent worldAdvance + = playWithBackendIO defaultBackendState + display backColor simResolution + worldStart worldToPicture worldHandleEvent worldAdvance + False diff --git a/gloss/Graphics/Gloss/Interface/Pure/Game.hs b/gloss/Graphics/Gloss/Interface/Pure/Game.hs index 3af1b0a..6152f64 100644 --- a/gloss/Graphics/Gloss/Interface/Pure/Game.hs +++ b/gloss/Graphics/Gloss/Interface/Pure/Game.hs @@ -40,3 +40,4 @@ play display backColor simResolution (return . worldToPicture) (\event world -> return $ worldHandleEvent event world) (\time world -> return $ worldAdvance time world) + True diff --git a/gloss/Graphics/Gloss/Internals/Interface/Game.hs b/gloss/Graphics/Gloss/Internals/Interface/Game.hs index 51bf115..5f9b2a7 100644 --- a/gloss/Graphics/Gloss/Internals/Interface/Game.hs +++ b/gloss/Graphics/Gloss/Internals/Interface/Game.hs @@ -35,6 +35,7 @@ playWithBackendIO -> (Event -> world -> IO world) -- ^ A function to handle input events. -> (Float -> world -> IO world) -- ^ A function to step the world one iteration. -- It is passed the period of time (in seconds) needing to be advanced. + -> Bool -- ^ Whether to use the callback_exit or not. -> IO () playWithBackendIO @@ -46,6 +47,7 @@ playWithBackendIO worldToPicture worldHandleEvent worldAdvance + withCallbackExit = do let singleStepTime = 1 @@ -87,12 +89,14 @@ playWithBackendIO stateSR animateSR (readIORef viewSR) worldSR worldStart (\_ -> worldAdvance) singleStepTime) - , callback_exit () , callback_keyMouse worldSR viewSR worldHandleEvent , callback_motion worldSR worldHandleEvent , callback_reshape worldSR worldHandleEvent] - createWindow backend display backgroundColor callbacks + let exitCallback + = if withCallbackExit then [callback_exit ()] else [] + + createWindow backend display backgroundColor $ callbacks ++ exitCallback -- | Callback for KeyMouse events. From d26c0e618ad9c671891b84f4e55cb666bb0d6811 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sun, 2 Feb 2014 23:45:11 +0300 Subject: [PATCH 3/5] gloss.cabal: allow GLUT-2.5 Signed-off-by: Sergei Trofimovich --- gloss/gloss.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gloss/gloss.cabal b/gloss/gloss.cabal index f9f8d2b..e63d0fc 100644 --- a/gloss/gloss.cabal +++ b/gloss/gloss.cabal @@ -42,7 +42,7 @@ Library containers == 0.5.*, bytestring == 0.10.*, OpenGL == 2.8.*, - GLUT == 2.4.*, + GLUT >= 2.4 && < 2.6, bmp == 1.2.* ghc-options: From 2afb0c4a37e9468dbe161b7f778131f37966e740 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sun, 2 Feb 2014 23:46:12 +0300 Subject: [PATCH 4/5] gloss.cabal: port to OpenGL-2.9 Signed-off-by: Sergei Trofimovich --- gloss/Graphics/Gloss/Internals/Render/Picture.hs | 2 +- gloss/gloss.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gloss/Graphics/Gloss/Internals/Render/Picture.hs b/gloss/Graphics/Gloss/Internals/Render/Picture.hs index e0dac35..4a84eb0 100644 --- a/gloss/Graphics/Gloss/Internals/Render/Picture.hs +++ b/gloss/Graphics/Gloss/Internals/Render/Picture.hs @@ -319,7 +319,7 @@ installTexture width height bitmapData@(BitmapData _ fptr) cacheMe withForeignPtr fptr $ \ptr -> GL.texImage2D - Nothing + GLUT.Texture2D GL.NoProxy 0 GL.RGBA8 diff --git a/gloss/gloss.cabal b/gloss/gloss.cabal index e63d0fc..3b86e23 100644 --- a/gloss/gloss.cabal +++ b/gloss/gloss.cabal @@ -41,7 +41,7 @@ Library ghc-prim == 0.3.*, containers == 0.5.*, bytestring == 0.10.*, - OpenGL == 2.8.*, + OpenGL == 2.9.*, GLUT >= 2.4 && < 2.6, bmp == 1.2.* From 171c8beaca6e139e76e1c81561490b5e07e75154 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Mon, 3 Mar 2014 19:11:39 -0800 Subject: [PATCH 5/5] Fix type-signature of normaliseAngle's float' --- gloss/Graphics/Gloss/Geometry/Angle.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gloss/Graphics/Gloss/Geometry/Angle.hs b/gloss/Graphics/Gloss/Geometry/Angle.hs index 4865cb3..c3d0dc3 100644 --- a/gloss/Graphics/Gloss/Geometry/Angle.hs +++ b/gloss/Graphics/Gloss/Geometry/Angle.hs @@ -21,5 +21,5 @@ radToDeg r = r * 180 / pi {-# INLINE normaliseAngle #-} normaliseAngle :: Float -> Float normaliseAngle f = f - 2 * pi * floor' (f / (2 * pi)) - where floor' :: Float -> Int + where floor' :: Float -> Float floor' x = fromIntegral (floor x :: Int)