diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-14 15:13:40 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-14 15:17:46 +0530 |
| commit | ef178e85975ea2bdbd2043c92f0917e0fe19823a (patch) | |
| tree | 8d5c6c991fd28cadbdeb905f3d3633ebb30bca83 /src/Chelleport/AppShell.hs | |
| parent | fa02e5c7404dfe6aa47a1f5b5052e915e6d413d6 (diff) | |
| download | chelleport-ef178e85975ea2bdbd2043c92f0917e0fe19823a.tar.gz chelleport-ef178e85975ea2bdbd2043c92f0917e0fe19823a.zip | |
Draw grid + open x11 display to trigger click event
Diffstat (limited to 'src/Chelleport/AppShell.hs')
| -rw-r--r-- | src/Chelleport/AppShell.hs | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/src/Chelleport/AppShell.hs b/src/Chelleport/AppShell.hs index 74ca784..545df13 100644 --- a/src/Chelleport/AppShell.hs +++ b/src/Chelleport/AppShell.hs @@ -1,5 +1,6 @@ module Chelleport.AppShell where +import Chelleport.Context (DrawContext (ctxRenderer, ctxWindow), createContext) import Control.Monad (foldM, unless) import SDL (($=)) import qualified SDL @@ -9,38 +10,6 @@ data Action act = SysQuit | AppAction act newtype SysState = SysState {sysExit :: Bool} -data DrawContext = DrawContext - { ctxWindow :: SDL.Window, - ctxRenderer :: SDL.Renderer, - ctxFont :: TTF.Font - } - -createContext :: IO DrawContext -createContext = do - -- bounds <- fmap SDL.displayBoundsSize <$> SDL.getDisplays - -- let windowSize = case bounds of - -- (x : _) -> x - -- _ -> SDL.V2 800 600 - let windowSize = SDL.V2 0 0 - - let windowCfg = - SDL.defaultWindow - { SDL.windowInputGrabbed = True, - SDL.windowMode = SDL.FullscreenDesktop, - SDL.windowPosition = SDL.Absolute $ SDL.P $ SDL.V2 0 0, - SDL.windowInitialSize = windowSize, - SDL.windowBorder = False - } - window <- SDL.createWindow "My SDL Application" windowCfg - renderer <- SDL.createRenderer window (-1) SDL.defaultRenderer - font <- TTF.load "Inter-Regular.ttf" 16 - - SDL.windowOpacity window $= 0.6 - SDL.rendererDrawBlendMode renderer $= SDL.BlendAlphaBlend - SDL.rendererDrawColor renderer $= SDL.V4 0 0 0 0 - - pure $ DrawContext {ctxWindow = window, ctxRenderer = renderer, ctxFont = font} - setupAppShell :: (DrawContext -> IO state) -> (state -> DrawContext -> appAction -> IO state) -> @@ -62,6 +31,7 @@ setupAppShell initState update eventHandler draw = do appLoop drawCtx (state, sysState) = do events <- SDL.pollEvents + SDL.rendererDrawColor (ctxRenderer drawCtx) $= SDL.V4 0 0 0 0 SDL.clear $ ctxRenderer drawCtx draw state drawCtx SDL.present $ ctxRenderer drawCtx |
