Skip to content

Commit

Permalink
Holostress: repro for lambdacube3d/lambdacube-gl#9
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire committed Mar 10, 2017
1 parent 64d2b2c commit e3544e1
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions Holostress.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE UnicodeSyntax #-}

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

import Prelude hiding ((.), id)
import "GLFW-b" Graphics.UI.GLFW as GLFW
import qualified Graphics.Rendering.Cairo as GRC
import qualified Graphics.Rendering.Cairo.Internal as GRC (create)
import qualified GI.PangoCairo.Functions as GIPC
import Linear
import qualified LambdaCube.Linear as LCLin
import LambdaCube.Mesh as LC
import qualified LambdaCube.GL.Mesh as GL
import qualified Data.Vector as V
import qualified Data.Map as Map

-- Local imports
import Flatland
import HoloCanvas
import HoloCube
import HoloSettings
import WindowSys

main IO ()
main = do
stts defaultSettings
win makeGLWindow "holotype"
(Renderer{..}, stream)
makeSimpleRenderedStream win (("canvasStream", "canvasMtl") (ObjArrayNameS, UniformNameS))
let loop = do
_ cassemble stts stream
loop
loop
cassemble Settings 'PU ObjectStream -> IO ()
cassemble Settings{..} ObjectStream{..} = do
let (Di (V2 w h)) = fmap ceiling (di 1 1)
dSurface GRC.createImageSurface GRC.FormatARGB32 w h
dGRC GRC.create dSurface
dGIC grcToGIC dGRC
let (dx, dy) = (fromIntegral w, fromIntegral $ -h)
position = V.fromList [ LCLin.V2 0 dy, LCLin.V2 0 0, LCLin.V2 dx 0, LCLin.V2 0 dy, LCLin.V2 dx 0, LCLin.V2 dx dy ]
texcoord = V.fromList [ LCLin.V2 0 1, LCLin.V2 0 0, LCLin.V2 1 0, LCLin.V2 0 1, LCLin.V2 1 0, LCLin.V2 1 1 ]
dMesh = LC.Mesh { mPrimitive = P_Triangles
, mAttributes = Map.fromList [ ("position", A_V2F position)
, ("uv", A_V2F texcoord) ] }
GL.uploadMeshToGPU dMesh
GIPC.createContext dGIC
pure ()

0 comments on commit e3544e1

Please sign in to comment.