module Graphics.UI.WXCore.OpenGL
(
GLAttribute(..)
, glCanvasCreateDefault
, glCanvasCreateEx
) where
import Graphics.UI.WXCore.WxcTypes
import Graphics.UI.WXCore.WxcClasses
import Graphics.UI.WXCore.Types
import Foreign
data GLAttribute
= GL_RGBA
| GL_BUFFER_SIZE Int
| GL_LEVEL Ordering
| GL_DOUBLEBUFFER
| GL_STEREO
| GL_AUX_BUFFERS Int
| GL_MIN_RED Int
| GL_MIN_GREEN Int
| GL_MIN_BLUE Int
| GL_MIN_ALPHA Int
| GL_DEPTH_SIZE Int
| GL_STENCIL_SIZE Int
| GL_MIN_ACCUM_RED Int
| GL_MIN_ACCUM_GREEN Int
| GL_MIN_ACCUM_BLUE Int
| GL_MIN_ACCUM_ALPHA Int
| GL_SAMPLE_BUFFERS Int
| GL_SAMPLES Int
| GL_CORE_PROFILE
| GL_MAJOR_VERSION Int
| GL_MINOR_VERSION Int
encodeAttributes :: [GLAttribute] -> [Int]
encodeAttributes attributes
= concatMap encodeAttribute attributes
encodeAttribute :: GLAttribute -> [Int]
encodeAttribute attr
= case attr of
GL_RGBA -> [1]
GL_BUFFER_SIZE n -> [2,n]
GL_LEVEL n -> [3, case n of { GT -> 1; LT -> (1); _other -> 0 }]
GL_DOUBLEBUFFER -> [4]
GL_STEREO -> [5]
GL_AUX_BUFFERS n -> [6,n]
GL_MIN_RED n -> [7,n]
GL_MIN_GREEN n -> [8,n]
GL_MIN_BLUE n -> [9,n]
GL_MIN_ALPHA n -> [10,n]
GL_DEPTH_SIZE n -> [11,n]
GL_STENCIL_SIZE n -> [12,n]
GL_MIN_ACCUM_RED n -> [13,n]
GL_MIN_ACCUM_GREEN n -> [14,n]
GL_MIN_ACCUM_BLUE n -> [15,n]
GL_MIN_ACCUM_ALPHA n -> [16,n]
GL_SAMPLE_BUFFERS n -> [17,n]
GL_SAMPLES n -> [18,n]
GL_CORE_PROFILE -> [19]
GL_MAJOR_VERSION n -> [20,n]
GL_MINOR_VERSION n -> [21,n]
glCanvasCreateDefault :: Window a -> Style -> String -> [GLAttribute] -> IO (GLCanvas ())
glCanvasCreateDefault parent style title attrs
= glCanvasCreateEx parent idAny rectNull style title attrs nullPalette
glCanvasCreateEx :: Window a -> Id -> Rect -> Style -> String -> [GLAttribute] -> Palette b -> IO (GLCanvas ())
glCanvasCreateEx parent id' rect' style title attributes palette
= withArray0 (toCInt 0) (map toCInt (encodeAttributes attributes)) $ \pattrs ->
glCanvasCreate parent id' pattrs rect' style title palette