luminance-samples 0.9.1 → 0.10
raw patch · 9 files changed
+101/−107 lines, 9 filesdep ~luminance
Dependency ranges changed: luminance
Files
- CHANGELOG.md +5/−0
- luminance-samples.cabal +30/−30
- src/Blending.hs +24/−29
- src/Blit.hs +4/−15
- src/DepthTest.hs +23/−20
- src/HelloWorld.hs +2/−2
- src/HelloWorldUniform.hs +4/−4
- src/Texture.hs +4/−3
- src/UBO.hs +5/−4
CHANGELOG.md view
@@ -1,3 +1,8 @@+## 0.10++- Updated luminance dependency to include the latest version and break compatibility with older+ versions.+ ## 0.9.1 - Support for `contravariant-1.4`
luminance-samples.cabal view
@@ -1,5 +1,5 @@ name: luminance-samples-version: 0.9.1+version: 0.10 synopsis: Luminance samples description: Luminance samples used as tutorial help homepage: https://github.com/phaazon/luminance-samples@@ -30,12 +30,12 @@ default-extensions: DataKinds , FlexibleContexts - build-depends: base >= 4.8 && < 4.9- , luminance >= 0.9 && < 0.10- , GLFW-b >= 1.4 && < 1.5- , mtl >= 2.2 && < 2.3- , resourcet >= 1.1 && < 1.2- , transformers >= 0.4 && < 0.5+ build-depends: base >= 4.8 && < 4.9+ , luminance >= 0.10 && < 0.11+ , GLFW-b >= 1.4 && < 1.5+ , mtl >= 2.2 && < 2.3+ , resourcet >= 1.1 && < 1.2+ , transformers >= 0.4 && < 0.5 hs-source-dirs: src @@ -52,12 +52,12 @@ , FlexibleContexts , ScopedTypeVariables - build-depends: base >= 4.8 && < 4.9- , luminance >= 0.9 && < 0.10- , GLFW-b >= 1.4 && < 1.5- , mtl >= 2.2 && < 2.3- , resourcet >= 1.1 && < 1.2- , transformers >= 0.4 && < 0.5+ build-depends: base >= 4.8 && < 4.9+ , luminance >= 0.10 && < 0.11+ , GLFW-b >= 1.4 && < 1.5+ , mtl >= 2.2 && < 2.3+ , resourcet >= 1.1 && < 1.2+ , transformers >= 0.4 && < 0.5 hs-source-dirs: src @@ -74,13 +74,13 @@ , FlexibleContexts , ScopedTypeVariables - build-depends: base >= 4.8 && < 4.9- , contravariant >= 1.3 && < 1.5- , luminance >= 0.9 && < 0.10- , GLFW-b >= 1.4 && < 1.5- , mtl >= 2.2 && < 2.3- , resourcet >= 1.1 && < 1.2- , transformers >= 0.4 && < 0.5+ build-depends: base >= 4.8 && < 4.9+ , contravariant >= 1.3 && < 1.5+ , luminance >= 0.10 && < 0.11+ , GLFW-b >= 1.4 && < 1.5+ , mtl >= 2.2 && < 2.3+ , resourcet >= 1.1 && < 1.2+ , transformers >= 0.4 && < 0.5 hs-source-dirs: src @@ -97,13 +97,13 @@ , FlexibleContexts , ScopedTypeVariables - build-depends: base >= 4.8 && < 4.9- , contravariant >= 1.3 && < 1.5- , luminance >= 0.9 && < 0.10- , GLFW-b >= 1.4 && < 1.5- , mtl >= 2.2 && < 2.3- , resourcet >= 1.1 && < 1.2- , transformers >= 0.4 && < 0.5+ build-depends: base >= 4.8 && < 4.9+ , contravariant >= 1.3 && < 1.5+ , luminance >= 0.10 && < 0.11+ , GLFW-b >= 1.4 && < 1.5+ , mtl >= 2.2 && < 2.3+ , resourcet >= 1.1 && < 1.2+ , transformers >= 0.4 && < 0.5 hs-source-dirs: src @@ -123,7 +123,7 @@ build-depends: base >= 4.8 && < 4.9 , contravariant >= 1.3 && < 1.5 , JuicyPixels >= 3.2 && < 3.4- , luminance >= 0.9 && < 0.10+ , luminance >= 0.10 && < 0.11 , GLFW-b >= 1.4 && < 1.5 , mtl >= 2.2 && < 2.3 , resourcet >= 1.1 && < 1.2@@ -146,7 +146,7 @@ build-depends: base >= 4.8 && < 4.9 , contravariant >= 1.3 && < 1.5- , luminance >= 0.9 && < 0.10+ , luminance >= 0.10 && < 0.11 , GLFW-b >= 1.4 && < 1.5 , mtl >= 2.2 && < 2.3 , resourcet >= 1.1 && < 1.2@@ -171,7 +171,7 @@ build-depends: base >= 4.8 && < 4.9 , contravariant >= 1.3 && < 1.5 , linear >= 1.20 && < 1.21- , luminance >= 0.9 && < 0.10+ , luminance >= 0.10 && < 0.11 , GLFW-b >= 1.4 && < 1.5 , mtl >= 2.2 && < 2.3 , resourcet >= 1.1 && < 1.2
src/Blending.hs view
@@ -1,45 +1,40 @@ import Common-import Control.Monad-import Data.Functor.Contravariant.Divisible-import Graphics.Luminance.Batch-import Graphics.Luminance.Cmd-import Graphics.Luminance.Blending-import Graphics.Luminance.Framebuffer-import Graphics.Luminance.Geometry-import Graphics.Luminance.RenderCmd-import Graphics.Luminance.Shader.Program-import Graphics.Luminance.Shader.Stage-import Graphics.Luminance.Vertex+import Data.Foldable ( for_ )+import Graphics.Luminance main :: IO () main = startup $ \window loop -> do triangle <- createGeometry vertices Nothing Triangle vs <- createStage VertexShader vsSource fs <- createStage FragmentShader fsSource- (program,colorOffsetU) <- createProgram [vs,fs] $ \uni -> do+ program <- createProgram [vs,fs] $ \uni -> do colorU <- uni (UniformName "color") offsetU <- uni (UniformName "offset")- pure $ divided colorU offsetU+ pure (colorU,offsetU) loop $ do- void . runCmd . draw $ framebufferBatch defaultFramebuffer- [anySPBatch . shaderProgramBatch_ program $- [- renderCmd blending False colorOffsetU (color0,offset0) triangle - , renderCmd blending False colorOffsetU (color1,offset1) triangle - , renderCmd blending False colorOffsetU (color2,offset2) triangle - ]- ]+ gpuRegion . newFrame defaultFramebuffer . newShading (Some program) $ do+ for_ (zip colors offsets) $ \(color,offset) -> do+ updateUniforms program $ \(colorU,offsetU) ->+ colorU .= color+ <> offsetU .= offset+ drawGeometry (renderCmd blending False triangle ) endFrame window -color0,color1,color2 :: (Float,Float,Float)-color0 = (1,0,0)-color1 = (0,1,0)-color2 = (0,0,1)+colors :: [(Float,Float,Float)]+colors =+ [+ (1,0,0)+ , (0,1,0)+ , (0,0,1)+ ] -offset0,offset1,offset2 :: (Float,Float)-offset0 = (-0.25,0)-offset1 = (0.25,0)-offset2 = (0,0.25)+offsets :: [(Float,Float)]+offsets = + [+ (-0.25,0)+ , (0.25,0)+ , (0,0.25)+ ] vertices :: [V 2 Float] vertices =
src/Blit.hs view
@@ -1,15 +1,5 @@ import Common-import Graphics.Luminance.Batch-import Graphics.Luminance.Cmd-import Graphics.Luminance.Framebuffer-import Graphics.Luminance.Geometry-import Graphics.Luminance.RenderCmd-import Graphics.Luminance.Pixel as L-import Graphics.Luminance.RW-import Graphics.Luminance.Shader.Program-import Graphics.Luminance.Shader.Stage-import Graphics.Luminance.Texture-import Graphics.Luminance.Vertex+import Graphics.Luminance main :: IO () main = startup $ \window loop -> do@@ -19,10 +9,9 @@ program <- createProgram_ [vs,fs] fb :: Framebuffer RW RGBA32F () <- createFramebuffer windowW windowH 1 loop $ do- _ <- runCmd $ do- _ <- draw $ framebufferBatch fb - [anySPBatch $ shaderProgramBatch_ program [stdRenderCmd_ triangle]]- blit fb defaultFramebuffer 0 0 windowW windowH 0 0 windowW windowH BlitColor Linear+ gpuRegion . newFrame fb . newShading (Some program) $ do+ drawGeometry (stdRenderCmd triangle)+ framebufferBlit fb defaultFramebuffer 0 0 windowW windowH 0 0 windowW windowH BlitColor Linear endFrame window vertices :: [V 2 Float]
src/DepthTest.hs view
@@ -1,6 +1,5 @@ import Common-import Control.Monad-import Data.Functor.Contravariant.Divisible+import Data.Foldable ( for_ ) import Graphics.Luminance main :: IO ()@@ -8,30 +7,34 @@ triangle <- createGeometry vertices Nothing Triangle vs <- createStage VertexShader vsSource fs <- createStage FragmentShader fsSource- (program,colorOffsetU) <- createProgram [vs,fs] $ \uni -> do+ program <- createProgram [vs,fs] $ \uni -> do colorU <- uni (UniformName "color") offsetU <- uni (UniformName "offset")- pure $ divided colorU offsetU+ pure (colorU,offsetU) loop $ do- void . runCmd . draw $ framebufferBatch defaultFramebuffer- [anySPBatch . shaderProgramBatch_ program $- [- renderCmd Nothing True colorOffsetU (color0,offset0) triangle - , renderCmd Nothing True colorOffsetU (color1,offset1) triangle - , renderCmd Nothing True colorOffsetU (color2,offset2) triangle - ]- ]+ gpuRegion . newFrame defaultFramebuffer . newShading (Some program) $ do+ for_ (zip colors offsets) $ \(color,offset) -> do+ updateUniforms program $ \(colorU,offsetU) ->+ colorU .= color+ <> offsetU .= offset+ drawGeometry (renderCmd Nothing True triangle ) endFrame window -color0,color1,color2 :: (Float,Float,Float)-color0 = (1,0,0)-color1 = (0,1,0)-color2 = (0,0,1)+colors :: [(Float,Float,Float)]+colors =+ [+ (1,0,0)+ , (0,1,0)+ , (0,0,1)+ ] -offset0,offset1,offset2 :: (Float,Float)-offset0 = (-0.25,0)-offset1 = (0.25,0)-offset2 = (0,0.25)+offsets :: [(Float,Float)]+offsets =+ [+ (-0.25,0)+ , (0.25,0)+ , (0,0.25)+ ] vertices :: [V 2 Float] vertices =
src/HelloWorld.hs view
@@ -1,5 +1,4 @@ import Common-import Control.Monad import Graphics.Luminance main :: IO ()@@ -7,7 +6,8 @@ triangle <- createGeometry vertices Nothing Triangle program <- sequenceA [createStage VertexShader vsSource,createStage FragmentShader fsSource] >>= createProgram_ loop $ do- void . runCmd . draw $ framebufferBatch defaultFramebuffer [anySPBatch $ shaderProgramBatch_ program [stdRenderCmd_ triangle]]+ gpuRegion . newFrame defaultFramebuffer . newShading (Some program) $+ drawGeometry (stdRenderCmd triangle) endFrame window vertices :: [V 2 Float]
src/HelloWorldUniform.hs view
@@ -1,5 +1,4 @@ import Common-import Control.Monad import Graphics.Luminance main :: IO ()@@ -7,10 +6,12 @@ triangle <- createGeometry vertices Nothing Triangle vs <- createStage VertexShader vsSource fs <- createStage FragmentShader fsSource- (program,colorsU :: U [(Float,Float,Float)]) <- createProgram [vs,fs] $ \uni ->+ program <- createProgram [vs,fs] $ \uni -> uni (UniformName "colors") loop $ do- void . runCmd . draw $ framebufferBatch defaultFramebuffer [anySPBatch $ shaderProgramBatch program colorsU colors [stdRenderCmd_ triangle]]+ gpuRegion . newFrame defaultFramebuffer . newShading (Some program) $ do+ updateUniforms program $ (.= colors)+ drawGeometry (stdRenderCmd triangle) endFrame window colors :: [(Float,Float,Float)]@@ -49,7 +50,6 @@ [ "in vec4 vertexColor;" , "out vec4 frag;"- , "void main() {" , " frag = vertexColor;"
src/Texture.hs view
@@ -16,10 +16,11 @@ quad <- createGeometry vertices Nothing Triangle vs <- createStage VertexShader vsSource fs <- createStage FragmentShader fsSource- (program,texU) <- createProgram [vs,fs] $ \uni -> uni (UniformName "srcTex")+ program <- createProgram [vs,fs] $ \uni -> uni (UniformName "srcTex")+ updateUniforms program $ (.= tex) loop $ do- void . runCmd . draw $ framebufferBatch defaultFramebuffer- [anySPBatch $ shaderProgramBatch program texU tex [stdRenderCmd_ quad]]+ gpuRegion . newFrame defaultFramebuffer . newShading (Some program) $ do+ drawGeometry (stdRenderCmd quad) endFrame window vertices :: [V 2 Float]
src/UBO.hs view
@@ -1,5 +1,4 @@ import Common-import Control.Monad import GHC.Generics ( Generic ) import Graphics.Luminance import Linear@@ -9,11 +8,13 @@ triangle <- createGeometry vertices Nothing Triangle vs <- createStage VertexShader vsSource fs <- createStage FragmentShader fsSource- colorBuffer :: Region RW (UB Color) <- createBuffer (newRegion 3)+ colorBuffer :: Buffer RW (UB Color) <- createBuffer (newRegion 3) writeWhole colorBuffer (map UB colors)- (program,colorsU) <- createProgram [vs,fs] $ \uni -> uni (UniformBlockName "Colors")+ program <- createProgram [vs,fs] $ \uni -> uni (UniformBlockName "Colors")+ updateUniforms program $ (.= colorBuffer) loop $ do- void . runCmd . draw $ framebufferBatch defaultFramebuffer [anySPBatch $ shaderProgramBatch program colorsU colorBuffer [stdRenderCmd_ triangle]]+ gpuRegion . newFrame defaultFramebuffer . newShading (Some program) $+ drawGeometry (stdRenderCmd triangle) endFrame window data Color = Color {