summaryrefslogtreecommitdiffstats
path: root/GLDriver.hs
blob: 2e3dafc6cbb4cbc3cff1467898899ba75cc5f4fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{-# LANGUAGE ExistentialQuantification, DeriveDataTypeable #-}

module GLDriver ( Driver(..)
                , Event
                , SomeEvent(..)
                , QuitEvent(..)
                , ResizeEvent(..)
                , fromEvent
                ) where

import Data.Typeable


class Driver a where
    initialized :: a -> Bool
    
    initGL :: a -> IO a
    deinitGL :: a -> IO ()
    
    swapBuffers :: a -> IO ()
    
    nextEvent :: a -> IO (Maybe SomeEvent)


class Typeable a => Event a

data SomeEvent = forall a. Event a => SomeEvent a

fromEvent :: Event a => SomeEvent -> Maybe a
fromEvent (SomeEvent a) = cast a


data QuitEvent = QuitEvent deriving Typeable
instance Event QuitEvent

data ResizeEvent = ResizeEvent Int Int deriving Typeable
instance Event ResizeEvent