Refactored world runner.
[hollow-plutonium.git] / Video.hs
blob91ee797e7ac8ca623f0b71e5b084648b12aa6841
1 module Video (
2 startVideo,
3 endVideo,
4 drawImage,
5 Video(..),
6 Backend(..)
7 ) where
9 import Graphics.UI.SDL (Surface)
10 import Data.IntMap
12 import Coord
13 import Image
14 import VideoGuts
16 data Backend = UseSDL | UseOpenGL
19 startVideo :: Int -> Int -> Backend -> IO Video
20 startVideo w h UseSDL = do
21 screen <- setupSDL w h
22 return (mkClassicBackend screen)
23 startVideo w h UseOpenGL = do
24 setupGL w h
25 return mkGLBackend
28 mkClassicBackend :: Surface -> Video
29 mkClassicBackend screen = Video {
30 clear = sdlClear screen,
31 loadImage = sdlLoadImage screen,
32 setClip = sdlSetClip screen,
33 finalize = sdlFinalize screen
36 mkGLBackend :: Video
37 mkGLBackend = Video {
38 clear = glClear,
39 loadImage = glLoadImage,
40 setClip = glSetClip,
41 finalize = glFinalize
44 endVideo :: IO ()
45 endVideo = quitGuts
47 drawImage :: Coord -> Image -> IO ()
48 drawImage xy img = (imgApply img) xy