GPipe 1.0.1 → 1.0.2
raw patch · 6 files changed
+33/−31 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Graphics.GPipe.Stream.Fragment: rasterize :: (VertexOutput a) => PrimitiveStream p (VertexPosition, a) -> FragmentStream (FragmentInput a)
- Graphics.GPipe.Stream.Fragment: rasterizeFront :: (VertexOutput a) => PrimitiveStream Triangle (VertexPosition, a) -> FragmentStream (FragmentInput a)
+ Graphics.GPipe.Stream.Fragment: rasterizeFront :: (VertexOutput a) => PrimitiveStream p (VertexPosition, a) -> FragmentStream (FragmentInput a)
Files
- GPipe.cabal +1/−1
- src/Formats.hs +3/−2
- src/Graphics/GPipe/Stream/Fragment.hs +1/−2
- src/OutputMerger.hs +19/−7
- src/Rasterizer.hs +7/−17
- src/Shader.hs +2/−2
GPipe.cabal view
@@ -1,5 +1,5 @@ name: GPipe-version: 1.0.1+version: 1.0.2 cabal-version: >= 1.2.3 build-type: Simple license: BSD3
src/Formats.hs view
@@ -35,7 +35,9 @@ ) where import qualified Graphics.Rendering.OpenGL as GL -import Data.Vec ((:.)(..), Vec3, Vec4) +import Data.Vec ((:.)(..), Vec3, Vec4, zipWith) +import Prelude hiding (zipWith) +import Data.Boolean -- | A GPU format with only an alpha value. -- These are the associated types in 'GPUFormat' and 'ColorFormat':@@ -271,4 +273,3 @@ data Color RGBAFormat a = RGBA (Vec3 a) a deriving (Eq,Ord,Show) fromColor _ _ (RGBA (a:.b:.c:.()) d) = a:.b:.c:.d:.() toColor (a:.b:.c:.d:.()) = RGBA (a:.b:.c:.()) d -
src/Graphics/GPipe/Stream/Fragment.hs view
@@ -51,10 +51,9 @@ -- | When using the @rasterize@ functions, give the vertices positions in canonical view space, i.e. where @x@, @y@ and @z@ -- is in the interval @[-1, 1]@. These aren't interpolated back to the fragments by default, so you -- must duplicate these positions into the vertices interpolated values if you need them in the fragments (which is very unusual). - rasterize, + rasterizeFront, rasterizeBack, rasterizeFrontAndBack, - rasterizeFront, ) where import Shader
src/OutputMerger.hs view
@@ -118,16 +118,23 @@ d' <- ioEvaluate d return (a':.b':.c':.d':.()) +setDefaultStates :: IO () +setDefaultStates = do frontFace $= CCW + depthRange $= (0,1) + + newFrameBufferColor c = FrameBuffer $ do c' <- ioEvaluateColor 0 1 c setContextWindow - liftIO $ do setNewColor c' + liftIO $ do setDefaultStates + setNewColor c' clear [GL.ColorBuffer] newFrameBufferColorDepth c d = FrameBuffer $ do c' <- ioEvaluateColor 0 1 c d' <- ioEvaluate d setContextWindow - liftIO $ do setNewColor c' + liftIO $ do setDefaultStates + setNewColor c' setNewDepth d' clear [GL.ColorBuffer, GL.DepthBuffer] newFrameBufferColorDepthStencil c d s = FrameBuffer $ do @@ -135,7 +142,8 @@ d' <- ioEvaluate d s' <- ioEvaluate s setContextWindow - liftIO $ do setNewColor c' + liftIO $ do setDefaultStates + setNewColor c' setNewDepth d' setNewStencil s' clear [GL.ColorBuffer, GL.DepthBuffer, GL.StencilBuffer] @@ -144,26 +152,30 @@ c' <- ioEvaluateColor 0 1 c s' <- ioEvaluate s setContextWindow - liftIO $ do setNewColor c' + liftIO $ do setDefaultStates + setNewColor c' setNewStencil s' clear [GL.ColorBuffer, GL.StencilBuffer] newFrameBufferDepth d = FrameBuffer $ do d' <- ioEvaluate d setContextWindow - liftIO $ do setNewDepth d' + liftIO $ do setDefaultStates + setNewDepth d' clear [GL.DepthBuffer] newFrameBufferDepthStencil d s = FrameBuffer $ do d' <- ioEvaluate d s' <- ioEvaluate s setContextWindow - liftIO $ do setNewDepth d' + liftIO $ do setDefaultStates + setNewDepth d' setNewStencil s' clear [GL.DepthBuffer, GL.StencilBuffer] newFrameBufferStencil s = FrameBuffer $ do s' <- ioEvaluate s setContextWindow - liftIO $ do setNewStencil s' + liftIO $ do setDefaultStates + setNewStencil s' clear [GL.StencilBuffer]
src/Rasterizer.hs view
@@ -15,10 +15,9 @@ module Rasterizer ( Rasterizer(), VertexOutput(..), - rasterize, rasterizeFront, - rasterizeFrontAndBack, rasterizeBack, + rasterizeFrontAndBack, ) where import Shader @@ -76,13 +75,13 @@ b' <- toFragment b return $ a':.b' --- | Rasterize all types of primitives (and both sides of triangles) with vertices containing canonical view coordinates into fragments. -rasterize :: VertexOutput a+-- | Rasterize front side of all types of primitives with vertices containing canonical view coordinates into fragments. +rasterizeFront :: VertexOutput a => PrimitiveStream p (VertexPosition, a) -- ^ The primitive stream with vertices containing canonical view coordinates and data to be interpolated. -> FragmentStream (FragmentInput a) -- ^ The resulting fragment stream with fragments containing the interpolated values. -rasterize (PrimitiveStream []) = FragmentStream [] -rasterize (PrimitiveStream xs) = FragmentStream $ map rasterizeOne xs - where rasterizeOne (pdesc, (pos, va)) = ((pdesc, CullNone, fs, getPositionCode pos), true, fa) +rasterizeFront (PrimitiveStream []) = FragmentStream [] +rasterizeFront (PrimitiveStream xs) = FragmentStream $ map rasterizeOne xs + where rasterizeOne (pdesc, (pos, va)) = ((pdesc, CullBack, fs, getPositionCode pos), true, fa) where (fa, fs) = getFragmentInput va -- | Rasterize both sides of triangles with vertices containing canonical view coordinates into fragments, also returning the primitives side in the fragments. @@ -94,16 +93,7 @@ where rasterizeOne (pdesc, (pos, va)) = ((pdesc, CullNone, fs, getPositionCode pos), true, (Fragment $ return "gl_FrontFacing", fa)) where (fa, fs) = getFragmentInput va --- | Rasterize only front side of triangles with vertices containing canonical view coordinates into fragments. -rasterizeFront :: VertexOutput a- => PrimitiveStream Triangle (VertexPosition, a) -- ^ The primitive stream with vertices containing canonical view coordinates and data to be interpolated.- -> FragmentStream (FragmentInput a) -- ^ The resulting fragment stream with fragments containing the interpolated values. -rasterizeFront (PrimitiveStream []) = FragmentStream [] -rasterizeFront (PrimitiveStream xs) = FragmentStream $ map rasterizeOne xs - where rasterizeOne (pdesc, (pos, va)) = ((pdesc, CullBack, fs, getPositionCode pos), true, fa) - where (fa, fs) = getFragmentInput va - --- | Rasterize only back side of triangles with vertices containing canonical view coordinates into fragments. +-- | Rasterize back side of triangles with vertices containing canonical view coordinates into fragments. rasterizeBack :: VertexOutput a => PrimitiveStream Triangle (VertexPosition, a) -- ^ The primitive stream with vertices containing canonical view coordinates and data to be interpolated. -> FragmentStream (FragmentInput a) -- ^ The resulting fragment stream with fragments containing the interpolated values.
src/Shader.hs view
@@ -367,14 +367,14 @@ instance Boolean (Vertex Bool) where true = Vertex $ return "true" false = Vertex $ return "false" - notB = vUnaryFunc "not" + notB = vUnaryPreOp "!" (&&*) = vBinaryOp "&&" (||*) = vBinaryOp "||" instance Boolean (Fragment Bool) where true = Fragment $ return "true" false = Fragment $ return "false" - notB = fUnaryFunc "not" + notB = fUnaryPreOp "!" (&&*) = fBinaryOp "&&" (||*) = fBinaryOp "||"