diff --git a/.gitignore b/.gitignore index bb66e00..0f5635d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ cabal.sandbox.config dist/ *.swp +out.png diff --git a/raytrace.cabal b/raytrace.cabal index b341257..37dda67 100644 --- a/raytrace.cabal +++ b/raytrace.cabal @@ -62,7 +62,8 @@ executable raytrace build-depends: base >=4.7 && <4.8, attoparsec >= 0.12, bytestring >= 0.10, - linear >= 1.10 + linear >= 1.10, + JuicyPixels >= 3.1 -- Directories containing source files. -- hs-source-dirs: diff --git a/src/Main.hs b/src/Main.hs index c6770d3..82e63be 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -2,6 +2,8 @@ module Main where import Control.Applicative +import Codec.Picture.Png +import Codec.Picture.Types import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as B8 @@ -65,8 +67,9 @@ validateScene obs = do , sceneObjects = objects } -render :: Scene -> IO () -render s = putStrLn "rendering currently not implemented" +render :: Scene -> Image PixelRGB8 +render s = generateImage pixelRenderer 250 300 + where pixelRenderer x y = PixelRGB8 128 128 128 main :: IO () main = do @@ -80,4 +83,5 @@ main = do Left error -> putStrLn $ "Error: " ++ error Right s -> do print s - render s + im <- return $ render s + writePng "out.png" im