packages feed

not-gloss 0.7.5.0 → 0.7.6.0

raw patch · 3 files changed

+39/−5 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Vis: Aliased :: Antialiasing
+ Vis: Multisampled :: Int -> Antialiasing
+ Vis: Smoothed :: Antialiasing
+ Vis: data Antialiasing
+ Vis: optAntialiasing :: Options -> Antialiasing
+ Vis.Vis: Aliased :: Antialiasing
+ Vis.Vis: Multisampled :: Int -> Antialiasing
+ Vis.Vis: Smoothed :: Antialiasing
+ Vis.Vis: data Antialiasing
+ Vis.Vis: instance Eq Antialiasing
+ Vis.Vis: instance Ord Antialiasing
+ Vis.Vis: instance Show Antialiasing
+ Vis.Vis: optAntialiasing :: Options -> Antialiasing
- Vis: Options :: Maybe Color -> Maybe (Int, Int) -> Maybe (Int, Int) -> String -> Maybe Camera0 -> Options
+ Vis: Options :: Maybe Color -> Maybe (Int, Int) -> Maybe (Int, Int) -> String -> Maybe Camera0 -> Antialiasing -> Options
- Vis.Vis: Options :: Maybe Color -> Maybe (Int, Int) -> Maybe (Int, Int) -> String -> Maybe Camera0 -> Options
+ Vis.Vis: Options :: Maybe Color -> Maybe (Int, Int) -> Maybe (Int, Int) -> String -> Maybe Camera0 -> Antialiasing -> Options

Files

not-gloss.cabal view
@@ -1,5 +1,5 @@ name:                not-gloss-version:             0.7.5.0+version:             0.7.6.0 stability:           Experimental synopsis:            Painless 3D graphics, no affiliation with gloss description:{
src/Vis.hs view
@@ -1,6 +1,7 @@ {-# OPTIONS_GHC -Wall #-}  module Vis ( Options(..)+           , Antialiasing(..)            , Camera0(..)            , defaultOpts            , display@@ -22,7 +23,7 @@  import Graphics.UI.GLUT ( SpecialKey(..), BitmapFont(..), Flavour(..) ) -import Vis.Vis ( Options(..), visMovie )+import Vis.Vis ( Options(..), Antialiasing(..), visMovie ) import Vis.Camera ( Camera0(..) ) import Vis.Interface ( display, animate, simulate, play, animateIO, simulateIO, playIO ) import Vis.VisObject ( VisObject(..), LoadedObjModel, loadObjModel )@@ -40,4 +41,5 @@   , optWindowPosition = Nothing   , optWindowName = "not-gloss"   , optInitialCamera = Nothing+  , optAntialiasing = Aliased   }
src/Vis/Vis.hs view
@@ -2,6 +2,7 @@ {-# Language ScopedTypeVariables #-}  module Vis.Vis ( Options(..)+               , Antialiasing(..)                , vis                , visMovie                , FullState@@ -39,6 +40,12 @@ -- | user state and internal states type FullState a = (a, Float) +data Antialiasing =+  Aliased+  | Smoothed+  | Multisampled Int+  deriving (Eq, Show, Ord)+ data Options =   Options   { optBackgroundColor :: Maybe GC.Color -- ^ optional background color@@ -46,11 +53,18 @@   , optWindowPosition :: Maybe (Int,Int) -- ^ optional (x,y) window origin in pixels   , optWindowName :: String -- ^ window name   , optInitialCamera :: Maybe Camera0 -- ^ initial camera position+  , optAntialiasing :: Antialiasing -- ^ which antialiasing strategy to use   } deriving Show  myGlInit :: Options -> IO () myGlInit opts = do-  GLUT.initialDisplayMode $= [ DoubleBuffered, RGBAMode, WithDepthBuffer ]+  let displayMode = [ DoubleBuffered, RGBAMode, WithDepthBuffer ] +++        case optAntialiasing opts of+          Multisampled numSamples -> [ GLUT.Multisampling+                                     , GLUT.WithSamplesPerPixel numSamples+                                     ]+          _ -> []+  GLUT.initialDisplayMode $= displayMode    Size x y <- GLUT.get GLUT.screenSize   let intScale d i = round $ d*(realToFrac i :: Double)@@ -82,6 +96,22 @@   GLUT.materialShininess Front $= 100   GLUT.colorMaterial $= Just (Front, Diffuse) +  case optAntialiasing opts of+    Aliased -> do+      GLUT.lineSmooth $= Disabled+      GLUT.pointSmooth $= Disabled+      GLUT.multisample $= Disabled+    Smoothed -> do+      GLUT.hint GLUT.LineSmooth $= GLUT.Nicest+      GLUT.hint GLUT.PolygonSmooth $= GLUT.Nicest+      GLUT.lineSmooth $= Enabled+      GLUT.pointSmooth $= Enabled+      GLUT.multisample $= Disabled+    Multisampled _ -> do+      GLUT.lineSmooth $= Disabled+      GLUT.pointSmooth $= Disabled+      GLUT.multisample $= Enabled+   glEnable gl_BLEND   glBlendFunc gl_SRC_ALPHA gl_ONE_MINUS_SRC_ALPHA @@ -340,7 +370,9 @@             bmp = packRGBA32ToBMP32 (fromIntegral width) (fromIntegral height) bs          let filename = toFilename imageNumber-        printf "writing \"%s\" (%d / %d) ...\n" filename imageNumber n+            percent :: Double+            percent = 100 * fromIntegral imageNumber / fromIntegral n+        printf "writing \"%s\" (%d / %d == %6.2f %%) ...\n" filename imageNumber n percent         writeBMP filename bmp        drawFun = do@@ -352,7 +384,7 @@                   mapM_ (screenShot n cam) (zip objectsToDraw [0..])                   putStrLn "finished writing files"                   putStrLn "you might want to try some command like:"-                  putStrLn "\"ffmpeg -framerate 20 -i data/movie.%03d.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4\""+                  putStrLn "\"ffmpeg -framerate 50 -i data/movie.%03d.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4\""                   putMVar stateMVar state'                    writeIORef areWeDrawingRef False