packages feed

gloss-raster-accelerate 1.9.0.0 → 2.0.0.0

raw patch · 4 files changed

+95/−215 lines, 4 filesdep +colour-acceleratedep −accelerate-cudadep ~acceleratedep ~basedep ~gloss

Dependencies added: colour-accelerate

Dependencies removed: accelerate-cuda

Dependency ranges changed: accelerate, base, gloss, gloss-accelerate

Files

Graphics/Gloss/Accelerate/Raster/Array.hs view
@@ -1,18 +1,27 @@+{-# LANGUAGE CPP        #-} {-# LANGUAGE RankNTypes #-}---- | Rendering of Accelerate arrays as raster images+-- |+-- Module      : Graphics.Gloss.Accelerate.Raster.Array+-- Copyright   : [2013..2017] Trevor L. McDonell+-- License     : BSD3 --+-- Maintainer  : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>+-- Stability   : experimental+-- Portability : non-portable (GHC extensions)+--+-- Rendering of Accelerate arrays as raster images+-- module Graphics.Gloss.Accelerate.Raster.Array (    module Graphics.Gloss.Accelerate.Data.Point,-  module Graphics.Gloss.Accelerate.Data.Color,+  module Data.Array.Accelerate.Data.Colour.RGBA,    -- * Display functions   Render, Display(..),-  animateArray, animateArrayWith,-  animateArrayIO, animateArrayIOWith,-  playArray, playArrayWith,-  playArrayIO, playArrayIOWith,+  animateArrayWith,+  animateArrayIOWith,+  playArrayWith,+  playArrayIOWith,    -- * Picture creation   makePicture,@@ -21,9 +30,9 @@  -- Friends import Graphics.Gloss.Accelerate.Render-import Graphics.Gloss.Accelerate.Data.Color import Graphics.Gloss.Accelerate.Data.Point import Graphics.Gloss.Accelerate.Data.Picture+import Data.Array.Accelerate.Data.Colour.RGBA  -- Standard library import Prelude                                          as P@@ -42,30 +51,14 @@ -- Animate -------------------------------------------------------------------- -- ------- --- | Animate a bitmap generated by an Accelerate computation, using the default---   backend.----animateArray-    :: Display                          -- ^ Display mode-    -> (Int, Int)                       -- ^ Number of pixels to draw per point-    -> (Exp Float -> Acc (Array DIM2 Color))-            -- ^ A function to construct an array of colours. The function-            --   should return an array of the same extent every time it is-            --   applied.-            ---            --   It is passed the time in seconds since the program started.-    -> IO ()-animateArray = animateArrayWith defaultRender-- -- | Animate a bitmap generated by an Accelerate computation, specifying the --   backend used to render the image. -- animateArrayWith-    :: Render                           -- ^ Method to render the array+    :: Render                           -- ^ Method to render the array (backend 'run1' function to use)     -> Display                          -- ^ Display mode     -> (Int, Int)                       -- ^ Number of pixels to draw per point-    -> (Exp Float -> Acc (Array DIM2 Color))+    -> (Exp Float -> Acc (Array DIM2 Colour))             -- ^ A function to construct an array of colours. The function             --   should return an array of the same extent every time it is             --   applied.@@ -73,7 +66,7 @@             --   It is passed the time in seconds since the program started.     -> IO () animateArrayWith render display (zoomX, zoomY) makeArray-  | zoomX < 1 || zoomY < 1+  | zoomX P.< 1 P.|| zoomY P.< 1   = error "Graphics.Gloss.Raster: invalid pixel scalar factor"    | otherwise@@ -81,26 +74,11 @@                         . fromList Z                         . return     in+#if MIN_VERSION_gloss(1,10,0)+    animateFixedIO display G.black (return . picture) (\_ -> return ())+#else     animateFixedIO display G.black (return . picture)----- | Animate a bitmap generated by an Accelerate computation and IO actions, using the default---   backend.----animateArrayIO-    :: Arrays world-    => Display                          -- ^ Display mode-    -> (Int, Int)                       -- ^ Number of pixels to draw per point-    -> (Float -> IO world)              -- ^ Extract world from time in seconds-                                        --   since the program started-    -> (Acc world -> Acc (Array DIM2 Color))-            -- ^ A function to construct an array of colours. The function-            --   should return an array of the same extent every time it is-            --   applied.-            ---            --   It is passed the world-    -> IO ()-animateArrayIO = animateArrayIOWith defaultRender+#endif   -- | Animate a bitmap generated by an Accelerate computation and IO actions, specifying the@@ -108,12 +86,12 @@ -- animateArrayIOWith     :: Arrays world-    => Render                           -- ^ Method to render the array+    => Render                           -- ^ Method to render the array (backend 'run1' function)     -> Display                          -- ^ Display mode     -> (Int, Int)                       -- ^ Number of pixels to draw per point     -> (Float -> IO world)              -- ^ Extract world from time in seconds                                         --   since the program started-    -> (Acc world -> Acc (Array DIM2 Color))+    -> (Acc world -> Acc (Array DIM2 Colour))             -- ^ A function to construct an array of colours. The function             --   should return an array of the same extent every time it is             --   applied.@@ -121,35 +99,18 @@             --   It is passed the world     -> IO () animateArrayIOWith render display (zoomX, zoomY) makeWorld makeArray-  | zoomX < 1 || zoomY < 1+  | zoomX P.< 1 P.|| zoomY P.< 1   = error "Graphics.Gloss.Raster: invalid pixel scalar factor"    | otherwise   = let picture = fmap (makePicture render zoomX zoomY makeArray)                 . makeWorld     in+#if MIN_VERSION_gloss(1,10,0)+    animateFixedIO display G.black picture (\_ -> return ())+#else     animateFixedIO display G.black picture----- | Play with a bitmap generated by an Accelerate computation, using the---   default backend.----playArray-    :: Arrays world-    => Display          -- ^ Display mode-    -> (Int, Int)       -- ^ Number of pixels to draw per point-    -> Int              -- ^ Number of simulation steps to take for each second of real time-    -> state            -- ^ The initial state-    -> (state -> world) -- ^ Extract the world state-    -> (Acc world -> Acc (Array DIM2 Color))-            -- ^ Compute the colour of the world-    -> (Event -> state -> state)-            -- ^ Handle input events-    -> (Float -> state -> state)-            -- ^ Step the world one iteration.-            --   It is passed the time in seconds since the program started.-    -> IO ()-playArray = playArrayWith defaultRender+#endif   -- | Play with a bitmap generated by an Accelerate computation, specifying the@@ -157,13 +118,13 @@ -- playArrayWith     :: Arrays world-    => Render           -- ^ Method to render the world+    => Render           -- ^ Method to render the world (backend 'run1' function)     -> Display          -- ^ Display mode     -> (Int, Int)       -- ^ Number of pixels to draw per point     -> Int              -- ^ Number of simulation steps to take for each second of real time     -> state            -- ^ The initial state     -> (state -> world) -- ^ Extract the world state-    -> (Acc world -> Acc (Array DIM2 Color))+    -> (Acc world -> Acc (Array DIM2 Colour))             -- ^ Compute the colour of the world     -> (Event -> state -> state)             -- ^ Handle input events@@ -173,7 +134,7 @@     -> IO () playArrayWith render display (zoomX, zoomY) stepRate               initState makeWorld makeArray handleEvent stepState-  | zoomX < 1 || zoomY < 1+  | zoomX P.< 1 P.|| zoomY P.< 1   = error "Graphics.Gloss.Raster: invalid pixel scalar factor"    | otherwise@@ -183,39 +144,18 @@     play display G.black stepRate initState picture handleEvent stepState  --- | Play with a bitmap generated by an Accelerate computation and IO actions, using the---   default backend.----playArrayIO-    :: Arrays world-    => Display          -- ^ Display mode-    -> (Int, Int)       -- ^ Number of pixels to draw per point-    -> Int              -- ^ Number of simulation steps to take for each second of real time-    -> state            -- ^ The initial state-    -> (state -> IO world) -- ^ Extract the world state-    -> (Acc world -> Acc (Array DIM2 Color))-            -- ^ Compute the colour of the world-    -> (Event -> state -> IO state)-            -- ^ Handle input events-    -> (Float -> state -> IO state)-            -- ^ Step the world one iteration.-            --   It is passed the time in seconds since the program started.-    -> IO ()-playArrayIO = playArrayIOWith defaultRender-- -- | Play with a bitmap generated by an Accelerate computation and IO actions, specifying the --   method used to render the world. -- playArrayIOWith     :: Arrays world-    => Render           -- ^ Method to render the world+    => Render           -- ^ Method to render the world (backend 'run1' function)     -> Display          -- ^ Display mode     -> (Int, Int)       -- ^ Number of pixels to draw per point     -> Int              -- ^ Number of simulation steps to take for each second of real time     -> state            -- ^ The initial state     -> (state -> IO world) -- ^ Extract the world state-    -> (Acc world -> Acc (Array DIM2 Color))+    -> (Acc world -> Acc (Array DIM2 Colour))             -- ^ Compute the colour of the world     -> (Event -> state -> IO state)             -- ^ Handle input events@@ -225,7 +165,7 @@     -> IO () playArrayIOWith render display (zoomX, zoomY) stepRate               initState makeWorld makeArray handleEvent stepState-  | zoomX < 1 || zoomY < 1+  | zoomX P.< 1 P.|| zoomY P.< 1   = error "Graphics.Gloss.Raster: invalid pixel scalar factor"    | otherwise@@ -247,10 +187,11 @@     => Render                                   -- ^ method to compute the image     -> Int                                      -- ^ pixel width     -> Int                                      -- ^ pixel height-    -> (Acc world -> Acc (Array DIM2 Color))    -- ^ function to create the image+    -> (Acc world -> Acc (Array DIM2 Colour))   -- ^ function to create the image     -> (world -> Picture)                       -- ^ new function that generates the picture makePicture render zoomX zoomY makeArray   = let -- compute the image+        -- assume the host is a little-endian architecture         pixels          = render (A.map (packRGBA . opaque) . makeArray)          -- Turn the array into a Gloss picture
Graphics/Gloss/Accelerate/Raster/Field.hs view
@@ -1,18 +1,27 @@+{-# LANGUAGE CPP        #-} {-# LANGUAGE RankNTypes #-}---- | Rendering of 2D functions as raster fields+-- |+-- Module      : Graphics.Gloss.Accelerate.Raster.Field+-- Copyright   : [2013..2017] Trevor L. McDonell+-- License     : BSD3 --+-- Maintainer  : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>+-- Stability   : experimental+-- Portability : non-portable (GHC extensions)+--+-- Rendering of 2D functions as raster fields+-- module Graphics.Gloss.Accelerate.Raster.Field (    module Graphics.Gloss.Accelerate.Data.Point,-  module Graphics.Gloss.Accelerate.Data.Color,+  module Data.Array.Accelerate.Data.Colour.RGBA,    -- * Display functions   Render, Display(..),-  animateField, animateFieldWith,-  animateFieldIO, animateFieldIOWith,-  playField, playFieldWith,-  playFieldIO, playFieldIOWith,+  animateFieldWith,+  animateFieldIOWith,+  playFieldWith,+  playFieldIOWith,    -- * Field creation   makeField,@@ -21,15 +30,21 @@  -- Friends import Graphics.Gloss.Accelerate.Render-import Graphics.Gloss.Accelerate.Data.Color import Graphics.Gloss.Accelerate.Data.Point import Graphics.Gloss.Accelerate.Raster.Array+import Data.Array.Accelerate.Data.Colour.RGBA  -- Standard library import Prelude                                          as P+#if MIN_VERSION_gloss(1,11,0)+import System.IO.Unsafe+#endif  -- Gloss import Graphics.Gloss.Interface.Pure.Game               ( Event )+#if MIN_VERSION_gloss(1,11,0)+import Graphics.Gloss.Interface.Environment+#endif  -- Accelerate import Data.Array.Accelerate                            as A@@ -38,20 +53,6 @@ -- Animate -------------------------------------------------------------------- -- ------- --- | Animate a continuous 2D function using the default backend----animateField-    :: Display                          -- ^ Display mode-    -> (Int, Int)                       -- ^ Number of pixels to draw per point-    -> (Exp Float -> Exp Point -> Exp Color)-            -- ^ A function to compute the colour at a particular point.-            ---            --   It is passed the time in seconds since the program started, and-            --   a point between (-1,1) and (+1,1).-    -> IO ()-animateField = animateFieldWith defaultRender-- -- | Animate a continuous 2D function, specifying the backend used to render --   the field. --@@ -59,7 +60,7 @@     :: Render           -- ^ Method to render the field     -> Display          -- ^ Display mode     -> (Int, Int)       -- ^ Number of pixels to draw per point-    -> (Exp Float -> Exp Point -> Exp Color)+    -> (Exp Float -> Exp Point -> Exp Colour)             -- ^ A function to compute the colour at a particular point.             --             --   It is passed the time in seconds since the program started, and@@ -80,23 +81,6 @@         (makeField sizeX sizeY makePixel)  --- | Animate a continuous 2D function using IO actions and the default backend----animateFieldIO-    :: Arrays world-    => Display                          -- ^ Display mode-    -> (Int, Int)                       -- ^ Number of pixels to draw per point-    -> (Float -> IO world)              -- ^ Extract world from time in seconds-                                        --   since the program started-    -> (Acc world -> Exp Point -> Exp Color)-            -- ^ A function to compute the colour at a particular point.-            ---            --   It is passed the world, and-            --   a point between (-1,1) and (+1,1).-    -> IO ()-animateFieldIO = animateFieldIOWith defaultRender-- -- | Animate a continuous 2D function using IO actions, specifying the backend used to render --   the field. --@@ -107,7 +91,7 @@     -> (Int, Int)       -- ^ Number of pixels to draw per point     -> (Float -> IO world) -- ^ Extract world from time in seconds                            --   since the program started-    -> (Acc world -> Exp Point -> Exp Color)+    -> (Acc world -> Exp Point -> Exp Colour)             -- ^ A function to compute the colour at a particular point.             --             --   It is passed the world, and@@ -129,26 +113,6 @@         (makeField sizeX sizeY makePixel)  --- | Play a game with a continuous 2D function using the default backend.----playField-    :: Arrays world-    => Display          -- ^ Display mode-    -> (Int, Int)       -- ^ Number of pixels to draw per point-    -> Int              -- ^ Number of simulation steps to take for each second of real time-    -> state            -- ^ The initial state-    -> (state -> world) -- ^ Extract the world state-    -> (Acc world -> Exp Point -> Exp Color)-            -- ^ Compute the colour of the world at a given point-    -> (Event -> state -> state)-            -- ^ Handle input events-    -> (Float -> state -> state)-            -- ^ Step the world one iteration.-            --   It is passed the time in seconds since the program started.-    -> IO ()-playField = playFieldWith defaultRender-- -- | Play a game with a continuous 2D function, specifying the method used to --   render the field. --@@ -160,7 +124,7 @@     -> Int              -- ^ Number of simulation steps to take for each second of real time     -> state            -- ^ The initial state     -> (state -> world) -- ^ Extract the world state-    -> (Acc world -> Exp Point -> Exp Color)+    -> (Acc world -> Exp Point -> Exp Colour)             -- ^ Compute the colour of the world at a given point     -> (Event -> state -> state)             -- ^ Handle input events@@ -188,26 +152,6 @@         handleEvent         stepState --- | Play a game with a continuous 2D function using IO actions, and the default backend.----playFieldIO-    :: Arrays world-    => Display          -- ^ Display mode-    -> (Int, Int)       -- ^ Number of pixels to draw per point-    -> Int              -- ^ Number of simulation steps to take for each second of real time-    -> state            -- ^ The initial state-    -> (state -> IO world) -- ^ Extract the world state-    -> (Acc world -> Exp Point -> Exp Color)-            -- ^ Compute the colour of the world at a given point-    -> (Event -> state -> IO state)-            -- ^ Handle input events-    -> (Float -> state -> IO state)-            -- ^ Step the world one iteration.-            --   It is passed the time in seconds since the program started.-    -> IO ()-playFieldIO = playFieldIOWith defaultRender-- -- | Play a game with a continuous 2D function using IO actions, specifying the method used to --   render the field. --@@ -219,7 +163,7 @@     -> Int              -- ^ Number of simulation steps to take for each second of real time     -> state            -- ^ The initial state     -> (state -> IO world) -- ^ Extract the world state-    -> (Acc world -> Exp Point -> Exp Color)+    -> (Acc world -> Exp Point -> Exp Colour)             -- ^ Compute the colour of the world at a given point     -> (Event -> state -> IO state)             -- ^ Handle input events@@ -255,7 +199,11 @@ sizeOfDisplay display   = case display of       InWindow _ s _    -> s+#if MIN_VERSION_gloss(1,11,0)+      FullScreen        -> unsafePerformIO getScreenSize+#else       FullScreen s      -> s+#endif   -- | Lift a point-wise colouring function into an image creation function.@@ -268,8 +216,8 @@ makeField     :: Int                                      -- ^ image width     -> Int                                      -- ^ image height-    -> (world -> Exp Point -> Exp Color)        -- ^ function to apply at each point-    -> (world -> Acc (Array DIM2 Color))        -- ^ new function that generates the field+    -> (world -> Exp Point -> Exp Colour)       -- ^ function to apply at each point+    -> (world -> Acc (Array DIM2 Colour))       -- ^ new function that generates the field makeField sizeX sizeY makePixel world   = A.generate (constant (Z :. sizeY :. sizeX))                (makePixel world . pointOfIndex sizeX sizeY)
Graphics/Gloss/Accelerate/Render.hs view
@@ -1,30 +1,26 @@ {-# LANGUAGE CPP        #-} {-# LANGUAGE RankNTypes #-}+-- |+-- Module      : Graphics.Gloss.Accelerate.Render+-- Copyright   : [2013..2017] Trevor L. McDonell+-- License     : BSD3+--+-- Maintainer  : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>+-- Stability   : experimental+-- Portability : non-portable (GHC extensions)+--  module Graphics.Gloss.Accelerate.Render   where  import Data.Array.Accelerate-#ifdef ACCELERATE_CUDA_BACKEND-import Data.Array.Accelerate.CUDA-#else-import Data.Array.Accelerate.Interpreter-#endif  --- | The type of executing Accelerate computations. The CUDA and Interpreter---   backends both provide a function 'run1' that can be used.+-- | The type for executing Accelerate computations. This matches the 'run1'+--   style of executing programs. -- --   Some variants of the display functions take an argument of this type, which --   determine how computations are executed. -- type Render = forall a b. (Arrays a, Arrays b) => (Acc a -> Acc b) -> a -> b----- | The set of backends available to execute Accelerate programs. The default---   chooses the fastest available, which is currently the CUDA backend. This is---   controlled via the import statements.----defaultRender :: Render-defaultRender =  run1 
gloss-raster-accelerate.cabal view
@@ -1,20 +1,16 @@ Name:                   gloss-raster-accelerate-Version:                1.9.0.0+Version:                2.0.0.0 Synopsis:               Parallel rendering of raster images using Accelerate Description:            Parallel rendering of raster images using Accelerate License:                BSD3 License-file:           LICENSE Author:                 Trevor L. McDonell-Maintainer:             tmcdonell@cse.unsw.edu.au+Maintainer:             Trevor L. McDonell <tmcdonell@cse.unsw.edu.au> Category:               Graphics Build-type:             Simple Cabal-version:          >=1.10 -Flag cuda-  Description:          Enable the CUDA parallel backend for NVIDIA GPUs-  Default:              True - Library   Exposed-modules:         Graphics.Gloss.Accelerate.Render@@ -22,15 +18,11 @@         Graphics.Gloss.Accelerate.Raster.Field    build-depends:-        base                    >= 4.6 && < 4.9,-        accelerate              >= 0.15,-        gloss                   == 1.9.*,-        gloss-accelerate        == 1.9.*--  if flag(cuda)-    cpp-options:                -DACCELERATE_CUDA_BACKEND-    Build-depends:-        accelerate-cuda         >= 0.15+        base                    >= 4.6 && < 4.10+      , accelerate              >= 0.16+      , colour-accelerate       >= 0.1+      , gloss                   >= 1.9+      , gloss-accelerate        >= 0.2    ghc-options:         -Wall -O2@@ -38,10 +30,13 @@   default-language:         Haskell2010 +source-repository head+  type:                         git+  location:                     https://github.com/tmcdonell/gloss-raster-accelerate+ source-repository this   type:                         git+  tag:                          v2.0.0.0   location:                     https://github.com/tmcdonell/gloss-raster-accelerate-  branch:                       release/1.9-  tag:                          1.9.0.0  -- vim: nospell