hpastetwo

Simple GPipe Program

author
jmcarthur/geezusfreeek
age
127 days
language
haskell
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Main where

import Control.Applicative
import Data.Vec
import Graphics.GPipe
import qualified Graphics.UI.GLUT as GLUT

main :: IO ()
main = do
  GLUT.getArgsAndInitialize
  newWindow "Test"
            (0:.0:.())
            (640:.480:.())
            (return . paintSquare . newFrameBufferColor . RGB $ 0.5:.0.5:.0.5:.())
            (const $ return ())
  GLUT.mainLoop


square :: PrimitiveStream Triangle (Vec2 (Vertex Float))
square = toGPUStream TriangleFan [0:.0:.(), 0:.1:.(), 1:.1:.(), 1:.0:.()]

squareF :: FragmentStream ()
squareF = rasterize $ flip (,) () . (`append` 0:.1:.()) <$> square

paintSquare :: FrameBuffer RGBFormat () () -> FrameBuffer RGBFormat () ()
paintSquare = paintColor NoBlending (RGB $ True:.True:.True:.()) $ (RGB $ 1:.0:.0:.()) <$ squareF