luminance 0.1.1.1 → 0.2
raw patch · 8 files changed
+61/−8 lines, 8 files
Files
- CHANGELOG.md +14/−2
- luminance.cabal +1/−1
- src/Graphics/Luminance.hs +4/−4
- src/Graphics/Luminance/Batch.hs +1/−0
- src/Graphics/Luminance/Core/Batch.hs +4/−0
- src/Graphics/Luminance/Core/RenderCmd.hs +29/−0
- src/Graphics/Luminance/Core/Shader/Stage.hs +7/−1
- src/Graphics/Luminance/RenderCmd.hs +1/−0
CHANGELOG.md view
@@ -1,12 +1,24 @@+# 0.2++#### Breaking changes++- Automatically insert GLSL pragmas in shaders.++#### Non-breaking changes++- Added documentation for RenderCmd.+- Added stdRenderCmd_.+- Added shaderProgramBatch_.+ ### 0.1.1.1 - Fixed a typo in the Graphics.Luminance documentation. -### 0.1.1+## 0.1.1 - Added a tutoral in Graphics.Luminance. -### 0.1+# 0.1 - Initial revision. Do not consider this revision as a stable release. It’s experimental. The first stable release will be **1.0**.
luminance.cabal view
@@ -1,5 +1,5 @@ name: luminance-version: 0.1.1.1+version: 0.2 synopsis: Type-safe, dependently-typed and stateless graphics framework description: This package exposes several modules to work with /GPUs/ in a stateless and type-safe way. Currently, it uses __OpenGL__ as backend hardware technology but
src/Graphics/Luminance.hs view
@@ -164,10 +164,10 @@ -- Here’s an exemple of such a use: -- -- @--- (program,uniformInterface) <- createProgram shaderStages $ \uni -> do--- resolutionU <- uni $ Left "resolution"--- timeU <- uni $ Left "time"--- pure $ divided resolutionU timeU+-- (program,uniformInterface) <- 'createProgram' shaderStages $ \uni -> do+-- resolutionU <- uni $ 'Left' "resolution"+-- timeU <- uni $ 'Left' "time"+-- 'pure' $ 'divided' resolutionU timeU -- @ -- -- In that example, @uniformInterface@ has type @U ((Float,Float),Float)@, @(Float,Float@ being the
src/Graphics/Luminance/Batch.hs view
@@ -17,6 +17,7 @@ , AnySPBatch , anySPBatch , shaderProgramBatch+ , shaderProgramBatch_ ) where import Graphics.Luminance.Core.Batch
src/Graphics/Luminance/Core/Batch.hs view
@@ -85,6 +85,10 @@ shaderProgramBatch :: Program -> U u -> u -> [RenderCmd rw c d v Geometry] -> SPBatch rw c d u v shaderProgramBatch = SPBatch +-- |Create a new 'SPBatch' with no uniform interface.+shaderProgramBatch_ :: Program -> [RenderCmd rw c d v Geometry] -> SPBatch rw c d () v+shaderProgramBatch_ p = SPBatch p mempty ()+ -------------------------------------------------------------------------------- -- Geometry draw function ------------------------------------------------------
src/Graphics/Luminance/Core/RenderCmd.hs view
@@ -14,11 +14,29 @@ import Graphics.Luminance.Core.Shader.Uniform ( U(..) ) -- FIXME: we need to make a tighter link between c and blending and between d and the depth test.+-- FIXME: is the 'rw' type parameter still useful?++-- |A /GPU/ render command. That type exists to implement a stateless way to issue draw commands+-- to the /GPU/. You can set several hints for a given draw command:+--+-- - /blending/: the blending mode is represented by+-- @'Maybe' ('BlendingMode','BlendingFactor','BlendingFactor')@. If you pass+-- 'Nothing', /blending/ is disabled for that draw command. If you want to enable it, you have+-- to pass @'Just' (mode,srcK,dstK)@, where @mode@ is the 'BlendingMode' and @srcK@ and @dstK@+-- are both 'BlendingFactor' representing the source and destination factors.+-- - /depth test/: the depth test can be enabled by passing 'True' and disabled with 'False'.+-- - a /per draw command uniform interface and uniform value/: that is the way you can customize+-- the draw calls. You just have to pass the uniform interface and the value to send down to the+-- shader.+--+-- Finally, a 'RenderCmd' holds a value. That value will be consumed later by other functions. In+-- general, it’ll be 'Geometry'. data RenderCmd rw c d u a = RenderCmd (Maybe (BlendingMode,BlendingFactor,BlendingFactor)) Bool (U u) u a instance Functor (RenderCmd rw c d u) where fmap f (RenderCmd blending depthTest uni u a) = RenderCmd blending depthTest uni u (f a) +-- |@'renderCmd' blending depthTest uniformInterface u a@ constructs a new 'RenderCmd'. renderCmd :: Maybe (BlendingMode,BlendingFactor,BlendingFactor) -> Bool -> U u@@ -27,5 +45,16 @@ -> RenderCmd rw c d u a renderCmd = RenderCmd +-- |A standard 'RenderCmd' builder.+--+-- - no /blending/+-- - /depth test/ enabled stdRenderCmd :: U u -> u -> a -> RenderCmd rw c d u a stdRenderCmd = RenderCmd Nothing True++-- |A standard 'RenderCmd' builder with no uniform interface.+--+-- - no /blending/+-- - /depth test/ enabled+stdRenderCmd_ :: a -> RenderCmd rw c d () a+stdRenderCmd_ = stdRenderCmd mempty ()
src/Graphics/Luminance/Core/Shader/Stage.hs view
@@ -60,7 +60,7 @@ mkShader target src = do (sid,compiled,cl) <- liftIO $ do sid <- glCreateShader target- withCString src $ \cstr -> do+ withCString (prependGLSLPragma src) $ \cstr -> do with cstr $ \pcstr -> glShaderSource sid 1 pcstr nullPtr glCompileShader sid compiled <- isCompiled sid@@ -91,6 +91,12 @@ allocaArray l $ liftA2 (*>) (glGetShaderInfoLog sid (fromIntegral l) nullPtr) (peekCString . castPtr)++prependGLSLPragma :: String -> String+prependGLSLPragma src =+ "#version 450 core\n"+ ++ "#extension GL_ARB_bindless_texture : require\n"+ ++ src -------------------------------------------------------------------------------- -- Shader stage errors ---------------------------------------------------------
src/Graphics/Luminance/RenderCmd.hs view
@@ -14,6 +14,7 @@ , renderCmd -- * Special render commands , stdRenderCmd+ , stdRenderCmd_ ) where import Graphics.Luminance.Core.RenderCmd