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 872eec8
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Holostress.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{-# 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.Cairo as GIC
import qualified Foreign.Ptr as F
import qualified GI.PangoCairo.Functions as GIPC
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
import qualified Graphics.Rendering.Cairo.Types as GRC
import qualified Data.GI.Base as GI

-- Local imports
import HoloCube
import WindowSys

main IO ()
main = do
win makeGLWindow "holotype"
(Renderer{..}, _)
makeSimpleRenderedStream win (("canvasStream", "canvasMtl") (ObjArrayNameS, UniformNameS))
let (w, h) = (1, 1)
loop = do
dSurface GRC.createImageSurface GRC.FormatARGB32 w h
dGRC GRC.create dSurface
dGIC GIC.Context <$> GI.newManagedPtr (F.castPtr $ GRC.unCairo dGRC) (return ())
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
loop
loop

0 comments on commit 872eec8

Please sign in to comment.