gloss-examples 1.8.2.1 → 1.9.1.1
raw patch · 5 files changed
+118/−51 lines, 5 filesdep +GLFW-bdep +gloss-renderingdep ~glossdep ~gloss-rasterdep ~randomnew-component:exe:gloss-render
Dependencies added: GLFW-b, gloss-rendering
Dependency ranges changed: gloss, gloss-raster, random, repa, repa-algorithms, repa-io
Files
- gloss-examples.cabal +55/−42
- picture/Boids/Main.hs +0/−1
- picture/Eden/Main.hs +4/−4
- picture/Lifespan/Main.hs +4/−4
- picture/Render/Main.hs +55/−0
gloss-examples.cabal view
@@ -1,5 +1,5 @@ Name: gloss-examples-Version: 1.8.2.1+Version: 1.9.1.1 License: MIT License-file: LICENSE Author: Ben Lippmeier@@ -26,7 +26,7 @@ base == 4.7.*, bytestring == 0.10.*, bmp == 1.2.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Bitmap ghc-options: -threaded -O2@@ -35,7 +35,7 @@ Executable gloss-boids Build-depends: base == 4.7.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs other-modules: KDTree2d Vec2 hs-source-dirs: picture/Boids@@ -45,7 +45,7 @@ Executable gloss-clock Build-depends: base == 4.7.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Clock ghc-options: -threaded -O2@@ -55,7 +55,7 @@ Build-depends: base == 4.7.*, vector == 0.10.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs other-modules: Cell World hs-source-dirs: picture/Conway@@ -64,8 +64,8 @@ Executable gloss-draw Build-depends:- base == 4.7.*,- gloss == 1.8.2.*+ base == 4.7.*,+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Draw ghc-options: -threaded -O2@@ -74,7 +74,7 @@ Executable gloss-easy Build-depends: base == 4.7.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Easy ghc-options: -threaded -O2@@ -83,8 +83,8 @@ Executable gloss-eden Build-depends: base == 4.7.*,- random == 1.0.*,- gloss == 1.8.2.*+ random == 1.1.*,+ gloss == 1.9.1.* Main-is: Main.hs other-modules: Cell Community World hs-source-dirs: picture/Eden@@ -94,7 +94,7 @@ Executable gloss-flake Build-depends: base == 4.7.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Flake ghc-options: -threaded -O2@@ -103,7 +103,7 @@ Executable gloss-gameevent Build-depends: base == 4.7.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/GameEvent ghc-options: -threaded -O2@@ -112,7 +112,7 @@ Executable gloss-hello Build-depends: base == 4.7.*, - gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Hello ghc-options: -threaded -O2@@ -121,8 +121,8 @@ Executable gloss-lifespan Build-depends: base == 4.7.*, - gloss == 1.8.2.*, - random == 1.0.*+ gloss == 1.9.1.*,+ random == 1.1.* Main-is: Main.hs other-modules: Cell Community World hs-source-dirs: picture/Lifespan@@ -132,7 +132,7 @@ Executable gloss-machina Build-depends: base == 4.7.*, - gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Machina ghc-options: -threaded -O2@@ -141,7 +141,8 @@ Executable gloss-occlusion Build-depends: base == 4.7.*, - gloss == 1.8.2.*+ gloss == 1.9.1.*,+ gloss-rendering == 1.9.1.* Main-is: Main.hs other-modules: Cell World State Data hs-source-dirs: picture/Occlusion@@ -153,7 +154,7 @@ base == 4.7.*, ghc-prim == 0.3.*, containers == 0.5.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs other-modules: Actor Advance Collide Config Contact QuadTree World hs-source-dirs: picture/Styrene@@ -163,7 +164,7 @@ Executable gloss-tree Build-depends: base == 4.7.*, - gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Tree ghc-options: -threaded -O2@@ -173,7 +174,7 @@ Build-depends: base == 4.7.*, vector == 0.10.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs other-modules: Draw Interface State World Geometry.Randomish Geometry.Segment hs-source-dirs: picture/Visibility @@ -183,7 +184,7 @@ Executable gloss-zen Build-depends: base == 4.7.*, - gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Zen ghc-options: -threaded -O2@@ -191,9 +192,9 @@ Executable gloss-crystal Build-depends:- base == 4.7.*,- gloss == 1.8.2.*,- gloss-raster == 1.8.2.*+ base == 4.7.*,+ gloss == 1.9.1.*,+ gloss-raster == 1.9.1.* Main-is: Main.hs hs-source-dirs: raster/Crystal ghc-options: @@ -210,8 +211,8 @@ Executable gloss-ray Build-depends: base == 4.7.*,- gloss == 1.8.2.*,- gloss-raster == 1.8.2.*+ gloss == 1.9.1.*,+ gloss-raster == 1.9.1.* Main-is: Main.hs other-modules: Light Object Trace Vec3 World hs-source-dirs: raster/Ray@@ -226,8 +227,8 @@ Executable gloss-pulse Build-depends: base == 4.7.*,- gloss == 1.8.2.*,- gloss-raster == 1.8.2.*+ gloss == 1.9.1.*,+ gloss-raster == 1.9.1.* Main-is: Main.hs hs-source-dirs: raster/Pulse ghc-options:@@ -243,8 +244,8 @@ base == 4.7.*, ghc-prim == 0.3.*, vector == 0.10.*,- gloss == 1.8.2.*,- gloss-raster == 1.8.2.*+ gloss == 1.9.1.*,+ gloss-raster == 1.9.1.* Main-is: Main.hs hs-source-dirs: raster/Wave ghc-options:@@ -259,10 +260,10 @@ base == 4.7.*, ghc-prim == 0.3.*, vector == 0.10.*,- repa == 3.2.*,- repa-io == 3.2.*,- repa-algorithms == 3.2.*,- gloss == 1.8.2.*+ repa == 3.3.*,+ repa-io == 3.3.*,+ repa-algorithms == 3.3.*,+ gloss == 1.9.1.* Main-is: Main.hs other-modules: Args Config FieldElt Model UserEvent@@ -281,10 +282,10 @@ Executable gloss-snow- Build-depends+ Build-depends: base == 4.7.*,- repa == 3.2.*,- gloss == 1.8.2.*+ repa == 3.3.*,+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: raster/Snow ghc-options:@@ -296,10 +297,10 @@ Executable gloss-mandel- Build-depends+ Build-depends: base == 4.7.*,- repa == 3.2.*,- gloss == 1.8.2.*+ repa == 3.3.*,+ gloss == 1.9.1.* Main-is: Main.hs other-modules: Solver hs-source-dirs: raster/Mandel@@ -314,11 +315,23 @@ Executable gloss-graph- Build-depends+ Build-depends: base == 4.7.*, containers == 0.5.*,- gloss == 1.8.2.*+ gloss == 1.9.1.* Main-is: Main.hs hs-source-dirs: picture/Graph ghc-options: -Wall -O2++Executable gloss-render+ Build-depends:+ base == 4.7.*,+ containers == 0.5.*,+ gloss == 1.9.1.*,+ GLFW-b+ Main-is: Main.hs+ hs-source-dirs: picture/Render+ ghc-options:+ -Wall -O2+
picture/Boids/Main.hs view
@@ -10,7 +10,6 @@ import System.IO.Unsafe import Debug.Trace import Graphics.Gloss-import Graphics.Gloss.Data.Picture import Graphics.Gloss.Interface.Pure.Simulate
picture/Eden/Main.hs view
@@ -1,7 +1,7 @@ -- Adapted from ANUPlot version by Clem Baker-Finch module Main where-import World+import qualified World as W import Graphics.Gloss import Graphics.Gloss.Interface.Pure.Simulate import System.Random@@ -12,8 +12,8 @@ simulate (InWindow "Eden" (800, 600) (10, 10)) (greyN 0.1) -- background color 2 -- number of steps per second- (genesis' gen) -- initial world- render -- function to convert world to a Picture- evolve -- function to step the world one iteration+ (W.genesis' gen) -- initial world+ W.render -- function to convert world to a Picture+ W.evolve -- function to step the world one iteration
picture/Lifespan/Main.hs view
@@ -1,7 +1,7 @@ -- Adapted from ANUPlot version by Clem Baker-Finch module Main where-import World+import qualified World as W import Graphics.Gloss import Graphics.Gloss.Interface.Pure.Simulate import System.Random@@ -12,9 +12,9 @@ simulate (InWindow "Lifespan" (800, 600) (10, 10)) (greyN 0.1) -- background color 2 -- number of steps per second- (genesis' gen) -- initial world- render -- function to convert world to a Picture- evolve -- function to step the world one iteration+ (W.genesis' gen) -- initial world+ W.render -- function to convert world to a Picture+ W.evolve -- function to step the world one iteration
+ picture/Render/Main.hs view
@@ -0,0 +1,55 @@+{-# LANGUAGE PackageImports #-}+import "GLFW-b" Graphics.UI.GLFW as GLFW+import Control.Concurrent (threadDelay)+import Control.Monad (when, unless)+import Graphics.Gloss.Render+import Graphics.Gloss+++main :: IO ()+main = do+ let width = 200+ height = 200++ state <- stateInit++ withWindow width height "Render" $ \win -> do+ loop state win (width, height)+++ where loop state window (w, h) = do+ threadDelay 20000+ pollEvents+ render state (w, h) white (Circle 80)+ swapBuffers window+ k <- keyIsPressed window Key'Escape+ unless k $ loop state window (w, h)+++withWindow :: Int -> Int -> String -> (GLFW.Window -> IO ()) -> IO ()+withWindow width height title f = do+ GLFW.setErrorCallback $ Just simpleErrorCallback+ r <- GLFW.init+ when r $ do+ m <- GLFW.createWindow width height title Nothing Nothing+ case m of+ (Just win) -> do+ GLFW.makeContextCurrent m+ f win+ GLFW.setErrorCallback $ Just simpleErrorCallback+ GLFW.destroyWindow win+ Nothing -> return ()+ GLFW.terminate+ where+ simpleErrorCallback e s =+ putStrLn $ unwords [show e, show s]+++keyIsPressed :: Window -> Key -> IO Bool+keyIsPressed win key = isPress `fmap` GLFW.getKey win key+++isPress :: KeyState -> Bool+isPress KeyState'Pressed = True+isPress KeyState'Repeating = True+isPress _ = False