{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{- |
  Module      : Haskengl
  Description : 4D side project
  Copyright   : Andromeda 2025
  License     : WTFPL
  Maintainer  : Matrix @Andromeda:tchncs.de
  Stability   : Experimental
 -}
module Haskengl.Main (main) where

-- IMPORTS --

import Graphics.UI.GLFW (Window)
import Relude
import Relude.Monad (forever)

import Haskengl.IO
import Haskengl.Math.Transforms
import Haskengl.Types
import Haskengl.Update

-- MAIN --

main :: IO ()
main =
  do
    (window, objects) <- openWindow "window :)"
    loop window objects update view model
    return ()

-- | Elm-like 'gameloop'
loop
  :: Window -- ^ The window to display on
  -> DisplayableObjects -- ^ Objects to be displayed
  -> (Model -> Model) -- ^ Update function
  -> (Window -> DisplayableObjects -> Model -> IO ()) -- ^ View function
  -> Model -- ^ Model
  -> IO ()
loop window objects update view model =
  do
    let model = update model
    view window objects model
    loop window objects update view model
