0 | {- Tian Z (ecburx@burx.vip) -}
 1 |
 2 | ||| Display a picture in window.
 3 | module IdrisGL.Display
 4 |
 5 | import IdrisGL.Picture
 6 | import IdrisGL.DataType
 7 | import IdrisGL.Color
 8 | import IdrisGL.SDL.SDL_event
 9 | import IdrisGL.SDL.SDL_video
10 | import IdrisGL.SDL.SDL_render
11 | import IdrisGL.SDL.SDL_surface
12 | import IdrisGL.SDL.SDL_timer
13 |
14 | ||| Open a new window and display the given picture.
15 | |||
16 | ||| @ window  Display mode.
17 | ||| @ bgColor Background color.
18 | ||| @ pic     Picture.
19 | export
20 | display : (window  : Display)
21 |        -> (bgColor : Color)
22 |        -> (pic     : Picture) 
23 |        -> IO ()
24 | display window bgColor pic  =  do 
25 |     win                     <- createWin window
26 |     ren                     <- createRenderer win
27 |     setRenderDrawColor         ren bgColor
28 |
29 |     renderClear                ren
30 |     loadPicture                pic ren win
31 |     renderPresent              ren
32 |     e                       <- newEve
33 |     loop                       e
34 |
35 |     closeWin                   win
36 |     freeEve e
37 |     freeRender                 ren
38 |
39 |     where loop : Event -> IO ()
40 |           loop     e with (eveType e)
41 |               loop _ | E_QUIT = pure ()
42 |               loop e | _      = loop e