module Graphics.UI.GLUT.Initialization (
initialize, getArgsAndInitialize, exit,
initialWindowPosition, initialWindowSize,
DisplayMode(..), initialDisplayMode, displayModePossible,
DisplayCapability(..), Relation(..), DisplayCapabilityDescription(..),
initialDisplayCapabilities,
RenderingContext(..), renderingContext,
DirectRendering(..), directRendering,
initialContextVersion, ContextFlag(..), initialContextFlags,
ContextProfile(..), initialContextProfile
) where
import Control.Monad ( when )
import Control.Monad.IO.Class ( MonadIO(..) )
import Data.Bits ( Bits(..) )
import Data.List ( genericLength, intersperse, mapAccumR )
import Data.StateVar ( get, ($=), GettableStateVar, makeGettableStateVar
, SettableStateVar, makeSettableStateVar, StateVar, makeStateVar )
import Foreign.C.String ( peekCString, withCString )
import Foreign.C.Types ( CInt, CUInt )
import Foreign.Marshal.Array ( peekArray, withArray0 )
import Foreign.Marshal.Utils ( with, withMany )
import Foreign.Ptr ( nullPtr )
import Foreign.Storable ( peek )
import Graphics.Rendering.OpenGL ( Position(..), Size(..) )
import System.Environment ( getArgs, getProgName )
import Graphics.UI.GLUT.QueryUtils
import Graphics.UI.GLUT.Raw
import Graphics.UI.GLUT.Types
initialize :: MonadIO m
=> String
-> [String]
-> m [String]
initialize :: String -> [String] -> m [String]
initialize String
prog [String]
args = IO [String] -> m [String]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [String] -> m [String]) -> IO [String] -> m [String]
forall a b. (a -> b) -> a -> b
$
CInt -> (Ptr CInt -> IO [String]) -> IO [String]
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with (CInt
1 CInt -> CInt -> CInt
forall a. Num a => a -> a -> a
+ [String] -> CInt
forall i a. Num i => [a] -> i
genericLength [String]
args) ((Ptr CInt -> IO [String]) -> IO [String])
-> (Ptr CInt -> IO [String]) -> IO [String]
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
argcBuf ->
(String -> (CString -> IO [String]) -> IO [String])
-> [String] -> ([CString] -> IO [String]) -> IO [String]
forall a b res.
(a -> (b -> res) -> res) -> [a] -> ([b] -> res) -> res
withMany String -> (CString -> IO [String]) -> IO [String]
forall a. String -> (CString -> IO a) -> IO a
withCString (String
prog String -> [String] -> [String]
forall a. a -> [a] -> [a]
: [String]
args) (([CString] -> IO [String]) -> IO [String])
-> ([CString] -> IO [String]) -> IO [String]
forall a b. (a -> b) -> a -> b
$ \[CString]
argvPtrs ->
CString -> [CString] -> (Ptr CString -> IO [String]) -> IO [String]
forall a b. Storable a => a -> [a] -> (Ptr a -> IO b) -> IO b
withArray0 CString
forall a. Ptr a
nullPtr [CString]
argvPtrs ((Ptr CString -> IO [String]) -> IO [String])
-> (Ptr CString -> IO [String]) -> IO [String]
forall a b. (a -> b) -> a -> b
$ \Ptr CString
argvBuf -> do
Ptr CInt -> Ptr CString -> IO ()
forall (m :: * -> *). MonadIO m => Ptr CInt -> Ptr CString -> m ()
glutInit Ptr CInt
argcBuf Ptr CString
argvBuf
CInt
newArgc <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
argcBuf
[CString]
newArgvPtrs <- Int -> Ptr CString -> IO [CString]
forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
newArgc) Ptr CString
argvBuf
[String]
newArgv <- (CString -> IO String) -> [CString] -> IO [String]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM CString -> IO String
peekCString [CString]
newArgvPtrs
[String] -> IO [String]
forall (m :: * -> *) a. Monad m => a -> m a
return ([String] -> IO [String]) -> [String] -> IO [String]
forall a b. (a -> b) -> a -> b
$ [String] -> [String]
forall a. [a] -> [a]
tail [String]
newArgv
getArgsAndInitialize :: MonadIO m => m (String, [String])
getArgsAndInitialize :: m (String, [String])
getArgsAndInitialize = IO (String, [String]) -> m (String, [String])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (String, [String]) -> m (String, [String]))
-> IO (String, [String]) -> m (String, [String])
forall a b. (a -> b) -> a -> b
$ do
String
prog <- IO String
getProgName
[String]
args <- IO [String]
getArgs
[String]
nonGLUTArgs <- String -> [String] -> IO [String]
forall (m :: * -> *). MonadIO m => String -> [String] -> m [String]
initialize String
prog [String]
args
(String, [String]) -> IO (String, [String])
forall (m :: * -> *) a. Monad m => a -> m a
return (String
prog, [String]
nonGLUTArgs)
exit :: MonadIO m => m ()
exit :: m ()
exit = m ()
forall (m :: * -> *). MonadIO m => m ()
glutExit
initialWindowPosition :: StateVar Position
initialWindowPosition :: StateVar Position
initialWindowPosition =
IO Position -> (Position -> IO ()) -> StateVar Position
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO Position
getInitialWindowPosition Position -> IO ()
setInitialWindowPosition
getInitialWindowPosition :: IO Position
getInitialWindowPosition :: IO Position
getInitialWindowPosition = do
GLint
x <- Getter GLint
forall a. Getter a
simpleGet CInt -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLenum
glut_INIT_WINDOW_X
GLint
y <- Getter GLint
forall a. Getter a
simpleGet CInt -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLenum
glut_INIT_WINDOW_Y
Position -> IO Position
forall (m :: * -> *) a. Monad m => a -> m a
return (Position -> IO Position) -> Position -> IO Position
forall a b. (a -> b) -> a -> b
$ GLint -> GLint -> Position
Position GLint
x GLint
y
setInitialWindowPosition :: Position -> IO ()
setInitialWindowPosition :: Position -> IO ()
setInitialWindowPosition (Position GLint
x GLint
y) =
CInt -> CInt -> IO ()
forall (m :: * -> *). MonadIO m => CInt -> CInt -> m ()
glutInitWindowPosition (GLint -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLint
x) (GLint -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLint
y)
initialWindowSize :: StateVar Size
initialWindowSize :: StateVar Size
initialWindowSize = IO Size -> (Size -> IO ()) -> StateVar Size
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO Size
getInitialWindowSize Size -> IO ()
setInitialWindowSize
getInitialWindowSize :: IO Size
getInitialWindowSize :: IO Size
getInitialWindowSize = do
GLint
w <- Getter GLint
forall a. Getter a
simpleGet CInt -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLenum
glut_INIT_WINDOW_WIDTH
GLint
h <- Getter GLint
forall a. Getter a
simpleGet CInt -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLenum
glut_INIT_WINDOW_HEIGHT
Size -> IO Size
forall (m :: * -> *) a. Monad m => a -> m a
return (Size -> IO Size) -> Size -> IO Size
forall a b. (a -> b) -> a -> b
$ GLint -> GLint -> Size
Size GLint
w GLint
h
setInitialWindowSize :: Size -> IO ()
setInitialWindowSize :: Size -> IO ()
setInitialWindowSize (Size GLint
w GLint
h) =
CInt -> CInt -> IO ()
forall (m :: * -> *). MonadIO m => CInt -> CInt -> m ()
glutInitWindowSize (GLint -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLint
w) (GLint -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLint
h)
data DisplayMode
= RGBAMode
| RGBMode
| IndexMode
| LuminanceMode
| WithAlphaComponent
| WithAccumBuffer
| WithDepthBuffer
| WithStencilBuffer
| WithAuxBuffers Int
| SingleBuffered
| DoubleBuffered
| Multisampling
| WithSamplesPerPixel Int
| Stereoscopic
| Captionless
| Borderless
| SRGBMode
deriving ( DisplayMode -> DisplayMode -> Bool
(DisplayMode -> DisplayMode -> Bool)
-> (DisplayMode -> DisplayMode -> Bool) -> Eq DisplayMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisplayMode -> DisplayMode -> Bool
$c/= :: DisplayMode -> DisplayMode -> Bool
== :: DisplayMode -> DisplayMode -> Bool
$c== :: DisplayMode -> DisplayMode -> Bool
Eq, Eq DisplayMode
Eq DisplayMode
-> (DisplayMode -> DisplayMode -> Ordering)
-> (DisplayMode -> DisplayMode -> Bool)
-> (DisplayMode -> DisplayMode -> Bool)
-> (DisplayMode -> DisplayMode -> Bool)
-> (DisplayMode -> DisplayMode -> Bool)
-> (DisplayMode -> DisplayMode -> DisplayMode)
-> (DisplayMode -> DisplayMode -> DisplayMode)
-> Ord DisplayMode
DisplayMode -> DisplayMode -> Bool
DisplayMode -> DisplayMode -> Ordering
DisplayMode -> DisplayMode -> DisplayMode
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DisplayMode -> DisplayMode -> DisplayMode
$cmin :: DisplayMode -> DisplayMode -> DisplayMode
max :: DisplayMode -> DisplayMode -> DisplayMode
$cmax :: DisplayMode -> DisplayMode -> DisplayMode
>= :: DisplayMode -> DisplayMode -> Bool
$c>= :: DisplayMode -> DisplayMode -> Bool
> :: DisplayMode -> DisplayMode -> Bool
$c> :: DisplayMode -> DisplayMode -> Bool
<= :: DisplayMode -> DisplayMode -> Bool
$c<= :: DisplayMode -> DisplayMode -> Bool
< :: DisplayMode -> DisplayMode -> Bool
$c< :: DisplayMode -> DisplayMode -> Bool
compare :: DisplayMode -> DisplayMode -> Ordering
$ccompare :: DisplayMode -> DisplayMode -> Ordering
$cp1Ord :: Eq DisplayMode
Ord, Int -> DisplayMode -> ShowS
[DisplayMode] -> ShowS
DisplayMode -> String
(Int -> DisplayMode -> ShowS)
-> (DisplayMode -> String)
-> ([DisplayMode] -> ShowS)
-> Show DisplayMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisplayMode] -> ShowS
$cshowList :: [DisplayMode] -> ShowS
show :: DisplayMode -> String
$cshow :: DisplayMode -> String
showsPrec :: Int -> DisplayMode -> ShowS
$cshowsPrec :: Int -> DisplayMode -> ShowS
Show )
marshalDisplayMode :: DisplayMode -> CUInt
marshalDisplayMode :: DisplayMode -> CUInt
marshalDisplayMode DisplayMode
m = case DisplayMode
m of
DisplayMode
RGBAMode -> CUInt
glut_RGBA
DisplayMode
RGBMode -> CUInt
glut_RGB
DisplayMode
IndexMode -> CUInt
glut_INDEX
DisplayMode
LuminanceMode -> CUInt
glut_LUMINANCE
DisplayMode
WithAlphaComponent -> CUInt
glut_ALPHA
DisplayMode
WithAccumBuffer -> CUInt
glut_ACCUM
DisplayMode
WithDepthBuffer -> CUInt
glut_DEPTH
DisplayMode
WithStencilBuffer -> CUInt
glut_STENCIL
WithAuxBuffers Int
1 -> CUInt
glut_AUX1
WithAuxBuffers Int
2 -> CUInt
glut_AUX2
WithAuxBuffers Int
3 -> CUInt
glut_AUX3
WithAuxBuffers Int
4 -> CUInt
glut_AUX4
WithAuxBuffers Int
n ->
String -> CUInt
forall a. HasCallStack => String -> a
error (String
"marshalDisplayMode: illegal number of auxiliary buffers: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
n)
DisplayMode
SingleBuffered -> CUInt
glut_SINGLE
DisplayMode
DoubleBuffered -> CUInt
glut_DOUBLE
DisplayMode
Multisampling -> CUInt
glut_MULTISAMPLE
WithSamplesPerPixel Int
_ -> String -> CUInt
forall a. HasCallStack => String -> a
error (String
"marshalDisplayMode: this should not happen")
DisplayMode
Stereoscopic -> CUInt
glut_STEREO
DisplayMode
Captionless -> CUInt
glut_CAPTIONLESS
DisplayMode
Borderless -> CUInt
glut_BORDERLESS
DisplayMode
SRGBMode -> CUInt
glut_SRGB
initialDisplayMode :: StateVar [DisplayMode]
initialDisplayMode :: StateVar [DisplayMode]
initialDisplayMode = IO [DisplayMode]
-> ([DisplayMode] -> IO ()) -> StateVar [DisplayMode]
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO [DisplayMode]
getInitialDisplayMode [DisplayMode] -> IO ()
setInitialDisplayMode
getInitialDisplayMode :: IO [DisplayMode]
getInitialDisplayMode :: IO [DisplayMode]
getInitialDisplayMode = do
CUInt
mode <- Getter CUInt
forall a. Getter a
simpleGet CInt -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLenum
glut_INIT_DISPLAY_MODE
let displayModes :: [DisplayMode]
displayModes = CUInt -> [DisplayMode]
i2dms (CUInt
mode CUInt -> CUInt -> CUInt
forall a. Bits a => a -> a -> a
.&. CUInt -> CUInt
forall a. Bits a => a -> a
complement CUInt
glut_MULTISAMPLE)
if CUInt
mode CUInt -> CUInt -> CUInt
forall a. Bits a => a -> a -> a
.&. CUInt
glut_MULTISAMPLE CUInt -> CUInt -> Bool
forall a. Eq a => a -> a -> Bool
== CUInt
0
then [DisplayMode] -> IO [DisplayMode]
forall (m :: * -> *) a. Monad m => a -> m a
return [DisplayMode]
displayModes
else do
Int
n <- StateVar Int -> IO Int
forall t a (m :: * -> *). (HasGetter t a, MonadIO m) => t -> m a
get StateVar Int
samplesPerPixel
[DisplayMode] -> IO [DisplayMode]
forall (m :: * -> *) a. Monad m => a -> m a
return ([DisplayMode] -> IO [DisplayMode])
-> [DisplayMode] -> IO [DisplayMode]
forall a b. (a -> b) -> a -> b
$ Int -> DisplayMode
WithSamplesPerPixel Int
n DisplayMode -> [DisplayMode] -> [DisplayMode]
forall a. a -> [a] -> [a]
: [DisplayMode]
displayModes
i2dms :: CUInt -> [DisplayMode]
i2dms :: CUInt -> [DisplayMode]
i2dms CUInt
bitfield | DisplayMode
IndexMode DisplayMode -> [DisplayMode] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [DisplayMode]
modes Bool -> Bool -> Bool
|| DisplayMode
LuminanceMode DisplayMode -> [DisplayMode] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [DisplayMode]
modes = [DisplayMode]
modes
| Bool
otherwise = DisplayMode
RGBAMode DisplayMode -> [DisplayMode] -> [DisplayMode]
forall a. a -> [a] -> [a]
: [DisplayMode]
modes
where modes :: [DisplayMode]
modes = CUInt -> [DisplayMode]
i2dmsWithoutRGBA CUInt
bitfield
i2dmsWithoutRGBA :: CUInt -> [DisplayMode]
i2dmsWithoutRGBA :: CUInt -> [DisplayMode]
i2dmsWithoutRGBA CUInt
bitfield =
[ DisplayMode
c | DisplayMode
c <- [ DisplayMode
IndexMode, DisplayMode
LuminanceMode, DisplayMode
WithAlphaComponent,
DisplayMode
WithAccumBuffer, DisplayMode
WithDepthBuffer, DisplayMode
WithStencilBuffer,
Int -> DisplayMode
WithAuxBuffers Int
1, Int -> DisplayMode
WithAuxBuffers Int
2, Int -> DisplayMode
WithAuxBuffers Int
3,
Int -> DisplayMode
WithAuxBuffers Int
4, DisplayMode
SingleBuffered, DisplayMode
DoubleBuffered, DisplayMode
Multisampling,
DisplayMode
Stereoscopic, DisplayMode
Captionless, DisplayMode
Borderless, DisplayMode
SRGBMode ]
, (CUInt
bitfield CUInt -> CUInt -> CUInt
forall a. Bits a => a -> a -> a
.&. DisplayMode -> CUInt
marshalDisplayMode DisplayMode
c) CUInt -> CUInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CUInt
0 ]
setInitialDisplayMode :: [DisplayMode] -> IO ()
setInitialDisplayMode :: [DisplayMode] -> IO ()
setInitialDisplayMode [DisplayMode]
modes = do
let ([Int]
spps, [DisplayMode]
transformedModes) = ([Int] -> DisplayMode -> ([Int], DisplayMode))
-> [Int] -> [DisplayMode] -> ([Int], [DisplayMode])
forall (t :: * -> *) a b c.
Traversable t =>
(a -> b -> (a, c)) -> a -> t b -> (a, t c)
mapAccumR [Int] -> DisplayMode -> ([Int], DisplayMode)
handleMultisampling [] [DisplayMode]
modes
(Int -> IO ()) -> [Int] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (StateVar Int
samplesPerPixel StateVar Int -> Int -> IO ()
forall t a (m :: * -> *).
(HasSetter t a, MonadIO m) =>
t -> a -> m ()
$=) [Int]
spps
CUInt -> IO ()
forall (m :: * -> *). MonadIO m => CUInt -> m ()
glutInitDisplayMode ((DisplayMode -> CUInt) -> [DisplayMode] -> CUInt
forall b a. (Num b, Bits b) => (a -> b) -> [a] -> b
toBitfield DisplayMode -> CUInt
marshalDisplayMode [DisplayMode]
transformedModes)
handleMultisampling :: [Int] -> DisplayMode -> ([Int], DisplayMode)
handleMultisampling :: [Int] -> DisplayMode -> ([Int], DisplayMode)
handleMultisampling [Int]
spps (WithSamplesPerPixel Int
spp) = (Int
spp Int -> [Int] -> [Int]
forall a. a -> [a] -> [a]
: [Int]
spps, DisplayMode
Multisampling)
handleMultisampling [Int]
spps DisplayMode
mode = ([Int]
spps, DisplayMode
mode)
toBitfield :: (Num b, Bits b) => (a -> b) -> [a] -> b
toBitfield :: (a -> b) -> [a] -> b
toBitfield a -> b
marshal = (b -> b -> b) -> b -> [b] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl b -> b -> b
forall a. Bits a => a -> a -> a
(.|.) b
0 ([b] -> b) -> ([a] -> [b]) -> [a] -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> [a] -> [b]
forall a b. (a -> b) -> [a] -> [b]
map a -> b
marshal
displayModePossible :: GettableStateVar Bool
displayModePossible :: GettableStateVar Bool
displayModePossible =
GettableStateVar Bool -> GettableStateVar Bool
forall a. IO a -> IO a
makeGettableStateVar (GettableStateVar Bool -> GettableStateVar Bool)
-> GettableStateVar Bool -> GettableStateVar Bool
forall a b. (a -> b) -> a -> b
$ Getter Bool
forall a. Getter a
simpleGet (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) GLenum
glut_DISPLAY_MODE_POSSIBLE
samplesPerPixel :: StateVar Int
samplesPerPixel :: StateVar Int
samplesPerPixel = IO Int -> (Int -> IO ()) -> StateVar Int
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO Int
getSamplesPerPixel Int -> IO ()
setSamplesPerPixel
getSamplesPerPixel :: IO Int
getSamplesPerPixel :: IO Int
getSamplesPerPixel = do
Bool
m <- GettableStateVar Bool
multisamplingSupported
if Bool
m
then Getter Int
forall a. Getter a
simpleGet CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CUInt -> GLenum
forall a b. (Integral a, Num b) => a -> b
fromIntegral CUInt
glut_MULTISAMPLE)
else Int -> IO Int
forall (m :: * -> *) a. Monad m => a -> m a
return Int
defaultSamplesPerPixels
defaultSamplesPerPixels :: Int
defaultSamplesPerPixels :: Int
defaultSamplesPerPixels = Int
4
setSamplesPerPixel :: Int -> IO ()
setSamplesPerPixel :: Int -> IO ()
setSamplesPerPixel Int
spp = do
Bool
m <- GettableStateVar Bool
multisamplingSupported
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
m (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
GLenum -> CInt -> IO ()
forall (m :: * -> *). MonadIO m => GLenum -> CInt -> m ()
glutSetOption (CUInt -> GLenum
forall a b. (Integral a, Num b) => a -> b
fromIntegral CUInt
glut_MULTISAMPLE) (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
spp)
multisamplingSupported :: IO Bool
multisamplingSupported :: GettableStateVar Bool
multisamplingSupported = String -> GettableStateVar Bool
forall (m :: * -> *). MonadIO m => String -> m Bool
isKnown String
"glutGetModeValues"
data DisplayCapability
= DisplayRGBA
| DisplayRGB
| DisplayRed
| DisplayGreen
| DisplayBlue
| DisplayIndex
| DisplayBuffer
| DisplaySingle
| DisplayDouble
| DisplayAccA
| DisplayAcc
| DisplayAlpha
| DisplayDepth
| DisplayStencil
| DisplaySamples
| DisplayStereo
| DisplayLuminance
| DisplayAux
| DisplayNum
| DisplayConformant
| DisplaySlow
| DisplayWin32PFD
| DisplayXVisual
| DisplayXStaticGray
| DisplayXGrayScale
| DisplayXStaticColor
| DisplayXPseudoColor
| DisplayXTrueColor
| DisplayXDirectColor
deriving ( DisplayCapability -> DisplayCapability -> Bool
(DisplayCapability -> DisplayCapability -> Bool)
-> (DisplayCapability -> DisplayCapability -> Bool)
-> Eq DisplayCapability
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisplayCapability -> DisplayCapability -> Bool
$c/= :: DisplayCapability -> DisplayCapability -> Bool
== :: DisplayCapability -> DisplayCapability -> Bool
$c== :: DisplayCapability -> DisplayCapability -> Bool
Eq, Eq DisplayCapability
Eq DisplayCapability
-> (DisplayCapability -> DisplayCapability -> Ordering)
-> (DisplayCapability -> DisplayCapability -> Bool)
-> (DisplayCapability -> DisplayCapability -> Bool)
-> (DisplayCapability -> DisplayCapability -> Bool)
-> (DisplayCapability -> DisplayCapability -> Bool)
-> (DisplayCapability -> DisplayCapability -> DisplayCapability)
-> (DisplayCapability -> DisplayCapability -> DisplayCapability)
-> Ord DisplayCapability
DisplayCapability -> DisplayCapability -> Bool
DisplayCapability -> DisplayCapability -> Ordering
DisplayCapability -> DisplayCapability -> DisplayCapability
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DisplayCapability -> DisplayCapability -> DisplayCapability
$cmin :: DisplayCapability -> DisplayCapability -> DisplayCapability
max :: DisplayCapability -> DisplayCapability -> DisplayCapability
$cmax :: DisplayCapability -> DisplayCapability -> DisplayCapability
>= :: DisplayCapability -> DisplayCapability -> Bool
$c>= :: DisplayCapability -> DisplayCapability -> Bool
> :: DisplayCapability -> DisplayCapability -> Bool
$c> :: DisplayCapability -> DisplayCapability -> Bool
<= :: DisplayCapability -> DisplayCapability -> Bool
$c<= :: DisplayCapability -> DisplayCapability -> Bool
< :: DisplayCapability -> DisplayCapability -> Bool
$c< :: DisplayCapability -> DisplayCapability -> Bool
compare :: DisplayCapability -> DisplayCapability -> Ordering
$ccompare :: DisplayCapability -> DisplayCapability -> Ordering
$cp1Ord :: Eq DisplayCapability
Ord, Int -> DisplayCapability -> ShowS
[DisplayCapability] -> ShowS
DisplayCapability -> String
(Int -> DisplayCapability -> ShowS)
-> (DisplayCapability -> String)
-> ([DisplayCapability] -> ShowS)
-> Show DisplayCapability
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisplayCapability] -> ShowS
$cshowList :: [DisplayCapability] -> ShowS
show :: DisplayCapability -> String
$cshow :: DisplayCapability -> String
showsPrec :: Int -> DisplayCapability -> ShowS
$cshowsPrec :: Int -> DisplayCapability -> ShowS
Show )
displayCapabilityToString :: DisplayCapability -> String
displayCapabilityToString :: DisplayCapability -> String
displayCapabilityToString DisplayCapability
x = case DisplayCapability
x of
DisplayCapability
DisplayRGBA -> String
"rgba"
DisplayCapability
DisplayRGB -> String
"rgb"
DisplayCapability
DisplayRed -> String
"red"
DisplayCapability
DisplayGreen -> String
"green"
DisplayCapability
DisplayBlue -> String
"blue"
DisplayCapability
DisplayIndex -> String
"index"
DisplayCapability
DisplayBuffer -> String
"buffer"
DisplayCapability
DisplaySingle -> String
"single"
DisplayCapability
DisplayDouble -> String
"double"
DisplayCapability
DisplayAccA -> String
"acca"
DisplayCapability
DisplayAcc -> String
"acc"
DisplayCapability
DisplayAlpha -> String
"alpha"
DisplayCapability
DisplayDepth -> String
"depth"
DisplayCapability
DisplayStencil -> String
"stencil"
DisplayCapability
DisplaySamples -> String
"samples"
DisplayCapability
DisplayStereo -> String
"stereo"
DisplayCapability
DisplayLuminance -> String
"luminance"
DisplayCapability
DisplayAux -> String
"aux"
DisplayCapability
DisplayNum -> String
"num"
DisplayCapability
DisplayConformant -> String
"conformant"
DisplayCapability
DisplaySlow -> String
"slow"
DisplayCapability
DisplayWin32PFD -> String
"win32pfd"
DisplayCapability
DisplayXVisual -> String
"xvisual"
DisplayCapability
DisplayXStaticGray -> String
"xstaticgray"
DisplayCapability
DisplayXGrayScale -> String
"xgrayscale"
DisplayCapability
DisplayXStaticColor -> String
"xstaticcolor"
DisplayCapability
DisplayXPseudoColor -> String
"xpseudocolor"
DisplayCapability
DisplayXTrueColor -> String
"xtruecolor"
DisplayCapability
DisplayXDirectColor -> String
"xdirectcolor"
data DisplayCapabilityDescription
= Where DisplayCapability Relation Int
| With DisplayCapability
deriving ( DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
(DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool)
-> (DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool)
-> Eq DisplayCapabilityDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
$c/= :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
== :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
$c== :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
Eq, Eq DisplayCapabilityDescription
Eq DisplayCapabilityDescription
-> (DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Ordering)
-> (DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool)
-> (DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool)
-> (DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool)
-> (DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool)
-> (DisplayCapabilityDescription
-> DisplayCapabilityDescription -> DisplayCapabilityDescription)
-> (DisplayCapabilityDescription
-> DisplayCapabilityDescription -> DisplayCapabilityDescription)
-> Ord DisplayCapabilityDescription
DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Ordering
DisplayCapabilityDescription
-> DisplayCapabilityDescription -> DisplayCapabilityDescription
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> DisplayCapabilityDescription
$cmin :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> DisplayCapabilityDescription
max :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> DisplayCapabilityDescription
$cmax :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> DisplayCapabilityDescription
>= :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
$c>= :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
> :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
$c> :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
<= :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
$c<= :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
< :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
$c< :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Bool
compare :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Ordering
$ccompare :: DisplayCapabilityDescription
-> DisplayCapabilityDescription -> Ordering
$cp1Ord :: Eq DisplayCapabilityDescription
Ord, Int -> DisplayCapabilityDescription -> ShowS
[DisplayCapabilityDescription] -> ShowS
DisplayCapabilityDescription -> String
(Int -> DisplayCapabilityDescription -> ShowS)
-> (DisplayCapabilityDescription -> String)
-> ([DisplayCapabilityDescription] -> ShowS)
-> Show DisplayCapabilityDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisplayCapabilityDescription] -> ShowS
$cshowList :: [DisplayCapabilityDescription] -> ShowS
show :: DisplayCapabilityDescription -> String
$cshow :: DisplayCapabilityDescription -> String
showsPrec :: Int -> DisplayCapabilityDescription -> ShowS
$cshowsPrec :: Int -> DisplayCapabilityDescription -> ShowS
Show )
displayCapabilityDescriptionToString :: DisplayCapabilityDescription -> String
displayCapabilityDescriptionToString :: DisplayCapabilityDescription -> String
displayCapabilityDescriptionToString (Where DisplayCapability
c Relation
r Int
i) =
DisplayCapability -> String
displayCapabilityToString DisplayCapability
c String -> ShowS
forall a. [a] -> [a] -> [a]
++ Relation -> String
relationToString Relation
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
displayCapabilityDescriptionToString (With DisplayCapability
c) = DisplayCapability -> String
displayCapabilityToString DisplayCapability
c
initialDisplayCapabilities :: SettableStateVar [DisplayCapabilityDescription]
initialDisplayCapabilities :: SettableStateVar [DisplayCapabilityDescription]
initialDisplayCapabilities =
([DisplayCapabilityDescription] -> IO ())
-> SettableStateVar [DisplayCapabilityDescription]
forall a. (a -> IO ()) -> SettableStateVar a
makeSettableStateVar (([DisplayCapabilityDescription] -> IO ())
-> SettableStateVar [DisplayCapabilityDescription])
-> ([DisplayCapabilityDescription] -> IO ())
-> SettableStateVar [DisplayCapabilityDescription]
forall a b. (a -> b) -> a -> b
$ \[DisplayCapabilityDescription]
caps ->
String -> (CString -> IO ()) -> IO ()
forall a. String -> (CString -> IO a) -> IO a
withCString
([String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([String] -> String)
-> ([DisplayCapabilityDescription] -> [String])
-> [DisplayCapabilityDescription]
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String] -> [String]
forall a. a -> [a] -> [a]
intersperse String
" " ([String] -> [String])
-> ([DisplayCapabilityDescription] -> [String])
-> [DisplayCapabilityDescription]
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DisplayCapabilityDescription -> String)
-> [DisplayCapabilityDescription] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map DisplayCapabilityDescription -> String
displayCapabilityDescriptionToString ([DisplayCapabilityDescription] -> String)
-> [DisplayCapabilityDescription] -> String
forall a b. (a -> b) -> a -> b
$
[DisplayCapabilityDescription]
caps)
CString -> IO ()
forall (m :: * -> *). MonadIO m => CString -> m ()
glutInitDisplayString
data RenderingContext
=
CreateNewContext
|
UseCurrentContext
deriving ( RenderingContext -> RenderingContext -> Bool
(RenderingContext -> RenderingContext -> Bool)
-> (RenderingContext -> RenderingContext -> Bool)
-> Eq RenderingContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RenderingContext -> RenderingContext -> Bool
$c/= :: RenderingContext -> RenderingContext -> Bool
== :: RenderingContext -> RenderingContext -> Bool
$c== :: RenderingContext -> RenderingContext -> Bool
Eq, Eq RenderingContext
Eq RenderingContext
-> (RenderingContext -> RenderingContext -> Ordering)
-> (RenderingContext -> RenderingContext -> Bool)
-> (RenderingContext -> RenderingContext -> Bool)
-> (RenderingContext -> RenderingContext -> Bool)
-> (RenderingContext -> RenderingContext -> Bool)
-> (RenderingContext -> RenderingContext -> RenderingContext)
-> (RenderingContext -> RenderingContext -> RenderingContext)
-> Ord RenderingContext
RenderingContext -> RenderingContext -> Bool
RenderingContext -> RenderingContext -> Ordering
RenderingContext -> RenderingContext -> RenderingContext
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: RenderingContext -> RenderingContext -> RenderingContext
$cmin :: RenderingContext -> RenderingContext -> RenderingContext
max :: RenderingContext -> RenderingContext -> RenderingContext
$cmax :: RenderingContext -> RenderingContext -> RenderingContext
>= :: RenderingContext -> RenderingContext -> Bool
$c>= :: RenderingContext -> RenderingContext -> Bool
> :: RenderingContext -> RenderingContext -> Bool
$c> :: RenderingContext -> RenderingContext -> Bool
<= :: RenderingContext -> RenderingContext -> Bool
$c<= :: RenderingContext -> RenderingContext -> Bool
< :: RenderingContext -> RenderingContext -> Bool
$c< :: RenderingContext -> RenderingContext -> Bool
compare :: RenderingContext -> RenderingContext -> Ordering
$ccompare :: RenderingContext -> RenderingContext -> Ordering
$cp1Ord :: Eq RenderingContext
Ord, Int -> RenderingContext -> ShowS
[RenderingContext] -> ShowS
RenderingContext -> String
(Int -> RenderingContext -> ShowS)
-> (RenderingContext -> String)
-> ([RenderingContext] -> ShowS)
-> Show RenderingContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RenderingContext] -> ShowS
$cshowList :: [RenderingContext] -> ShowS
show :: RenderingContext -> String
$cshow :: RenderingContext -> String
showsPrec :: Int -> RenderingContext -> ShowS
$cshowsPrec :: Int -> RenderingContext -> ShowS
Show )
marshalRenderingContext :: RenderingContext -> CInt
marshalRenderingContext :: RenderingContext -> CInt
marshalRenderingContext RenderingContext
CreateNewContext = CInt
glut_CREATE_NEW_CONTEXT
marshalRenderingContext RenderingContext
UseCurrentContext = CInt
glut_USE_CURRENT_CONTEXT
unmarshalRenderingContext :: CInt -> RenderingContext
unmarshalRenderingContext :: CInt -> RenderingContext
unmarshalRenderingContext CInt
r
| CInt
r CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
glut_CREATE_NEW_CONTEXT = RenderingContext
CreateNewContext
| CInt
r CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
glut_USE_CURRENT_CONTEXT = RenderingContext
UseCurrentContext
| Bool
otherwise = String -> RenderingContext
forall a. HasCallStack => String -> a
error String
"unmarshalRenderingContext"
renderingContext :: StateVar RenderingContext
renderingContext :: StateVar RenderingContext
renderingContext =
IO RenderingContext
-> (RenderingContext -> IO ()) -> StateVar RenderingContext
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar
(Getter RenderingContext
forall a. Getter a
simpleGet CInt -> RenderingContext
unmarshalRenderingContext GLenum
glut_RENDERING_CONTEXT)
(GLenum -> CInt -> IO ()
forall (m :: * -> *). MonadIO m => GLenum -> CInt -> m ()
glutSetOption GLenum
glut_RENDERING_CONTEXT (CInt -> IO ())
-> (RenderingContext -> CInt) -> RenderingContext -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RenderingContext -> CInt
marshalRenderingContext)
data DirectRendering
=
ForceIndirectContext
|
AllowDirectContext
|
TryDirectContext
|
ForceDirectContext
deriving ( DirectRendering -> DirectRendering -> Bool
(DirectRendering -> DirectRendering -> Bool)
-> (DirectRendering -> DirectRendering -> Bool)
-> Eq DirectRendering
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DirectRendering -> DirectRendering -> Bool
$c/= :: DirectRendering -> DirectRendering -> Bool
== :: DirectRendering -> DirectRendering -> Bool
$c== :: DirectRendering -> DirectRendering -> Bool
Eq, Eq DirectRendering
Eq DirectRendering
-> (DirectRendering -> DirectRendering -> Ordering)
-> (DirectRendering -> DirectRendering -> Bool)
-> (DirectRendering -> DirectRendering -> Bool)
-> (DirectRendering -> DirectRendering -> Bool)
-> (DirectRendering -> DirectRendering -> Bool)
-> (DirectRendering -> DirectRendering -> DirectRendering)
-> (DirectRendering -> DirectRendering -> DirectRendering)
-> Ord DirectRendering
DirectRendering -> DirectRendering -> Bool
DirectRendering -> DirectRendering -> Ordering
DirectRendering -> DirectRendering -> DirectRendering
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DirectRendering -> DirectRendering -> DirectRendering
$cmin :: DirectRendering -> DirectRendering -> DirectRendering
max :: DirectRendering -> DirectRendering -> DirectRendering
$cmax :: DirectRendering -> DirectRendering -> DirectRendering
>= :: DirectRendering -> DirectRendering -> Bool
$c>= :: DirectRendering -> DirectRendering -> Bool
> :: DirectRendering -> DirectRendering -> Bool
$c> :: DirectRendering -> DirectRendering -> Bool
<= :: DirectRendering -> DirectRendering -> Bool
$c<= :: DirectRendering -> DirectRendering -> Bool
< :: DirectRendering -> DirectRendering -> Bool
$c< :: DirectRendering -> DirectRendering -> Bool
compare :: DirectRendering -> DirectRendering -> Ordering
$ccompare :: DirectRendering -> DirectRendering -> Ordering
$cp1Ord :: Eq DirectRendering
Ord, Int -> DirectRendering -> ShowS
[DirectRendering] -> ShowS
DirectRendering -> String
(Int -> DirectRendering -> ShowS)
-> (DirectRendering -> String)
-> ([DirectRendering] -> ShowS)
-> Show DirectRendering
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DirectRendering] -> ShowS
$cshowList :: [DirectRendering] -> ShowS
show :: DirectRendering -> String
$cshow :: DirectRendering -> String
showsPrec :: Int -> DirectRendering -> ShowS
$cshowsPrec :: Int -> DirectRendering -> ShowS
Show )
marshalDirectRendering :: DirectRendering -> CInt
marshalDirectRendering :: DirectRendering -> CInt
marshalDirectRendering DirectRendering
x = case DirectRendering
x of
DirectRendering
ForceIndirectContext -> CInt
glut_FORCE_INDIRECT_CONTEXT
DirectRendering
AllowDirectContext -> CInt
glut_ALLOW_DIRECT_CONTEXT
DirectRendering
TryDirectContext -> CInt
glut_TRY_DIRECT_CONTEXT
DirectRendering
ForceDirectContext -> CInt
glut_FORCE_DIRECT_CONTEXT
unmarshalDirectRendering :: CInt -> DirectRendering
unmarshalDirectRendering :: CInt -> DirectRendering
unmarshalDirectRendering CInt
x
| CInt
x CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
glut_FORCE_INDIRECT_CONTEXT = DirectRendering
ForceIndirectContext
| CInt
x CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
glut_ALLOW_DIRECT_CONTEXT = DirectRendering
AllowDirectContext
| CInt
x CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
glut_TRY_DIRECT_CONTEXT = DirectRendering
TryDirectContext
| CInt
x CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
glut_FORCE_DIRECT_CONTEXT = DirectRendering
ForceDirectContext
| Bool
otherwise = String -> DirectRendering
forall a. HasCallStack => String -> a
error (String
"unmarshalDirectRendering: illegal value " String -> ShowS
forall a. [a] -> [a] -> [a]
++ CInt -> String
forall a. Show a => a -> String
show CInt
x)
directRendering :: StateVar DirectRendering
directRendering :: StateVar DirectRendering
directRendering =
IO DirectRendering
-> (DirectRendering -> IO ()) -> StateVar DirectRendering
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar
(Getter DirectRendering
forall a. Getter a
simpleGet CInt -> DirectRendering
unmarshalDirectRendering GLenum
glut_DIRECT_RENDERING)
(GLenum -> CInt -> IO ()
forall (m :: * -> *). MonadIO m => GLenum -> CInt -> m ()
glutSetOption GLenum
glut_DIRECT_RENDERING (CInt -> IO ())
-> (DirectRendering -> CInt) -> DirectRendering -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DirectRendering -> CInt
marshalDirectRendering)
initialContextVersion :: StateVar (Int, Int)
initialContextVersion :: StateVar (Int, Int)
initialContextVersion = IO (Int, Int) -> ((Int, Int) -> IO ()) -> StateVar (Int, Int)
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO (Int, Int)
getContextVersion (Int, Int) -> IO ()
setContextVersion
getContextVersion :: IO (Int, Int)
getContextVersion :: IO (Int, Int)
getContextVersion = do
Int
major <- Getter Int
forall a. Getter a
simpleGet CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLenum
glut_INIT_MAJOR_VERSION
Int
minor <- Getter Int
forall a. Getter a
simpleGet CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLenum
glut_INIT_MINOR_VERSION
(Int, Int) -> IO (Int, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
major, Int
minor)
setContextVersion :: (Int, Int) -> IO ()
setContextVersion :: (Int, Int) -> IO ()
setContextVersion (Int
major, Int
minor) =
CInt -> CInt -> IO ()
forall (m :: * -> *). MonadIO m => CInt -> CInt -> m ()
glutInitContextVersion (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
major) (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
minor)
data ContextFlag
=
DebugContext
|
ForwardCompatibleContext
deriving ( ContextFlag -> ContextFlag -> Bool
(ContextFlag -> ContextFlag -> Bool)
-> (ContextFlag -> ContextFlag -> Bool) -> Eq ContextFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContextFlag -> ContextFlag -> Bool
$c/= :: ContextFlag -> ContextFlag -> Bool
== :: ContextFlag -> ContextFlag -> Bool
$c== :: ContextFlag -> ContextFlag -> Bool
Eq, Eq ContextFlag
Eq ContextFlag
-> (ContextFlag -> ContextFlag -> Ordering)
-> (ContextFlag -> ContextFlag -> Bool)
-> (ContextFlag -> ContextFlag -> Bool)
-> (ContextFlag -> ContextFlag -> Bool)
-> (ContextFlag -> ContextFlag -> Bool)
-> (ContextFlag -> ContextFlag -> ContextFlag)
-> (ContextFlag -> ContextFlag -> ContextFlag)
-> Ord ContextFlag
ContextFlag -> ContextFlag -> Bool
ContextFlag -> ContextFlag -> Ordering
ContextFlag -> ContextFlag -> ContextFlag
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ContextFlag -> ContextFlag -> ContextFlag
$cmin :: ContextFlag -> ContextFlag -> ContextFlag
max :: ContextFlag -> ContextFlag -> ContextFlag
$cmax :: ContextFlag -> ContextFlag -> ContextFlag
>= :: ContextFlag -> ContextFlag -> Bool
$c>= :: ContextFlag -> ContextFlag -> Bool
> :: ContextFlag -> ContextFlag -> Bool
$c> :: ContextFlag -> ContextFlag -> Bool
<= :: ContextFlag -> ContextFlag -> Bool
$c<= :: ContextFlag -> ContextFlag -> Bool
< :: ContextFlag -> ContextFlag -> Bool
$c< :: ContextFlag -> ContextFlag -> Bool
compare :: ContextFlag -> ContextFlag -> Ordering
$ccompare :: ContextFlag -> ContextFlag -> Ordering
$cp1Ord :: Eq ContextFlag
Ord, Int -> ContextFlag -> ShowS
[ContextFlag] -> ShowS
ContextFlag -> String
(Int -> ContextFlag -> ShowS)
-> (ContextFlag -> String)
-> ([ContextFlag] -> ShowS)
-> Show ContextFlag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContextFlag] -> ShowS
$cshowList :: [ContextFlag] -> ShowS
show :: ContextFlag -> String
$cshow :: ContextFlag -> String
showsPrec :: Int -> ContextFlag -> ShowS
$cshowsPrec :: Int -> ContextFlag -> ShowS
Show )
marshalContextFlag :: ContextFlag -> CInt
marshalContextFlag :: ContextFlag -> CInt
marshalContextFlag ContextFlag
x = case ContextFlag
x of
ContextFlag
DebugContext -> CInt
glut_DEBUG
ContextFlag
ForwardCompatibleContext -> CInt
glut_FORWARD_COMPATIBLE
initialContextFlags :: StateVar [ContextFlag]
initialContextFlags :: StateVar [ContextFlag]
initialContextFlags = IO [ContextFlag]
-> ([ContextFlag] -> IO ()) -> StateVar [ContextFlag]
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO [ContextFlag]
getContextFlags [ContextFlag] -> IO ()
setContextFlags
getContextFlags :: IO [ContextFlag]
getContextFlags :: IO [ContextFlag]
getContextFlags = Getter [ContextFlag]
forall a. Getter a
simpleGet CInt -> [ContextFlag]
i2cfs GLenum
glut_INIT_FLAGS
i2cfs :: CInt -> [ContextFlag]
i2cfs :: CInt -> [ContextFlag]
i2cfs CInt
bitfield =
[ ContextFlag
c | ContextFlag
c <- [ ContextFlag
DebugContext, ContextFlag
ForwardCompatibleContext ]
, (CInt -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
bitfield CInt -> CInt -> CInt
forall a. Bits a => a -> a -> a
.&. ContextFlag -> CInt
marshalContextFlag ContextFlag
c) CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0 ]
setContextFlags :: [ContextFlag] -> IO ()
setContextFlags :: [ContextFlag] -> IO ()
setContextFlags = CInt -> IO ()
forall (m :: * -> *). MonadIO m => CInt -> m ()
glutInitContextFlags (CInt -> IO ())
-> ([ContextFlag] -> CInt) -> [ContextFlag] -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ContextFlag -> CInt) -> [ContextFlag] -> CInt
forall b a. (Num b, Bits b) => (a -> b) -> [a] -> b
toBitfield ContextFlag -> CInt
marshalContextFlag
data ContextProfile
=
CoreProfile
|
CompatibilityProfile
deriving ( ContextProfile -> ContextProfile -> Bool
(ContextProfile -> ContextProfile -> Bool)
-> (ContextProfile -> ContextProfile -> Bool) -> Eq ContextProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContextProfile -> ContextProfile -> Bool
$c/= :: ContextProfile -> ContextProfile -> Bool
== :: ContextProfile -> ContextProfile -> Bool
$c== :: ContextProfile -> ContextProfile -> Bool
Eq, Eq ContextProfile
Eq ContextProfile
-> (ContextProfile -> ContextProfile -> Ordering)
-> (ContextProfile -> ContextProfile -> Bool)
-> (ContextProfile -> ContextProfile -> Bool)
-> (ContextProfile -> ContextProfile -> Bool)
-> (ContextProfile -> ContextProfile -> Bool)
-> (ContextProfile -> ContextProfile -> ContextProfile)
-> (ContextProfile -> ContextProfile -> ContextProfile)
-> Ord ContextProfile
ContextProfile -> ContextProfile -> Bool
ContextProfile -> ContextProfile -> Ordering
ContextProfile -> ContextProfile -> ContextProfile
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ContextProfile -> ContextProfile -> ContextProfile
$cmin :: ContextProfile -> ContextProfile -> ContextProfile
max :: ContextProfile -> ContextProfile -> ContextProfile
$cmax :: ContextProfile -> ContextProfile -> ContextProfile
>= :: ContextProfile -> ContextProfile -> Bool
$c>= :: ContextProfile -> ContextProfile -> Bool
> :: ContextProfile -> ContextProfile -> Bool
$c> :: ContextProfile -> ContextProfile -> Bool
<= :: ContextProfile -> ContextProfile -> Bool
$c<= :: ContextProfile -> ContextProfile -> Bool
< :: ContextProfile -> ContextProfile -> Bool
$c< :: ContextProfile -> ContextProfile -> Bool
compare :: ContextProfile -> ContextProfile -> Ordering
$ccompare :: ContextProfile -> ContextProfile -> Ordering
$cp1Ord :: Eq ContextProfile
Ord, Int -> ContextProfile -> ShowS
[ContextProfile] -> ShowS
ContextProfile -> String
(Int -> ContextProfile -> ShowS)
-> (ContextProfile -> String)
-> ([ContextProfile] -> ShowS)
-> Show ContextProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContextProfile] -> ShowS
$cshowList :: [ContextProfile] -> ShowS
show :: ContextProfile -> String
$cshow :: ContextProfile -> String
showsPrec :: Int -> ContextProfile -> ShowS
$cshowsPrec :: Int -> ContextProfile -> ShowS
Show )
marshalContextProfile :: ContextProfile -> CInt
marshalContextProfile :: ContextProfile -> CInt
marshalContextProfile ContextProfile
x = case ContextProfile
x of
ContextProfile
CoreProfile -> CInt
glut_CORE_PROFILE
ContextProfile
CompatibilityProfile -> CInt
glut_COMPATIBILITY_PROFILE
initialContextProfile :: StateVar [ContextProfile]
initialContextProfile :: StateVar [ContextProfile]
initialContextProfile = IO [ContextProfile]
-> ([ContextProfile] -> IO ()) -> StateVar [ContextProfile]
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar IO [ContextProfile]
getContextProfiles [ContextProfile] -> IO ()
setContextProfiles
getContextProfiles :: IO [ContextProfile]
getContextProfiles :: IO [ContextProfile]
getContextProfiles = Getter [ContextProfile]
forall a. Getter a
simpleGet CInt -> [ContextProfile]
i2cps GLenum
glut_INIT_PROFILE
i2cps :: CInt -> [ContextProfile]
i2cps :: CInt -> [ContextProfile]
i2cps CInt
bitfield =
[ ContextProfile
c | ContextProfile
c <- [ ContextProfile
CoreProfile, ContextProfile
CompatibilityProfile ]
, (CInt -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
bitfield CInt -> CInt -> CInt
forall a. Bits a => a -> a -> a
.&. ContextProfile -> CInt
marshalContextProfile ContextProfile
c) CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0 ]
setContextProfiles :: [ContextProfile] -> IO ()
setContextProfiles :: [ContextProfile] -> IO ()
setContextProfiles = CInt -> IO ()
forall (m :: * -> *). MonadIO m => CInt -> m ()
glutInitContextProfile (CInt -> IO ())
-> ([ContextProfile] -> CInt) -> [ContextProfile] -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ContextProfile -> CInt) -> [ContextProfile] -> CInt
forall b a. (Num b, Bits b) => (a -> b) -> [a] -> b
toBitfield ContextProfile -> CInt
marshalContextProfile