-------------------------------------------------------------------------------

main :: IO ()
main = do
    let width  = 1280
        height = 720

    eventsChan <- newTQueueIO :: IO (TQueue Event)

    withWindow width height "test" $ \win -> do
        setCallbacks eventsChan win
        G.setCursorInputMode win G.CursorInputMode'Disabled
        GL.depthFunc GL.$= Just GL.Less
        GL.cullFace GL.$= Just GL.Front

        (fbWidth, fbHeight) <- G.getFramebufferSize win
        
        mcube <- runMaybeT makeCube
        texturePath <- getDataFileName "texture.png"
        eitherTexture <- readTexture texturePath

        maybe
            (return ())
            (\cube -> do
                either
                    (\_ -> putStrLn "Failed to load texture")
                    (\tex -> do
                        let env = Env
                                { envEventsChan     = eventsChan
                                , envWindow         = win
                                }
                            state = State
                                { stateWindowWidth  = fbWidth
                                , stateWindowHeight = fbHeight
                                , cube              = cube
                                , cubePositions     = initialCubes
                                , texture           = tex
                                , player            = initialPlayer
                                }
                        runApp env state)
                    eitherTexture)
            mcube
                
-------------------------------------------------------------------------------
main :: IO ()
main = do
    let width  = 1280
        height = 720

    eventsChan <- newTQueueIO :: IO (TQueue Event)

    withWindow width height "test" $ \win -> do
        setCallbacks eventsChan win
        G.setCursorInputMode win G.CursorInputMode'Disabled
        GL.depthFunc GL.$= Just GL.Less
        GL.cullFace GL.$= Just GL.Front

        (fbWidth, fbHeight) <- G.getFramebufferSize win
        
        mcube <- runMaybeT makeCube
        texturePath <- getDataFileName "texture.png"
        eitherTexture <- readTexture texturePath

        maybe
            (return ())
            (\cube -> do
                either
                    (\_ -> putStrLn "Failed to load texture")
                    (\tex -> do
                        let env = Env
                                { envEventsChan     = eventsChan
                                , envWindow         = win
                                }
                            state = State
                                { stateWindowWidth  = fbWidth
                                , stateWindowHeight = fbHeight
                                , cube              = cube
                                , cubePositions     = initialCubes
                                , texture           = tex
                                , player            = initialPlayer
                                }
                        runApp env state)
                    eitherTexture)
            mcube
                
-------------------------------------------------------------------------------
main = do
    let width  = 1280
        height = 720

    eventsChan <- newTQueueIO :: IO (TQueue Event)

    withWindow width height "test" $ \win -> do
        setCallbacks eventsChan win
        G.setCursorInputMode win G.CursorInputMode'Disabled
        GL.depthFunc GL.$= Just GL.Less
        GL.cullFace GL.$= Just GL.Front

        (fbWidth, fbHeight) <- G.getFramebufferSize win
        
        mcube <- runMaybeT makeCube
        texturePath <- getDataFileName "texture.png"
        eitherTexture <- readTexture texturePath

        maybe
            (return ())
            (\cube -> do
                either
                    (\_ -> putStrLn "Failed to load texture")
                    (\tex -> do
                        let env = Env
                                { envEventsChan     = eventsChan
                                , envWindow         = win
                                }
                            state = State
                                { stateWindowWidth  = fbWidth
                                , stateWindowHeight = fbHeight
                                , cube              = cube
                                , cubePositions     = initialCubes
                                , texture           = tex
                                , player            = initialPlayer
                                }
                        runApp env state)
                    eitherTexture)
            mcube
                
-------------------------------------------------------------------------------