module Display (display) where import Graphics.Rendering.OpenGL import Graphics.UI.GLUT import Data.IORef import States import Cube import TipTileMaps import DisplayState import qualified Data.Map as Map display :: (IORef MState) -> (IORef DState) -> (IORef PMState) -> (IORef TexObjGrp) -> IO() display mst dst pmst tObGp = do clearColor $= (Color4 0.4 0.5 0.5 1.0) clear [ColorBuffer] shadeModel $= Smooth --loadIdentity mst' <- readIORef mst dst' <- readIORef dst pmst' <- readIORef pmst tObGp' <- readIORef tObGp let mtable = (mainTable dst') mStateV = (getMStateCounterValueM mst') mStateVRest = (getMStateMaxValueM mst') - mStateV curPosX = cursorTileBasePosX dst' mst' pmst' curPosY = cursorTileBasePosY dst' mst' pmst' dst'' = foldl ( dStateChangeCounterV) dst' [(CTileMove , mStateV) , (CTileMoveRest , mStateVRest) , (CCursorPosX , curPosX) , (CCursorPosY , curPosY)] mapM_ (cubeSet dst'' mst' tObGp') (tipTiles mst') mapM_ (eventButtonSet tObGp' mst') (map snd (Map.toList (eButtons dst''))) let ct =(Map.elems (eCounter dst'')) mapM_ (counterSet tObGp') ct let eventM = events mst' eFrameFlag = mStateGetEventFlag mst' EFrame if eFrameFlag == (Just True) then eventFrame mtable mst' else return () swapBuffers