26 lines
976 B
Fennel
26 lines
976 B
Fennel
; LIBGL_ALWAYS_INDIRECT=1
|
|
(local fennel (require :fennel))
|
|
(import-macros {: def : q : ttype : static : eval : printform} :terra)
|
|
(local SDL (require :SDL))
|
|
|
|
(local CreateWindowAndRenderer (def [w int h int flags uint32]
|
|
(var window [SDL.Window] nil)
|
|
(var renderer [SDL.Renderer] nil)
|
|
(var result (SDL.CreateWindowAndRenderer w h flags (& window) (& renderer)))
|
|
(return result window renderer)))
|
|
|
|
(local last-event (printform (static SDL.Event (q (SDL.Event {type 0})))))
|
|
(fn event-loop [f]
|
|
(while (not= (SDL.PollEvent (last-event:getpointer)) 0) (f (last-event:get))))
|
|
|
|
(local rect (def [x int y int w int h int]
|
|
(return (SDL.Rect {x x y y w w h h}))))
|
|
|
|
(SDL.Init SDL.INIT_EVERYTHING)
|
|
(let [windowflags SDL.WINDOW_RESIZABLE
|
|
(ok window renderer) (unpacktuple (CreateWindowAndRenderer 640 480 windowflags))]
|
|
(SDL.SetRenderDrawColor renderer 0 0 0 255)
|
|
(SDL.RenderClear renderer)
|
|
(SDL.RenderPresent renderer)
|
|
{: window : renderer : rect : event-loop})
|