-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMain.hs
74 lines (66 loc) · 2.38 KB
/
Main.hs
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{-# LANGUAGE RecordWildCards #-}
module Main (main) where
import GHC.Conc (getNumProcessors)
import Control.Concurrent (setNumCapabilities)
import Control.Concurrent.STM.TQueue
import Data.List
import qualified System.Info as SI
import App
import Trace
import GLFWHelpers
import GLHelpers
import Timing
import Font
import FrameBuffer
import QuadRendering
import ShaderRendering
import FileModChecker
import qualified BoundedSequence as BS
runOnAllCores :: IO ()
runOnAllCores = GHC.Conc.getNumProcessors >>= setNumCapabilities
traceSystemInfo :: IO ()
traceSystemInfo = do
cpus <- GHC.Conc.getNumProcessors
traceS TLInfo =<<
( (++) . concat . intersperse " · " $
[ "System - OS: " ++ SI.os
, "Arch: " ++ SI.arch
, "CPUs: " ++ show cpus
, concat [ "Compiler: "
, SI.compilerName
, " / "
, show SI.compilerVersion
]
]
)
<$> (("\n" ++) <$> getGLStrings)
-- mapM_ (traceS TLInfo) =<< getGLExtensionList
main :: IO ()
main = do
runOnAllCores
withTrace Nothing True False True TLInfo $ do
_aeGLFWEventsQueue <- newTQueueIO :: IO (TQueue GLFWEvent)
let w = 512
h = 512
shdFn = "./fragment.shd"
reflMapFn = "./latlong_envmaps/uffizi_512.hdr"
in withWindow w h False "Viewer" _aeGLFWEventsQueue $ \_aeWindow ->
withFontTexture $ \_aeFontTexture ->
withFrameBuffer w h HighQualityDownscaling $ \_aeFB ->
withQuadRenderer 16384 $ \_aeQR ->
withShaderRenderer shdFn reflMapFn $ \_aeSR -> do
traceSystemInfo
_asCurTick <- getTick
_aeShaderModChecker <- checkModifedAsync shdFn 0.5
let as = AppState { _asLastEscPress = -1
, _asFrameTimes = BS.empty 60 -- Average over last N FPS
, _asMode = ModeDETestShader
, _asFBScale = 1
, _asLastShdErr = ""
, _asTiling = False
, _asFrameIdx = 0
, _asTakeScreenShot = False
, ..
}
ae = AppEnv { .. }
in runAppT as ae run