~alcinnz/Mondrian

ref: 595c10c349e1810e1deb4ed192b7f6a54d554d70 Mondrian/lib/Graphics/Rendering/Rect/Backgrounds.hs -rw-r--r-- 680 bytes
595c10c3 — Adrian Cochrane Fix transformation matrix (should be fixed upstream, but that'd be breaking). 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Graphics.Rendering.Rect.Backgrounds(Backgrounds(..), renderBackgrounds) where

import Graphics.Rendering.Rect.CSS.Background
import Graphics.Rendering.Rect.Types
import qualified Data.ByteString.Char8 as B8
import Linear (M44)
import Control.Monad.IO.Class (MonadIO(..))

baseFragmentShader = B8.pack $ unlines [
    "#version 330 core",
    "out vec4 fcolour;",
    "uniform vec4 colour;",
    "void main() { fcolour = colour; }"
  ]

renderBackgrounds :: (MonadIO m, MonadIO n) =>
    n (Backgrounds -> Rects -> M44 Float -> m ())
renderBackgrounds = do
    base <- renderRectWith baseFragmentShader ["colour"]
    return $ \self -> base [c $ background self] paddingBox