aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/Context.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-14 15:13:40 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-14 15:17:46 +0530
commitef178e85975ea2bdbd2043c92f0917e0fe19823a (patch)
tree8d5c6c991fd28cadbdeb905f3d3633ebb30bca83 /src/Chelleport/Context.hs
parentfa02e5c7404dfe6aa47a1f5b5052e915e6d413d6 (diff)
downloadchelleport-ef178e85975ea2bdbd2043c92f0917e0fe19823a.tar.gz
chelleport-ef178e85975ea2bdbd2043c92f0917e0fe19823a.zip
Draw grid + open x11 display to trigger click event
Diffstat (limited to 'src/Chelleport/Context.hs')
-rw-r--r--src/Chelleport/Context.hs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/Chelleport/Context.hs b/src/Chelleport/Context.hs
new file mode 100644
index 0000000..8ef41fd
--- /dev/null
+++ b/src/Chelleport/Context.hs
@@ -0,0 +1,46 @@
+module Chelleport.Context where
+
+import qualified Graphics.X11 as X11
+import SDL (($=))
+import qualified SDL
+import qualified SDL.Font as TTF
+
+data DrawContext = DrawContext
+ { ctxWindow :: SDL.Window,
+ ctxRenderer :: SDL.Renderer,
+ ctxFont :: TTF.Font,
+ ctxX11Display :: X11.Display
+ }
+
+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
+
+ display <- X11.openDisplay ""
+
+ pure $
+ DrawContext
+ { ctxWindow = window,
+ ctxRenderer = renderer,
+ ctxFont = font,
+ ctxX11Display = display
+ }