From d9d14bdc9448fe909bc1ce13c9ec3a94b3b1d5b7 Mon Sep 17 00:00:00 2001 From: andromeda Date: Thu, 12 Feb 2026 23:25:32 +0100 Subject: [PATCH] example except it just churns and doesn't actually paint a window --- src/Main.hs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Main.hs b/src/Main.hs index 832a24d..0119f13 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,5 +1,37 @@ module Main where +import RGFW.Generated +import Foreign.C.Types (CChar) +import Foreign.C.String (newCString) +import Foreign.C.ConstPtr +import Data.Bits ((.|.)) + main :: IO () main = do - putStrLn "Hello World" + + -- disable wayland, can't be bothered + _ <- rGFW_useWayland_safe $ RGFW_bool 0 + + -- create window. This string does not need to be freed, the window stays open + windowTitle_cstr <- newCString "window" + let + windowTitle_ptr = ConstPtr windowTitle_cstr + windowFlags = RGFW_windowFlags $ fromIntegral $ RGFW_windowCenter .|. RGFW_windowNoResize .|. RGFW_windowOpenGL + + window_ptr <- rGFW_createWindow_safe + windowTitle_ptr -- name + 100 -- x + 100 -- y + 100 -- w + 100 -- h + windowFlags -- flags + putDebug $ "windowFlags: " ++ (show $ unwrapU32 $ unwrapRGFW_windowFlags windowFlags) + putDebug $ "window_ptr: " ++ (show $ window_ptr) + putDebug "created window" + loop 0 + +loop :: Int -> IO () +loop i = loop $ i + 1 + +putDebug :: String -> IO () +putDebug a = putStrLn $ "[debug] " ++ a