{-# LANGUAGE ForeignFunctionInterface #-} module Init where import Affection as A import SDL (($=)) import qualified SDL import qualified Graphics.Rendering.OpenGL as GL import NanoVG hiding (V2(..), V3(..)) import Linear import Control.Monad (when) import Control.Monad.IO.Class (liftIO) import Control.Concurrent.STM import qualified Data.Set as S import qualified Data.Map.Strict as M import Data.Ecstasy import Data.Maybe import System.Exit (exitFailure) import Foreign.C.Types (CInt(..)) import Types import Floorplan import Debug.Trace foreign import ccall unsafe "glewInit" glewInit :: IO CInt load :: IO UserData load = do _ <- glewInit nvg <- createGL3 (S.fromList [StencilStrokes]) subs <- Subsystems <$> (Window <$> newTVarIO []) <*> (Mouse <$> newTVarIO []) (ws, _) <- yieldSystemT (0, defWorld) (return ()) mwall <- createImage nvg (FileName "assets/walls/wall_desc.png") 0 when (isNothing mwall) $ do logIO Error "Failed to load wall" exitFailure return UserData { state = Menu , subsystems = subs , assetImages = M.fromList [ (ImgWall, fromJust mwall) ] , nano = nvg , uuid = [] , worldState = ws , stateData = None }