aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/Context.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-21 16:37:24 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-21 16:49:42 +0530
commit87815edbab70302793fb83259fedc1ae9004d172 (patch)
treee434cc57bff80f7e8a739db9349225f57e82d2d8 /src/Chelleport/Context.hs
parent217f38ad33811c88c63ff4c0be387e67fb0cd68a (diff)
downloadchelleport-87815edbab70302793fb83259fedc1ae9004d172.tar.gz
chelleport-87815edbab70302793fb83259fedc1ae9004d172.zip
Optimize initialization time
Diffstat (limited to 'src/Chelleport/Context.hs')
-rw-r--r--src/Chelleport/Context.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Chelleport/Context.hs b/src/Chelleport/Context.hs
index 15c0b6a..3c2c850 100644
--- a/src/Chelleport/Context.hs
+++ b/src/Chelleport/Context.hs
@@ -3,6 +3,8 @@ module Chelleport.Context (initializeContext) where
import Chelleport.Types
import Data.ByteString (ByteString)
import Data.FileEmbed (embedFileRelative)
+-- import Data.Time.Clock.System
+-- import qualified Debug.Trace as Debug
import Foreign.C (CFloat)
import qualified Graphics.X11 as X11
import SDL (($=))
@@ -15,10 +17,18 @@ windowOpacity = 0.5
fontSize :: Int
fontSize = 24
+-- benchmark :: String -> IO a -> IO a
+-- benchmark msg m = do
+-- start <- systemNanoseconds <$> getSystemTime
+-- result <- m
+-- end <- systemNanoseconds <$> getSystemTime
+-- Debug.traceM $ msg ++ ": " ++ show (end - start)
+-- pure result
+
initializeContext :: IO DrawContext
initializeContext = do
-- Initialize SDL
- SDL.initializeAll
+ SDL.initialize [SDL.InitVideo, SDL.InitEvents]
TTF.initialize
window <- initializeWindow
@@ -60,6 +70,4 @@ initializeWindow = do
SDL.windowInitialSize = SDL.V2 0 0,
SDL.windowBorder = False
}
- window <- SDL.createWindow "Chelleport" windowCfg
- SDL.showWindow window
- pure window
+ SDL.createWindow "Chelleport" windowCfg