packages feed

opengles (empty) → 0.4.0

raw patch · 19 files changed

+5651/−0 lines, 19 filesdep +arraydep +basedep +bytestringsetup-changed

Dependencies added: array, base, bytestring, future-resource, ghc-prim, linear-vect, packer

Files

+ Graphics/EGL.hs view
@@ -0,0 +1,617 @@+{-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__+{-# LANGUAGE Unsafe, UnliftedFFITypes, MagicHash, UnboxedTuples #-}+#endif+-- | EGL 1.4 standard+-- +-- <http://www.khronos.org/registry/egl/>+-- +-- <http://www.khronos.org/files/egl-1-4-quick-reference-card.pdf>+module Graphics.EGL where+import Control.Applicative+import Data.IORef+import Foreign+import Foreign.C.String+import System.IO.Unsafe (unsafePerformIO)+import Unsafe.Coerce+#if __GLASGOW_HASKELL__+import GHC.Base (realWorld#)+import GHC.CString (unpackCString#)+import GHC.IO (IO (IO))+import GHC.Ptr (Ptr(..))+#else+import System.IO.Unsafe+#endif++type EGL a = IO (Either EGLError a)++-- * Errors+-- 0x3000-0x301E (Reserved 0x300F-0x301F for additional errors)+data EGLError =+    EGLSuccess+  | EGLNotInitialized+  | EGLBadAccess+  | EGLBadAlloc+  | EGLBadAttribute+  | EGLBadConfig+  | EGLBadContext+  | EGLBadCurrentSurface+  | EGLBadDisplay+  | EGLBadMatch+  | EGLBadNativePixmap+  | EGLBadNativeWindow+  | EGLBadParameter+  | EGLBadSurface+  | EGLContextLost+  | EGLUnknownErr Int++instance Show EGLError where+  show EGLSuccess = "EGLSuccess: Function succeeded."+  show EGLNotInitialized = "EGLNotInitialized: EGL is not or could not be initialized, for the specified display."+  show EGLBadAccess = "EGLBadAccess: EGL cannot access a requested resource (for example, a context is bound in another thread)."+  show EGLBadAlloc = "EGLBadAlloc: EGL failed to allocate resources for the requested operation."+  show EGLBadAttribute = "EGLBadAttribute: An unrecognized attribute or attribute value was passed in an attribute list."+  show EGLBadConfig = "EGLBadConfig: An EGLConfig argument does not name a valid EGLConfig."+  show EGLBadContext = "EGLBadContext: An EGLContext argument does not name a valid EGLContext."+  show EGLBadCurrentSurface = "EGLBadCurrentSurface: The current surface of the calling thread is a window, pbuffer, or pixmap that is no longer valid."+  show EGLBadDisplay = "EGLBadDisplay: An EGLDisplay argument does not name a valid EGLDisplay."+  show EGLBadMatch = "EGLBadMatch: Arguments are inconsistent; for example, an otherwise valid context requires buffers (e.g. depth or stencil) not allocated by an otherwise valid surface."+  show EGLBadNativePixmap = "EGLBadNativePixmap: An EGLNativePixmapType argument does not refer to a valid native pixmap."+  show EGLBadNativeWindow = "EGLBadNativeWindow: An EGLNativeWindowType argument does not refer to a valid native window."+  show EGLBadParameter = "EGLBadParameter: One or more argument values are invalid."+  show EGLBadSurface = "EGLBadSurface: An EGLSurface argument does not name a valid surface (window, pbuffer, or pixmap) configured for rendering."+  show EGLContextLost = "EGLContextLost: A power management event has occurred. The application must destroy all contexts and reinitialise client API state and objects to continue rendering."+  show (EGLUnknownErr n) = "EGLUnknownError: This error (" ++ show n ++ ") is not defined in EGL 1.4 spec."++eglGetError :: IO EGLError+eglGetError = c_eglGetError >>= return . unMarshal . (-) 0x3000+  where unMarshal x | x < 15 =+          [EGLSuccess+          ,EGLNotInitialized+          ,EGLBadAccess+          ,EGLBadAlloc+          ,EGLBadAttribute+          ,EGLBadConfig+          ,EGLBadContext+          ,EGLBadCurrentSurface+          ,EGLBadDisplay+          ,EGLBadMatch+          ,EGLBadNativePixmap+          ,EGLBadNativeWindow+          ,EGLBadParameter+          ,EGLBadSurface+          ,EGLContextLost+          ] !! x+        unMarshal x = EGLUnknownErr x++-- * Attribute Lists+-- 0x3020-0x3042 (Reserved 0x3041-0x304F for additional config attributes)+data EGLConfAttr =+    EGLBufferSize --EGLint+  | EGLAlphaSize --EGLint+  | EGLBlueSize --EGLint+  | EGLGreenSize --EGLint+  | EGLRedSize --EGLint+  | EGLDepthSize --EGLint+  | EGLStencilSize --EGLint+  | EGLConfigCaveat --EGLConfigCaveatValue+  | EGLConfigID --EGLint+  | EGLLevel --EGLint+  | EGLMaxPbufferHeight --EGLint+  | EGLMaxPbufferPixels --EGLint+  | EGLMaxPbufferWidth --EGLint+  | EGLNativeRenderable --EGLBoolean+  | EGLNativeVisualID --EGLint+  | EGLNativeVisualType --EGLint+  | EGLSamples --EGLint+  | EGLSampleBuffers --EGLint+  | EGLSurfaceType --EGLint+  | EGLTransparentType --EGLTransparentTypeValue+  | EGLTransparentBlueValue --EGLint+  | EGLTransparentGreenValue --EGLint+  | EGLTransparentRedValue --EGLint+  | EGLBindToTextureRGB --EGLBoolean+  | EGLBindToTextureRGBA --EGLBoolean+  | EGLMinSwapInterval --EGLint+  | EGLMaxSwapInterval --EGLint+  | EGLLuminanceSize --EGLint+  | EGLAlphaMaskSize --EGLint+  | EGLColorBufferType --EGLColorBufferTypeValue+  | EGLRenderableType --EGLint+  | EGLMatchNativePixmap -- ^ EGLint Pseudo-attribute (not queryable)+  | EGLConformant --EGLint++-- XXX deprecated instance+instance Enum EGLConfAttr where+  fromEnum x = case x of+    EGLBufferSize -> 0x3020+    EGLAlphaSize -> 0x3021+    EGLBlueSize -> 0x3022+    EGLGreenSize -> 0x3023+    EGLRedSize -> 0x3024+    EGLDepthSize -> 0x3025+    EGLStencilSize -> 0x3026+    EGLConfigCaveat -> 0x3027+    EGLConfigID -> 0x3028+    EGLLevel -> 0x3029+    EGLMaxPbufferHeight -> 0x302A+    EGLMaxPbufferPixels -> 0x302B+    EGLMaxPbufferWidth -> 0x302C+    EGLNativeRenderable -> 0x302D+    EGLNativeVisualID -> 0x302E+    EGLNativeVisualType -> 0x302F+    EGLSamples -> 0x3031+    EGLSampleBuffers -> 0x3032+    EGLSurfaceType -> 0x3033+    EGLTransparentType -> 0x3034+    EGLTransparentBlueValue -> 0x3035+    EGLTransparentGreenValue -> 0x3036+    EGLTransparentRedValue -> 0x3037+    EGLBindToTextureRGB -> 0x3039+    EGLBindToTextureRGBA -> 0x303A+    EGLMinSwapInterval -> 0x303B+    EGLMaxSwapInterval -> 0x303C+    EGLLuminanceSize -> 0x303D+    EGLAlphaMaskSize -> 0x303E+    EGLColorBufferType -> 0x303F+    EGLRenderableType -> 0x3040+    EGLMatchNativePixmap -> 0x3041+    EGLConformant -> 0x3042++egl_true = 1 :: Int+egl_false = 0 :: Int+-- | EGL_CONFIG_CAVEAT value EGL_NONE | 0x3050 | 0x3051+egl_none = 0x3038 :: Int+egl_slow_config = 0x3050 :: Int+egl_non_conformant_config = 0x3051 :: Int++-- | EGL_TRANSPARENT_TYPE value EGL_NONE | 0x3052+egl_transparent_rgb = 0x3052 :: Int++-- | EGL_COLOR_BUFFER_TYPE value 0x308E | 0x308F+egl_rgb_buffer = 0x308E :: Int+egl_luminance_buffer = 0x308F :: Int++-- | EGL_RENDERABLE_TYPE bitmask+egl_opengl_es_bit = 1 :: Int+egl_openvg_bit = 2 :: Int+egl_opengl_es2_bit = 4 :: Int+egl_opengl_bit = 8 :: Int++data EGLSurfAttr =+      EGLVGAlphaFormat -- enum Alpha format for OpenVG+    | EGLVGColorspace -- enum Color space for OpenVG+    | EGLConfigId -- Integer ID of EGLConfig surface was created with EGL_HEIGHT integer Height of surface+    | EGLHeight -- Height of surface+    | EGLHorizontalResolution -- integer Horizontal dot pitch+    | EGLLargestPbuffer -- boolean If true, create largest pbuffer possible+    | EGLMipmapTexture -- boolean True if texture has mipmaps+    | EGLMipmapLevel -- integer Mipmap level to render to+    | EGLMultisampleResolve -- enum Multisample resolve behavior+    | EGLPixelAspectRaito -- integer Display aspect ratio+    | EGLRenderBuffer -- enum Render buffer+    | EGLSwapBehavior -- enum Buffer swap behavior+    | EGLTextureFormat -- enum Format of texture: RGB, RGBA, or no texture+    | EGLTextureTarget -- enum Type of texture: 2D or no texture+    | EGLVerticalResolution -- integer Vertical dot pitch+    | EGLWidth -- integer Width of surface++instance Enum EGLSurfAttr where+  fromEnum x = case x of+    EGLHeight -> 0x3056+    EGLWidth -> 0x3067+    EGLLargestPbuffer -> 0x3058+    EGLTextureFormat -> 0x3080+    EGLTextureTarget -> 0x3081+    EGLMipmapTexture -> 0x3082+    EGLMipmapLevel -> 0x3083+    EGLRenderBuffer -> 0x3086+    EGLVGColorspace -> 0x3087+    EGLVGAlphaFormat -> 0x3088+    EGLHorizontalResolution -> 0x3090+    EGLVerticalResolution -> 0x3091+    EGLPixelAspectRaito -> 0x3092+    EGLSwapBehavior -> 0x3093+    EGLMultisampleResolve -> 0x3099+    EGLConfigId -> 0x3028++-- EGLBoolean -> EGLError+toEglErr api = api >>= \eglbool ->+  if isTrue eglbool then return EGLSuccess else eglGetError+-- falsy -> Left EGLError, good -> Right result+checkErr api cond f = api >>= \result ->+  if cond result then f result else Left <$> eglGetError+checkPtr api wrap = api >>= \ptr ->+  if ptr /= nullPtr then return (Right $ wrap ptr) else Left <$> eglGetError+checkBool api f = api >>= \bool ->+  if isTrue bool then Right <$> f else Left <$> eglGetError+isTrue = (/= 0)+withAttrList attrs =+  withArray $ foldr (\(k, v) l -> fromEnum k : v : l) [0x3038] attrs++-- * Initialization & Terminating+eglGetDefaultDisplay :: IO EGLDisplay+eglGetDefaultDisplay = EGLDisplay <$> c_eglGetDisplay nullPtr++eglGetDisplay :: EGLNativeDisplay a => a -> IO EGLDisplay+eglGetDisplay display = EGLDisplay <$> c_eglGetDisplay (getNativeDisplay display)++eglInitialize :: EGLDisplay -> EGL (Int, Int) -- ^ EGL (major, minor) version+eglInitialize display = alloca $ \major -> alloca $ \minor ->+  checkBool (c_eglInitialize (unD display) major minor) ((,) <$> peek major <*> peek minor)++eglTerminate :: EGLDisplay -> IO EGLError+eglTerminate display = toEglErr $ c_eglTerminate (unD display)++eglVendor display = c_eglQueryString (unD display) 0x3053 >>= peekCString+eglVersion display = c_eglQueryString (unD display) 0x3054 >>= peekCString+eglExtensions display = words <$> (c_eglQueryString (unD display) 0x3055 >>= peekCString)+eglClientAPIs display = words <$> (c_eglQueryString (unD display) 0x308D >>= peekCString)++eglQueryString :: EGLDisplay -> Int -> EGL String+eglQueryString display name =+  checkErr (c_eglQueryString (unD display) name) (/= nullPtr) (\str -> Right <$> peekCString str)++eglReleaseThread :: IO EGLError+eglReleaseThread = toEglErr c_eglReleaseThread++-- * Configuration Management+eglGetConfigs :: EGLDisplay -> EGL [EGLConfig]+eglGetConfigs display = alloca $ \num_config ->+  checkErr (c_eglGetConfigs (unD display) nullPtr 0 num_config) isTrue $ \_ -> do+    n <- peek num_config+    allocaArray n $ \configs ->+      checkBool (c_eglGetConfigs (unD display) configs n num_config) (map EGLConfig <$> peekArray n configs)++eglChooseConfig :: EGLDisplay -> [(EGLConfAttr, Int)] -> EGL [EGLConfig]+eglChooseConfig display attrs = withArray (const [0x3038] attrs) $ \attrib_list -> alloca $ \num_config ->+  checkErr (c_eglChooseConfig (unD display) attrib_list nullPtr 0 num_config) isTrue $ \_ -> do+    n <- peek num_config+    allocaArray n $ \configs ->+      checkBool (c_eglChooseConfig (unD display) attrib_list configs n num_config) (map EGLConfig <$> peekArray n configs)++eglGetConfigAttrib :: EGLDisplay -> EGLConfig -> EGLConfAttr -> EGL Int+eglGetConfigAttrib display config attribute = alloca $ \value ->+  checkBool (c_eglGetConfigAttrib (unD display) (unC config) (fromEnum attribute) value) (peek value)++-- * Rendering Surfaces+-- include EGL_RENDER_BUFFER,EGL_VG_COLORSPACE, and EGL_VG_ALPHA_FORMAT + ext+eglCreateWindowSurface :: EGLNativeWindow a => EGLDisplay -> EGLConfig -> a -> [(EGLSurfAttr, Int)] -> EGL EGLSurface+eglCreateWindowSurface display config win attrs =+  withAttrList attrs $ \attrib_list ->+    checkPtr (c_eglCreateWindowSurface (unD display) (unC config) (getNativeWindow win) attrib_list) EGLSurface++-- include EGL_WIDTH,EGL_HEIGHT,EGL_LARGEST_PBUFFER,EGL_TEXTURE_FORMAT,EGL_TEXTURE_TARGET,+-- EGL_MIPMAP_TEXTURE,EGL_VG_COLORSPACE, and EGL_VG_ALPHA_FORMAT + ext+eglCreatePbufferSurface :: EGLDisplay -> EGLConfig -> [(EGLSurfAttr, Int)] -> EGL EGLSurface+eglCreatePbufferSurface display config attrs =+  withAttrList attrs $ \attrib_list ->+    checkPtr (c_eglCreatePbufferSurface (unD display) (unC config) attrib_list) EGLSurface++-- include EGL_TEXTURE_FORMAT,EGL_TEXTURE_TARGET, and EGL_MIPMAP_TEXTURE+eglCreatePbufferFromClientBuffer :: EGLDisplay -> EGLenum -> EGLClientBuffer -> EGLConfig -> [(EGLSurfAttr, Int)] -> EGL EGLSurface+eglCreatePbufferFromClientBuffer display buftype buffer config attrs =+  withAttrList attrs $ \attrib_list ->+    checkPtr (c_eglCreatePbufferFromClientBuffer (unD display) buftype (unB buffer) (unC config) attrib_list) EGLSurface++eglDestroySurface :: EGLDisplay -> EGLSurface -> IO EGLError+eglDestroySurface display surface = toEglErr (c_eglDestroySurface (unD display) (unS surface))++-- include EGL_VG_COLORSPACE and EGL_VG_ALPHA_FORMAT + ext+eglCreatePixmapSurface :: EGLNativePixmap a => EGLDisplay -> EGLConfig -> a ->  [(EGLSurfAttr, Int)] -> EGL EGLSurface+eglCreatePixmapSurface display config pixmap attrs =+  withAttrList attrs $ \attrib_list ->+    checkPtr (c_eglCreatePixmapSurface (unD display) (unC config) (getNativePixmap pixmap) attrib_list) EGLSurface++eglSurfaceAttrib :: EGLDisplay -> EGLSurface -> EGLSurfAttr -> Int -> IO EGLError+eglSurfaceAttrib display surface attribute value =+  toEglErr (c_eglSurfaceAttrib (unD display) (unS surface) (fromEnum attribute) value)++eglQuerySurface :: EGLDisplay -> EGLSurface -> EGLSurfAttr -> EGL Int+eglQuerySurface display surface attribute = alloca $ \value ->+  checkBool (c_eglQuerySurface (unD display) (unS surface) (fromEnum attribute) value) (peek value)++-- * Rendering Contexts+-- 0x30A0 | 0x30A1 | 0x30A2 | 0x3038+data EGLBindAPIValue = EGLOpenGLESAPI | EGLOpenVGAPI | EGLOpenGLAPI | EGLAPINone+instance Enum EGLBindAPIValue where+  fromEnum EGLOpenGLESAPI = 0x30A0+  fromEnum EGLOpenVGAPI = 0x30A1+  fromEnum EGLOpenGLAPI = 0x30A2+  fromEnum EGLAPINone = 0x3038+  toEnum 0x30A0 = EGLOpenGLESAPI+  toEnum 0x30A1 = EGLOpenVGAPI+  toEnum 0x30A2 = EGLOpenGLAPI+  toEnum _ = EGLAPINone++eglBindAPI :: EGLBindAPIValue -> IO EGLError+eglBindAPI value = toEglErr (c_eglBindAPI (fromEnum value))++eglQueryAPI :: IO EGLBindAPIValue+eglQueryAPI = toEnum <$> c_eglQueryAPI++-- only EGL_CONTEXT_CLIENT_VERSION 0x3098 = 1 or 2+data EGLContextAttr = EGLContextClientVersion+instance Enum EGLContextAttr where+  fromEnum EGLContextClientVersion = 0x3098+eglCreateContext :: EGLDisplay -> EGLConfig -> [(EGLContextAttr, Int)] -> EGL EGLContext+eglCreateContext display config attrs =+  eglCreateContextWithShareContext display config (EGLContext nullPtr) attrs++eglCreateContextWithShareContext :: EGLDisplay -> EGLConfig -> EGLContext -> [(EGLContextAttr, Int)] -> EGL EGLContext+eglCreateContextWithShareContext display config shared_cxt attrs =+  withAttrList attrs $ \attrib_list ->+     checkPtr (c_eglCreateContext (unD display) (unC config) (unX shared_cxt) attrib_list) EGLContext++eglDestroyContext :: EGLDisplay -> EGLContext -> IO EGLError+eglDestroyContext display context =+  toEglErr(c_eglDestroyContext (unD display) (unX context))++eglMakeCurrent :: EGLDisplay -> EGLSurface -> EGLSurface -> EGLContext -> IO EGLError+eglMakeCurrent display draw read context =+  toEglErr (c_eglMakeCurrent (unD display) (unS draw) (unS read) (unX context))++eglReleaseCurrent :: EGLDisplay -> IO EGLError+eglReleaseCurrent display = toEglErr (c_eglMakeCurrent (unD display) nullPtr nullPtr nullPtr)++eglGetCurrentContext :: EGL EGLContext+eglGetCurrentContext = checkPtr c_eglGetCurrentContext EGLContext++data EGLReadDraw = EGLRead | EGLDraw deriving Eq+eglGetCurrentSurface :: EGLReadDraw -> EGL EGLSurface+eglGetCurrentSurface readdraw =+  checkPtr (c_eglGetCurrentSurface $+      if readdraw == EGLDraw then 0x3059 else 0x305A) EGLSurface++eglGetCurrentDisplay :: EGL EGLDisplay+eglGetCurrentDisplay = checkPtr c_eglGetCurrentDisplay EGLDisplay++-- EGL_CONFIG_ID, EGL_CONTEXT_CLIENT_TYPE, EGL_CONTEXT_CLIENT_VERSION, EGL_RENDER_BUFFER+eglConfigID d c = eglQueryContext d c 0x3028+eglContextClientType d c = eglQueryContext d c 0x3097+eglContextClientVersion d c = eglQueryContext d c 0x3098+eglRenderBuffer d c = eglQueryContext d c 0x3086++eglQueryContext :: EGLDisplay -> EGLContext -> Int -> EGL Int+eglQueryContext display context attribute = alloca $ \value ->+  checkBool (c_eglQueryContext (unD display) (unX context) attribute value) (peek value)++-- * Synchronization Primitives+eglWaitClient :: IO EGLError+eglWaitClient = toEglErr c_eglWaitClient+-- eglWaitGL is available for backwards compatibility+-- eglWaitGL :: IO EGLError+-- eglWaitGL = toEglErr c_eglWaitGL++data EGLWaitEngine = EGLCoreNativeEngine+eglWaitNative :: EGLWaitEngine -> IO EGLError+eglWaitNative engine = toEglErr (c_eglWaitNative 0x305B)++-- * Posting the Color Buffer+eglSwapBuffers :: EGLDisplay -> EGLSurface -> IO EGLError+eglSwapBuffers display surface =+  toEglErr (c_eglSwapBuffers (unD display) (unS surface))++eglCopyBuffers :: EGLNativePixmap a => EGLDisplay -> EGLSurface -> a -> IO EGLError+eglCopyBuffers display surface pixmap =+  toEglErr (c_eglCopyBuffers (unD display) (unS surface) (getNativePixmap pixmap))++eglSwapInterval :: EGLDisplay -> Int -> IO EGLError+eglSwapInterval display interval =+  toEglErr (c_eglSwapInterval (unD display) interval)++-- * Render to Textures+-- EGL_RENDER_BUFFER value 0x3084 | 0x3085+data EGLBuffer = EGLBackBuffer | EGLSingleBuffer deriving Eq+eglBindTexImage :: EGLDisplay -> EGLSurface -> EGLBuffer -> IO EGLError+eglBindTexImage display surface buffer =+  toEglErr (c_eglBindTexImage (unD display) (unS surface) (if buffer == EGLBackBuffer then 0x3084 else 0x3085))++eglReleaseTexImage :: EGLDisplay -> EGLSurface -> EGLBuffer -> IO EGLError+eglReleaseTexImage display surface buffer =+  toEglErr (c_eglReleaseTexImage (unD display) (unS surface) (if buffer == EGLBackBuffer then 0x3084 else 0x3085))++-- * Obtain Extension Function Pointers+eglGetProcAddress :: String -> FunPtr a+eglGetProcAddress procname =+  unsafePerformIO $ withCString procname c_eglGetProcAddress++#if defined(__GLASGOW_HASKELL__)+{-# INLINE [0] eglGetProcAddress #-}+{-# RULES+"EGL eglGetProcAddress/c_eglGetProcAddress" forall s .+   eglGetProcAddress (unpackCString# s) = inlinePerformIO (c_eglGetProcAddress (Ptr s))+ #-}++{-# INLINE inlinePerformIO #-}+-- | Just like unsafePerformIO, but we inline it. Big performance gains as+-- it exposes lots of things to further inlining. /Very unsafe/. In+-- particular, you should do no memory allocation inside an+-- 'inlinePerformIO' block.+--+inlinePerformIO :: IO a -> a+inlinePerformIO (IO m) = case m realWorld# of (# _, r #) -> r+#endif+++-- * Extending EGL+{-+-- * Helper functions+-- | Validate the current internal state.+-- may return EGL_BAD_CONTEXT, EGL_BAD_SURFACE, EGL_BAD_NATIVE_WINDOW,+-- EGL_BAD_CURRENT_SURFACE, EGL_CONTEXT_LOST, EGL_BAD_DISPLAY,+-- EGL_NOT_INITIALIZED+testEGL :: IO EGLError+testEGL = do+  disp <- c_eglGetCurrentDisplay+  cont <- c_eglGetCurrentContext+  draw <- c_eglGetCurrentSurface EGLDraw+  toEglErr (c_eglMakeCurrent disp draw draw cont)+data EGLState a = EGLState (Maybe a) EGLConfig [(EGLSurfAttr, Int)]+eglState = unsafePerformIO $ newIORef (EGLState Nothing) (EGLConfig nullPtr) []++-- | Initialize an EGL Context for OpenGL ES 2.0 (eglGetDefaultDisplay - eglMakeCurrent) +initEGL :: EGLNativeWindow a => a -> [(EGLConfAttr, Int)]+  -> [(EGLSurfAttr, Int)] -> IO EGLError+initEGL win confAttrs surfAttrs = do+  disp <- eglGetDefaultDisplay+  Right (major, minor) <- eglInitialize disp+  Right (config : _) <- eglChooseConfig disp+    ((EGLRenderableType, egl_opengl_es2_bit) : confAttrs)+  -- Request OpenGL ES 2.0++  Right cont <- eglCreateContext disp config [(EGLContextClientVersion, 2)]+  Right surf <- eglCreateWindowSurface disp config win surfAttrs+  eglMakeCurrent disp surf surf cont+  writeIORef eglState $ EGLState win config surfAttrs++-- | Tear down the EGL context in use (eglMakeCurrent - eglTerminate)+termEGL :: IO EGLError+termEGL = do+  disp <- eglGetCurrentDisplay+  cont <- eglGetCurrentContext+  surf <- eglGetCurrentSurface EGLDraw+  either return (\disp -> do+    eglReleaseCurrent disp+    either return (eglDestroyContext disp) cont+    either return (eglDestroySurface disp) surf+    eglTerminate disp+    ) disp++-- | Short hand for eglSwapBuffers+swapCurrentBuffers :: IO EGLError+swapCurrentBuffers = do+  disp <- eglGetCurrentDisplay+  surf <- eglGetCurrentSurface EGLDraw+  err <- either return (\disp -> either return (\surf -> eglSwapBuffers disp surf) surf) disp+  case err of+    EGLSuccess -> return EGLSuccess+    -- still consider context is valid+    EGLBadSurface -> initEGLSurface >> return EGLSuccess where+      initEGLSurface = do+        EGLState win config surfAttrs <- readIORef eglState+        read <- eglGetCurrentSurface EGLRead+        Right surf <- eglCreateWindowSurface disp config win surfAttrs+        Right cont <- eglGetCurrentContext+        eglMakeCurrent disp surf (either (const surf) id read) cont+    -- EGLBadContext | EGLContextLost+    _ -> termEGL >> initEGL win >> return err++-- | Destroy current draw surface+suspendEGL :: IO EGLError+suspendEGL = do+  disp <- eglGetCurrentDisplay+  surf <- eglGetCurrentSurface EGLDraw+  either return (\disp -> either return (eglDestroySurface disp) surf) disp++resumeEGL :: EGLNativeWindow => a -> IO EGLError+resumeEGL win = do+  err <- eglGetCurrentContext+  err' <- case err of+    Left _ -> initEGL win+    Right _ -> initEGLSurface where+      initEGLSurface = do+        Right (config : _) <- eglChooseConfig disp [(EGLRenderableType, egl_opengl_es2_bit)]+        Right cont <- eglGetCurrentContext+        Right surf <- eglCreateWindowSurface disp config win []+        eglMakeCurrent disp surf surf cont +  case err' of+    EGLSuccess -> return ()+    --EGLContextLost -> initEGLContext+    _ -> termEGL >> initEGL win+  return err'+-}+withCurrent :: (EGLError -> IO a) -- ^ Error handler+   -> (EGLDisplay -> EGLContext -> EGLSurface -> EGLSurface -> IO a)+   -- ^ Current Display in use -> Current Context -> Current Read Surface -> Current Draw Surface+   -> IO a+withCurrent f g = do+  disp <- eglGetCurrentDisplay+  cont <- eglGetCurrentContext+  read <- eglGetCurrentSurface EGLRead+  draw <- eglGetCurrentSurface EGLDraw+  either f (\d->+    either f (\c->+      either f (\r->+        either f (\s->+          g d c r s) draw) read) cont) disp++-- * Types+-- from EGL/eglplatform.h+-- ** Window-system-dependent types+type EGLNativeWindowType = Ptr ()+type EGLNativePixmapType = Ptr ()+-- XXX Symbian platform uses int instead of pointer...+type EGLNativeDisplayType = Ptr ()+class EGLNativeWindow a where getNativeWindow :: a -> EGLNativeWindowType+class EGLNativePixmap a where getNativePixmap :: a -> EGLNativePixmapType+class EGLNativeDisplay a where getNativeDisplay :: a -> EGLNativeDisplayType++-- ** EGL Types+-- | 32-bit signed integer+type EGLint = Int++-- from EGL/egl.h+type EGLBoolean = Int -- actually, Word32+type EGLenum = Int -- actually, Word32+type EGLConfig_ = Ptr ()+type EGLContext_ = Ptr ()+type EGLDisplay_ = Ptr ()+type EGLSurface_ = Ptr ()+type EGLClientBuffer_ = Ptr ()+ +newtype EGLConfig = EGLConfig { unC :: EGLConfig_ }+newtype EGLContext = EGLContext { unX :: EGLContext_ }+newtype EGLDisplay = EGLDisplay { unD :: EGLDisplay_ }+newtype EGLSurface = EGLSurface { unS :: EGLSurface_ }+newtype EGLClientBuffer = EGLClientBuffer { unB :: EGLClientBuffer_ }++-- * EGL Functions+-- ccall unsafe: For more efficient code. These C calls do not call Haskell.+foreign import ccall unsafe "EGL/egl.h eglGetError" c_eglGetError :: IO EGLint++foreign import ccall unsafe "EGL/egl.h eglGetDisplay" c_eglGetDisplay :: EGLNativeDisplayType -> IO EGLDisplay_+foreign import ccall unsafe "EGL/egl.h eglInitialize" c_eglInitialize :: EGLDisplay_ -> Ptr EGLint -> Ptr EGLint -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglTerminate" c_eglTerminate :: EGLDisplay_ -> IO EGLBoolean++foreign import ccall unsafe "EGL/egl.h eglQueryString" c_eglQueryString :: EGLDisplay_ -> EGLint -> IO CString++foreign import ccall unsafe "EGL/egl.h eglGetConfigs" c_eglGetConfigs :: EGLDisplay_ -> Ptr EGLConfig_ -> EGLint -> Ptr EGLint -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglChooseConfig" c_eglChooseConfig :: EGLDisplay_ -> Ptr EGLint -> Ptr EGLConfig_ -> EGLint -> Ptr EGLint -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglGetConfigAttrib" c_eglGetConfigAttrib :: EGLDisplay_ -> EGLConfig_ -> EGLint -> Ptr EGLint -> IO EGLBoolean++foreign import ccall unsafe "EGL/egl.h eglCreateWindowSurface" c_eglCreateWindowSurface :: EGLDisplay_ -> EGLConfig_ -> EGLNativeWindowType -> Ptr EGLint -> IO EGLSurface_+foreign import ccall unsafe "EGL/egl.h eglCreatePbufferSurface" c_eglCreatePbufferSurface :: EGLDisplay_ -> EGLConfig_ -> Ptr EGLint -> IO EGLSurface_+foreign import ccall unsafe "EGL/egl.h eglCreatePixmapSurface" c_eglCreatePixmapSurface :: EGLDisplay_ -> EGLConfig_ -> EGLNativePixmapType -> Ptr EGLint -> IO EGLSurface_+foreign import ccall unsafe "EGL/egl.h eglDestroySurface" c_eglDestroySurface :: EGLDisplay_ -> EGLSurface_ -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglQuerySurface" c_eglQuerySurface :: EGLDisplay_ -> EGLSurface_ -> EGLint -> Ptr EGLint -> IO EGLBoolean++foreign import ccall unsafe "EGL/egl.h eglBindAPI" c_eglBindAPI :: EGLenum -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglQueryAPI" c_eglQueryAPI :: IO EGLenum++foreign import ccall unsafe "EGL/egl.h eglWaitClient" c_eglWaitClient :: IO EGLBoolean++foreign import ccall unsafe "EGL/egl.h eglReleaseThread" c_eglReleaseThread :: IO EGLBoolean++foreign import ccall unsafe "EGL/egl.h eglCreatePbufferFromClientBuffer" c_eglCreatePbufferFromClientBuffer :: EGLDisplay_ -> EGLenum -> EGLClientBuffer_ -> EGLConfig_ -> Ptr EGLint -> IO EGLSurface_++foreign import ccall unsafe "EGL/egl.h eglSurfaceAttrib" c_eglSurfaceAttrib :: EGLDisplay_ -> EGLSurface_ -> EGLint -> EGLint -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglBindTexImage" c_eglBindTexImage :: EGLDisplay_ -> EGLSurface_ -> EGLint -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglReleaseTexImage" c_eglReleaseTexImage :: EGLDisplay_ -> EGLSurface_ -> EGLint -> IO EGLBoolean++foreign import ccall unsafe "EGL/egl.h eglSwapInterval" c_eglSwapInterval :: EGLDisplay_ -> EGLint -> IO EGLBoolean++foreign import ccall unsafe "EGL/egl.h eglCreateContext" c_eglCreateContext :: EGLDisplay_ -> EGLConfig_ -> EGLContext_ -> Ptr EGLint -> IO EGLContext_+foreign import ccall unsafe "EGL/egl.h eglDestroyContext" c_eglDestroyContext :: EGLDisplay_ -> EGLContext_ -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglMakeCurrent" c_eglMakeCurrent :: EGLDisplay_ -> EGLSurface_ -> EGLSurface_ -> EGLContext_ -> IO EGLBoolean++foreign import ccall unsafe "EGL/egl.h eglGetCurrentContext" c_eglGetCurrentContext :: IO EGLContext_+foreign import ccall unsafe "EGL/egl.h eglGetCurrentSurface" c_eglGetCurrentSurface :: EGLint -> IO EGLSurface_+foreign import ccall unsafe "EGL/egl.h eglGetCurrentDisplay" c_eglGetCurrentDisplay :: IO EGLDisplay_+foreign import ccall unsafe "EGL/egl.h eglQueryContext" c_eglQueryContext :: EGLDisplay_ -> EGLContext_ -> EGLint -> Ptr EGLint -> IO EGLBoolean++--foreign import ccall unsafe "EGL/egl.h eglWaitGL" c_eglWaitGL :: IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglWaitNative" c_eglWaitNative :: EGLint -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglSwapBuffers" c_eglSwapBuffers :: EGLDisplay_ -> EGLSurface_ -> IO EGLBoolean+foreign import ccall unsafe "EGL/egl.h eglCopyBuffers" c_eglCopyBuffers :: EGLDisplay_ -> EGLSurface_ -> EGLNativePixmapType -> IO EGLBoolean++foreign import ccall unsafe "EGL/egl.h eglGetProcAddress" c_eglGetProcAddress :: CString -> IO (FunPtr a)
+ Graphics/OpenGLES.hs view
@@ -0,0 +1,31 @@+-- | OpenGL ES (ES for Embed Systems) 2.0 and 3.0+-- <http://www.khronos.org/opengles/sdk/docs/reference_cards/OpenGL-ES-2_0-Reference-card.pdf>+-- <http://www.khronos.org/files/opengles3-quick-reference-card.pdf>+-- +-- ANGLE: OpenGL ES 2.0 backend for Windows.+-- <http://code.google.com/p/angleproject/>++module Graphics.OpenGLES (+  module Control.Future,+  module Data.Int,+  module Data.Word,+  module Graphics.OpenGLES.Buffer,+  module Graphics.OpenGLES.Core,+  module Graphics.OpenGLES.State,+  module Graphics.OpenGLES.Texture,+  module Graphics.OpenGLES.Types,+  module Linear.Class,+  module Linear.Vect,+  module Linear.Mat+  ) where+import Control.Future+import Data.Int+import Data.Word+import Graphics.OpenGLES.Buffer+import Graphics.OpenGLES.Core+import Graphics.OpenGLES.State+import Graphics.OpenGLES.Texture+import Graphics.OpenGLES.Types+import Linear.Class+import Linear.Vect+import Linear.Mat
+ Graphics/OpenGLES/Base.hs view
@@ -0,0 +1,808 @@+{-# LANGUAGE CPP #-}+-- | definition from gl3.h+module Graphics.OpenGLES.Base (+	-- * Basic Types+	GL,+	GLName,+	-- ** OpenGL ES 2.0+	GLboolean,+	GLbyte,+	GLubyte,+	GLchar,+	GLshort,+	GLushort,+	GLint,+	GLuint,+	GLfixed,+	GLsizei,+	GLenum,+	GLintptr,+	GLsizeiptr,+	GLbitfield,+	GLfloat,+	GLclampf,+	-- ** OpenGL ES 3.0+	GLint64,+	GLuint64,+	GLsync,+	GLhalf,++	-- * Bindings+	--isGLProcAvailable,++	-- ** OpenGL ES 2.0+	glActiveTexture,+	glAttachShader,+	glBindAttribLocation,+	glBindBuffer,+	glBindFramebuffer,+	glBindRenderbuffer,+	glBindTexture,+	glBlendColor,+	glBlendEquation,+	glBlendEquationSeparate,+	glBlendFunc,+	glBlendFuncSeparate,+	glBufferData,+	glBufferSubData,+	glCheckFramebufferStatus,+	glClear,+	glClearColor,+	glClearDepthf,+	glClearStencil,+	glColorMask,+	glCompileShader,+	glCompressedTexImage2D,+	glCompressedTexSubImage2D,+	glCopyTexImage2D,+	glCopyTexSubImage2D,+	glCreateProgram,+	glCreateShader,+	glCullFace,+	glDeleteBuffers,+	glDeleteFramebuffers,+	glDeleteProgram,+	glDeleteRenderbuffers,+	glDeleteShader,+	glDeleteTextures,+	glDepthFunc,+	glDepthMask,+	glDepthRangef,+	glDetachShader,+	glDisable,+	glDisableVertexAttribArray,+	glDrawArrays,+	glDrawElements,+	glEnable,+	glEnableVertexAttribArray,+	glFinish,+	glFlush,+	glFramebufferRenderbuffer,+	glFramebufferTexture2D,+	glFrontFace,+	glGenBuffers,+	glGenerateMipmap,+	glGenFramebuffers,+	glGenRenderbuffers,+	glGenTextures,+	glGetActiveAttrib,+	glGetActiveUniform,+	glGetAttachedShaders,+	glGetAttribLocation,+	glGetBooleanv,+	glGetBufferParameteriv,+	glGetError,+	glGetFloatv,+	glGetFramebufferAttachmentParameteriv,+	glGetIntegerv,+	glGetProgramiv,+	glGetProgramInfoLog,+	glGetRenderbufferParameteriv,+	glGetShaderiv,+	glGetShaderInfoLog,+	glGetShaderPrecisionFormat,+	glGetShaderSource,+	glGetString,+	glGetTexParameterfv,+	glGetTexParameteriv,+	glGetUniformfv,+	glGetUniformiv,+	glGetUniformLocation,+	glGetVertexAttribfv,+	glGetVertexAttribiv,+	glGetVertexAttribPointerv,+	glHint,+	glIsBuffer,+	glIsEnabled,+	glIsFramebuffer,+	glIsProgram,+	glIsRenderbuffer,+	glIsShader,+	glIsTexture,+	glLineWidth,+	glLinkProgram,+	glPixelStorei,+	glPolygonOffset,+	glReadPixels,+	glReleaseShaderCompiler,+	glRenderbufferStorage,+	glSampleCoverage,+	glScissor,+	glShaderBinary,+	glShaderSource,+	glStencilFunc,+	glStencilFuncSeparate,+	glStencilMask,+	glStencilMaskSeparate,+	glStencilOp,+	glStencilOpSeparate,+	glTexImage2D,+	glTexParameterf,+	glTexParameterfv,+	glTexParameteri,+	glTexParameteriv,+	glTexSubImage2D,+	glUniform1f,+	glUniform1fv,+	glUniform1i,+	glUniform1iv,+	glUniform2f,+	glUniform2fv,+	glUniform2i,+	glUniform2iv,+	glUniform3f,+	glUniform3fv,+	glUniform3i,+	glUniform3iv,+	glUniform4f,+	glUniform4fv,+	glUniform4i,+	glUniform4iv,+	glUniformMatrix2fv,+	glUniformMatrix3fv,+	glUniformMatrix4fv,+	glUseProgram,+	glValidateProgram,+	glVertexAttrib1f,+	glVertexAttrib1fv,+	glVertexAttrib2f,+	glVertexAttrib2fv,+	glVertexAttrib3f,+	glVertexAttrib3fv,+	glVertexAttrib4f,+	glVertexAttrib4fv,+	glVertexAttribPointer,+	glViewport,++	-- ** OpenGL ES 3.0+	glReadBuffer,+	glDrawRangeElements,+	glTexImage3D,+	glTexSubImage3D,+	glCopyTexSubImage3D,+	glCompressedTexImage3D,+	glCompressedTexSubImage3D,+	glGenQueries,+	glDeleteQueries,+	glIsQuery,+	glBeginQuery,+	glEndQuery,+	glGetQueryiv,+	glGetQueryObjectuiv,+	glUnmapBuffer,+	glGetBufferPointerv,+	glDrawBuffers,+	glUniformMatrix2x3fv,+	glUniformMatrix3x2fv,+	glUniformMatrix2x4fv,+	glUniformMatrix4x2fv,+	glUniformMatrix3x4fv,+	glUniformMatrix4x3fv,+	glBlitFramebuffer,+	glRenderbufferStorageMultisample,+	glFramebufferTextureLayer,+	glMapBufferRange,+	glFlushMappedBufferRange,+	glBindVertexArray,+	glDeleteVertexArrays,+	glGenVertexArrays,+	glIsVertexArray,+	glGetIntegeri_v,+	glBeginTransformFeedback,+	glEndTransformFeedback,+	glBindBufferRange,+	glBindBufferBase,+	glTransformFeedbackVaryings,+	glGetTransformFeedbackVarying,+	glVertexAttribIPointer,+	glGetVertexAttribIiv,+	glGetVertexAttribIuiv,+	glVertexAttribI4i,+	glVertexAttribI4ui,+	glVertexAttribI4iv,+	glVertexAttribI4uiv,+	glGetUniformuiv,+	glGetFragDataLocation,+	glUniform1ui,+	glUniform2ui,+	glUniform3ui,+	glUniform4ui,+	glUniform1uiv,+	glUniform2uiv,+	glUniform3uiv,+	glUniform4uiv,+	glClearBufferiv,+	glClearBufferuiv,+	glClearBufferfv,+	glClearBufferfi,+	glGetStringi,+	glCopyBufferSubData,+	glGetUniformIndices,+	glGetActiveUniformsiv,+	glGetUniformBlockIndex,+	glGetActiveUniformBlockiv,+	glGetActiveUniformBlockName,+	glUniformBlockBinding,+	glDrawArraysInstanced,+	glDrawElementsInstanced,+	glFenceSync,+	glIsSync,+	glDeleteSync,+	glClientWaitSync,+	glWaitSync,+	glGetInteger64v,+	glGetSynciv,+	glGetInteger64i_v,+	glGetBufferParameteri64v,+	glGenSamplers,+	glDeleteSamplers,+	glIsSampler,+	glBindSampler,+	glSamplerParameteri,+	glSamplerParameteriv,+	glSamplerParameterf,+	glSamplerParameterfv,+	glGetSamplerParameteriv,+	glGetSamplerParameterfv,+	glVertexAttribDivisor,+	glBindTransformFeedback,+	glDeleteTransformFeedbacks,+	glGenTransformFeedbacks,+	glIsTransformFeedback,+	glPauseTransformFeedback,+	glResumeTransformFeedback,+	glGetProgramBinary,+	glProgramBinary,+	glProgramParameteri,+	glInvalidateFramebuffer,+	glInvalidateSubFramebuffer,+	glTexStorage2D,+	glTexStorage3D,+	glGetInternalformativ,++	-- ** Extensions+	glDrawTexiOES,+	glMultiDrawArraysEXT,+	glMultiDrawElementsEXT,+	glGenVertexArraysOES,+	glBindVertexArrayOES,+	glDeleteVertexArraysOES,+	glIsVertexArrayOES,++	-- ** OpenGL ES 3.1+	glDispatchCompute,+	glDispatchComputeIndirect,+	glDrawArraysIndirect,+	glDrawElementsIndirect,+	glFramebufferParameteri,+	glGetFramebufferParameteriv,+	glGetProgramInterfaceiv,+	glGetProgramResourceIndex,+	glGetProgramResourceName,+	glGetProgramResourceiv,+	glGetProgramResourceLocation,+	glUseProgramStages,+	glActiveShaderProgram,+	glCreateShaderProgramv,+	glBindProgramPipeline,+	glDeleteProgramPipelines,+	glGenProgramPipelines,+	glIsProgramPipeline,+	glGetProgramPipelineiv,+	glProgramUniform1i,+	glProgramUniform2i,+	glProgramUniform3i,+	glProgramUniform4i,+	glProgramUniform1ui,+	glProgramUniform2ui,+	glProgramUniform3ui,+	glProgramUniform4ui,+	glProgramUniform1f,+	glProgramUniform2f,+	glProgramUniform3f,+	glProgramUniform4f,+	glProgramUniform1iv,+	glProgramUniform2iv,+	glProgramUniform3iv,+	glProgramUniform4iv,+	glProgramUniform1uiv,+	glProgramUniform2uiv,+	glProgramUniform3uiv,+	glProgramUniform4uiv,+	glProgramUniform1fv,+	glProgramUniform2fv,+	glProgramUniform3fv,+	glProgramUniform4fv,+	glProgramUniformMatrix2fv,+	glProgramUniformMatrix3fv,+	glProgramUniformMatrix4fv,+	glProgramUniformMatrix2x3fv,+	glProgramUniformMatrix3x2fv,+	glProgramUniformMatrix2x4fv,+	glProgramUniformMatrix4x2fv,+	glProgramUniformMatrix3x4fv,+	glProgramUniformMatrix4x3fv,+	glValidateProgramPipeline,+	glGetProgramPipelineInfoLog,+	glBindImageTexture,+	glGetBooleani_v,+	glMemoryBarrier,+	glMemoryBarrierByRegion,+	glTexStorage2DMultisample,+	glGetMultisamplefv,+	glSampleMaski,+	glGetTexLevelParameteriv,+	glGetTexLevelParameterfv,+	glBindVertexBuffer,+	glVertexAttribFormat,+	glVertexAttribIFormat,+	glVertexAttribBinding,+	glVertexBindingDivisor+	) where+import Foreign+import Foreign.C.String+import Graphics.EGL (eglGetProcAddress)+--XXX unify Wrappers by args+-- * Basic Types++-- | IO actions run in GL thread.+type GL = IO++-- | Name of a shader, program, and variable.+type GLName = String++-- ** OpenGL ES 2.0++-- | 1bit boolean+type GLboolean = Word8++-- | 8bit signed two\'s complement binary integer+type GLbyte = Int8++-- | 8bit unsigned binary integer+type GLubyte = Word8++-- | (Unused) 8bit characters making up strings+type GLchar = Int8++-- | 16bit signed two\'s complement binary integer+type GLshort = Int16++-- | 16bit unsigned binary integer+type GLushort = Word16++-- | 32bit signed two\'s complement binary integer+type GLint = Int32++-- | 32bit unsigned binary integer+type GLuint = Word32++-- | 32bit signed two\'s complement 16.16 scaled integer+type GLfixed = Int32++-- | 32bit non-negative binary integer size+type GLsizei = Int32++-- | 32bit enumerated binary integer value+type GLenum = Word32++-- | Pointer-sized signed two\'s complement binary integer+type GLintptr = Int++-- | Pointer-sized non-negative binary integer size+type GLsizeiptr = Int++-- | 32bit bit field+type GLbitfield = Word32++-- | 32bit floating-point value+type GLfloat = Float++-- | 32bit floating-point value clamped to [0,1]+type GLclampf = Float++-- ** OpenGL ES 3.0++-- | 64bit signed two\'s complement binary integer+type GLint64 = Int64++-- | 64bit unsigned binary integer+type GLuint64 = Word64++-- | Pointer-sized sync object handle+type GLsync = Ptr ()++-- | 16bit half-precision floating-point value encoded in an unsigned scalar+type GLhalf = Word16+++-- * Bindings++{-isGLProcAvailable :: String -> Bool+isGLProcAvailable name = let+	proc = castFunPtrToPtr (eglGetProcAddress name)+	undef = castFunPtrToPtr (eglGetProcAddress "glUndefined")+	in abs (proc `minusPtr` undef) > 0x10000+	-- eglGetProcAddress may return an useless pointer when+	-- given name starts with "gl" but not implemented.+-}+-- Declere must-have functions+#define GLES2(_procname, _typ) \+foreign import ccall unsafe "GLES2/gl2.h" _procname :: _typ; \+--{- avoid inlining to save size # INLINE _procname #-} \++-- Work around for a runtime link error+#define GL_EXT(_procname, _typ) \+foreign import ccall unsafe "dynamic" unwrap_/**/_procname :: FunPtr (_typ) -> _typ; \+_procname :: _typ; \+_procname = unwrap_/**/_procname (eglGetProcAddress "_procname") ; \+{-# NOINLINE _procname #-} \+-- foreign import ccall unsafe "dynamic"+--   unwrap_glActiveTexture :: FunPtr (GLenum -> GL ()) -> GLenum -> GL ();+-- glActiveTexture :: GLenum -> GL ();+-- glActiveTexture = unwrap_glActiveTexture (eglGetProcAddress "glActiveTexture");+++-- Share unwrap_* with a mother function+#define GL_DUP(_procname, _mother, _typ) \+_procname :: _typ; \+_procname = unwrap_/**/_mother (eglGetProcAddress "_procname") ; \+{-# NOINLINE _procname #-} \+++-- ** OpenGL ES 2.0++GLES2(glActiveTexture, GLenum -> GL ())+GLES2(glAttachShader, GLuint -> GLuint -> GL ())+GLES2(glBindAttribLocation, GLuint -> GLuint -> CString -> GL ())+GLES2(glBindBuffer, GLenum -> GLuint -> GL ())+GLES2(glBindFramebuffer, GLenum -> GLuint -> GL ())+GLES2(glBindRenderbuffer, GLenum -> GLuint -> GL ())+GLES2(glBindTexture, GLenum -> GLuint -> GL ())+GLES2(glBlendColor, GLclampf -> GLclampf -> GLclampf -> GLclampf -> GL ())+GLES2(glBlendEquation, GLenum -> GL ())+GLES2(glBlendEquationSeparate, GLenum -> GLenum -> GL ())+GLES2(glBlendFunc, GLenum -> GLenum -> GL ())+GLES2(glBlendFuncSeparate, GLenum -> GLenum -> GLenum -> GLenum -> GL ())+GLES2(glBufferData, GLenum -> GLsizeiptr -> Ptr () -> GLenum -> GL ())+GLES2(glBufferSubData, GLenum -> GLintptr -> GLsizeiptr -> Ptr () -> GL ())+GLES2(glCheckFramebufferStatus, GLenum -> GL GLenum)+GLES2(glClear, GLbitfield -> GL ())+GLES2(glClearColor, GLclampf -> GLclampf -> GLclampf -> GLclampf -> GL ())+GLES2(glClearDepthf, GLclampf -> GL ())+GLES2(glClearStencil, GLint -> GL ())+GLES2(glColorMask, GLboolean -> GLboolean -> GLboolean -> GLboolean -> GL ())+GLES2(glCompileShader, GLuint -> GL ())+--GLES2(glCompressedTexImage2D, GLenum -> GLint -> GLenum -> GLsizei -> GLsizei -> GLint -> GLsizei -> Ptr () -> GL ())+GLES2(glCompressedTexImage2D, GLenum -> GLint -> GLenum -> GLuint -> GLuint -> GLint -> GLsizei -> CString -> GL ())+GLES2(glCompressedTexSubImage2D, GLenum -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GLenum -> GLsizei -> Ptr () -> GL ())+GLES2(glCopyTexImage2D, GLenum -> GLint -> GLenum -> GLint -> GLint -> GLsizei -> GLsizei -> GLint -> GL ())+GLES2(glCopyTexSubImage2D, GLenum -> GLint -> GLint -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GL ())+GLES2(glCreateProgram, GL GLuint)+GLES2(glCreateShader, GLenum -> GL GLuint)+GLES2(glCullFace, GLenum -> GL ())+GLES2(glDeleteBuffers, GLsizei -> Ptr GLuint -> GL ())+GLES2(glDeleteFramebuffers, GLsizei -> Ptr GLuint -> GL ())+GLES2(glDeleteProgram, GLuint -> GL ())+GLES2(glDeleteRenderbuffers, GLsizei -> Ptr GLuint -> GL ())+GLES2(glDeleteShader, GLuint -> GL ())+GLES2(glDeleteTextures, GLsizei -> Ptr GLuint -> GL ())+GLES2(glDepthFunc, GLenum -> GL ())+GLES2(glDepthMask, GLboolean -> GL ())+GLES2(glDepthRangef, GLclampf -> GLclampf -> GL ())+GLES2(glDetachShader, GLuint -> GLuint -> GL ())+GLES2(glDisable, GLenum -> GL ())+GLES2(glDisableVertexAttribArray, GLuint -> GL ())+GLES2(glDrawArrays, GLenum -> GLint -> GLsizei -> GL ())+GLES2(glDrawElements, GLenum -> GLsizei -> GLenum -> Ptr () -> GL ())+GLES2(glEnable, GLenum -> GL ())+GLES2(glEnableVertexAttribArray, GLuint -> GL ())+GLES2(glFinish, GL ())+GLES2(glFlush, GL ())+GLES2(glFramebufferRenderbuffer, GLenum -> GLenum -> GLenum -> GLuint -> GL ())+GLES2(glFramebufferTexture2D, GLenum -> GLenum -> GLenum -> GLuint -> GLint -> GL ())+GLES2(glFrontFace, GLenum -> GL ())+GLES2(glGenBuffers, GLsizei -> Ptr GLuint -> GL ())+GLES2(glGenerateMipmap, GLenum -> GL ())+GLES2(glGenFramebuffers, GLsizei -> Ptr GLuint -> GL ())+GLES2(glGenRenderbuffers, GLsizei -> Ptr GLuint -> GL ())+GLES2(glGenTextures, GLsizei -> Ptr GLuint -> GL ())+GLES2(glGetActiveAttrib, GLuint -> GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLint -> Ptr GLenum -> CString -> GL ())+GLES2(glGetActiveUniform, GLuint -> GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLint -> Ptr GLenum -> CString -> GL ())+GLES2(glGetAttachedShaders, GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLuint -> GL ())+GLES2(glGetAttribLocation, GLuint -> CString -> GL GLint)+GLES2(glGetBooleanv, GLenum -> Ptr GLboolean -> GL ())+GLES2(glGetBufferParameteriv, GLenum -> GLenum -> Ptr GLint -> GL ())+GLES2(glGetError, GL GLenum)+GLES2(glGetFloatv, GLenum -> Ptr GLfloat -> GL ())+GLES2(glGetFramebufferAttachmentParameteriv, GLenum -> GLenum -> GLenum -> Ptr GLint -> GL ())+GLES2(glGetIntegerv, GLenum -> Ptr GLint -> GL ())+GLES2(glGetProgramiv, GLuint -> GLenum -> Ptr GLint -> GL ())+GLES2(glGetProgramInfoLog, GLuint -> GLsizei -> Ptr GLsizei -> CString -> GL ())+GLES2(glGetRenderbufferParameteriv, GLenum -> GLenum -> Ptr GLint -> GL ())+GLES2(glGetShaderiv, GLuint -> GLenum -> Ptr GLint -> GL ())+GLES2(glGetShaderInfoLog, GLuint -> GLsizei -> Ptr GLsizei -> CString -> GL ())+GLES2(glGetShaderPrecisionFormat, GLenum -> GLenum -> Ptr GLint -> Ptr GLint -> GL ())+GLES2(glGetShaderSource, GLuint -> GLsizei -> Ptr GLsizei -> CString -> GL ())+GLES2(glGetString, GLenum -> GL CString)+GLES2(glGetTexParameterfv, GLenum -> GLenum -> Ptr GLfloat -> GL ())+GLES2(glGetTexParameteriv, GLenum -> GLenum -> Ptr GLint -> GL ())+GLES2(glGetUniformfv, GLuint -> GLint -> Ptr GLfloat -> GL ())+GLES2(glGetUniformiv, GLuint -> GLint -> Ptr GLint -> GL ())+GLES2(glGetUniformLocation, GLuint -> CString -> GL GLint)+GLES2(glGetVertexAttribfv, GLuint -> GLenum -> Ptr GLfloat -> GL ())+GLES2(glGetVertexAttribiv, GLuint -> GLenum -> Ptr GLint -> GL ())+GLES2(glGetVertexAttribPointerv, GLuint -> GLenum -> Ptr (Ptr ()) -> GL ())+GLES2(glHint, GLenum -> GLenum -> GL ())+GLES2(glIsBuffer, GLuint -> GL GLboolean)+GLES2(glIsEnabled, GLenum -> GL GLboolean)+GLES2(glIsFramebuffer, GLuint -> GL GLboolean)+GLES2(glIsProgram, GLuint -> GL GLboolean)+GLES2(glIsRenderbuffer, GLuint -> GL GLboolean)+GLES2(glIsShader, GLuint -> GL GLboolean)+GLES2(glIsTexture, GLuint -> GL GLboolean)+GLES2(glLineWidth, GLfloat -> GL ())+GLES2(glLinkProgram, GLuint -> GL ())+GLES2(glPixelStorei, GLenum -> GLint -> GL ())+GLES2(glPolygonOffset, GLfloat -> GLfloat -> GL ())+GLES2(glReadPixels, GLint -> GLint -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr () -> GL ())+GLES2(glReleaseShaderCompiler, GL ())+GLES2(glRenderbufferStorage, GLenum -> GLenum -> GLsizei -> GLsizei -> GL ())+GLES2(glSampleCoverage, GLclampf -> GLboolean -> GL ())+GLES2(glScissor, GLint -> GLint -> GLsizei -> GLsizei -> GL ())+GLES2(glShaderBinary, GLsizei -> Ptr GLuint -> GLenum -> Ptr () -> GLsizei -> GL ())+GLES2(glShaderSource, GLuint -> GLsizei -> Ptr CString -> Ptr GLint -> GL ())+GLES2(glStencilFunc, GLenum -> GLint -> GLuint -> GL ())+GLES2(glStencilFuncSeparate, GLenum -> GLenum -> GLint -> GLuint -> GL ())+GLES2(glStencilMask, GLuint -> GL ())+GLES2(glStencilMaskSeparate, GLenum -> GLuint -> GL ())+GLES2(glStencilOp, GLenum -> GLenum -> GLenum -> GL ())+GLES2(glStencilOpSeparate, GLenum -> GLenum -> GLenum -> GLenum -> GL ())+-- GLES2(glTexImage2D, GLenum -> GLint -> GLint -> GLsizei -> GLsizei -> GLint -> GLenum -> GLenum -> Ptr () -> GL ())+GLES2(glTexImage2D, GLenum -> GLint -> GLenum -> GLuint -> GLuint -> GLint -> GLenum -> GLenum -> CString -> GL ())+GLES2(glTexParameterf, GLenum -> GLenum -> GLfloat -> GL ())+GLES2(glTexParameterfv, GLenum -> GLenum -> Ptr GLfloat -> GL ())+GLES2(glTexParameteri, GLenum -> GLenum -> GLint -> GL ())+GLES2(glTexParameteriv, GLenum -> GLenum -> Ptr GLint -> GL ())+GLES2(glTexSubImage2D, GLenum -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr () -> GL ())+GLES2(glUniform1f, GLint -> GLfloat -> GL ())+GLES2(glUniform1fv, GLint -> GLsizei -> Ptr GLfloat -> GL ())+GLES2(glUniform1i, GLint -> GLint -> GL ())+GLES2(glUniform1iv, GLint -> GLsizei -> Ptr GLint -> GL ())+GLES2(glUniform2f, GLint -> GLfloat -> GLfloat -> GL ())+GLES2(glUniform2fv, GLint -> GLsizei -> Ptr GLfloat -> GL ())+GLES2(glUniform2i, GLint -> GLint -> GLint -> GL ())+GLES2(glUniform2iv, GLint -> GLsizei -> Ptr GLint -> GL ())+GLES2(glUniform3f, GLint -> GLfloat -> GLfloat -> GLfloat -> GL ())+GLES2(glUniform3fv, GLint -> GLsizei -> Ptr GLfloat -> GL ())+GLES2(glUniform3i, GLint -> GLint -> GLint -> GLint -> GL ())+GLES2(glUniform3iv, GLint -> GLsizei -> Ptr GLint -> GL ())+GLES2(glUniform4f, GLint -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> GL ())+GLES2(glUniform4fv, GLint -> GLsizei -> Ptr GLfloat -> GL ())+GLES2(glUniform4i, GLint -> GLint -> GLint -> GLint -> GLint -> GL ())+GLES2(glUniform4iv, GLint -> GLsizei -> Ptr GLint -> GL ())+GLES2(glUniformMatrix2fv, GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GLES2(glUniformMatrix3fv, GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GLES2(glUniformMatrix4fv, GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GLES2(glUseProgram, GLuint -> GL ())+GLES2(glValidateProgram, GLuint -> GL ())+GLES2(glVertexAttrib1f, GLuint -> GLfloat -> GL ())+GLES2(glVertexAttrib1fv, GLuint -> Ptr GLfloat -> GL ())+GLES2(glVertexAttrib2f, GLuint -> GLfloat -> GLfloat -> GL ())+GLES2(glVertexAttrib2fv, GLuint -> Ptr GLfloat -> GL ())+GLES2(glVertexAttrib3f, GLuint -> GLfloat -> GLfloat -> GLfloat -> GL ())+GLES2(glVertexAttrib3fv, GLuint -> Ptr GLfloat -> GL ())+GLES2(glVertexAttrib4f, GLuint -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> GL ())+GLES2(glVertexAttrib4fv, GLuint -> Ptr GLfloat -> GL ())+GLES2(glVertexAttribPointer, GLuint -> GLint -> GLenum -> GLboolean -> GLsizei -> Ptr () -> GL ())+GLES2(glViewport, GLint -> GLint -> GLsizei -> GLsizei -> GL ())++-- ** OpenGL ES 3.0++GL_EXT(glReadBuffer, GLenum -> GL ())+GL_EXT(glDrawRangeElements, GLenum -> GLuint -> GLuint -> GLsizei -> GLenum -> Ptr (()) -> GL ())+--GL_EXT(glTexImage3D, GLenum -> GLint -> GLint -> GLsizei -> GLsizei -> GLsizei -> GLint -> GLenum -> GLenum -> Ptr () -> GL ())+GL_EXT(glTexImage3D, GLenum -> GLint -> GLenum -> GLuint -> GLuint -> GLuint -> GLint -> GLenum -> GLenum -> CString -> GL ())+GL_EXT(glTexSubImage3D, GLenum -> GLint -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr () -> GL ())+GL_EXT(glCopyTexSubImage3D, GLenum -> GLint -> GLint -> GLint -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GL ())+--GL_EXT(glCompressedTexImage3D, GLenum -> GLint -> GLenum -> GLsizei -> GLsizei -> GLsizei -> GLint -> GLsizei -> Ptr () -> GL ())+GL_EXT(glCompressedTexImage3D, GLenum -> GLint -> GLenum -> GLuint -> GLuint -> GLuint -> GLint -> GLsizei -> CString -> GL ())+GL_EXT(glCompressedTexSubImage3D, GLenum -> GLint -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GLsizei -> GLenum -> GLsizei -> Ptr () -> GL ())+GL_EXT(glGenQueries, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glDeleteQueries, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glIsQuery, GLuint -> GL GLboolean)+GL_EXT(glBeginQuery, GLenum -> GLuint -> GL ())+GL_EXT(glEndQuery, GLenum -> GL ())+GL_EXT(glGetQueryiv, GLenum -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glGetQueryObjectuiv, GLuint -> GLenum -> Ptr GLuint -> GL ())+GL_EXT(glUnmapBuffer, GLenum -> GL GLboolean)+GL_EXT(glGetBufferPointerv, GLenum -> GLenum -> Ptr (Ptr ()) -> GL ())+GL_EXT(glDrawBuffers, GLsizei -> Ptr GLenum -> GL ())+GL_EXT(glUniformMatrix2x3fv, GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glUniformMatrix3x2fv, GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glUniformMatrix2x4fv, GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glUniformMatrix4x2fv, GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glUniformMatrix3x4fv, GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glUniformMatrix4x3fv, GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glBlitFramebuffer, GLint -> GLint -> GLint -> GLint -> GLint -> GLint -> GLint -> GLint -> GLbitfield -> GLenum -> GL ())+GL_EXT(glRenderbufferStorageMultisample, GLenum -> GLsizei -> GLenum -> GLsizei -> GLsizei -> GL ())+GL_EXT(glFramebufferTextureLayer, GLenum -> GLenum -> GLuint -> GLint -> GLint -> GL ())+GL_EXT(glMapBufferRange, GLenum -> GLintptr -> GLsizeiptr -> GLbitfield -> GL (Ptr ()))+GL_EXT(glFlushMappedBufferRange, GLenum -> GLintptr -> GLsizeiptr -> GL ())+GL_EXT(glBindVertexArray, GLuint -> GL ())+GL_EXT(glDeleteVertexArrays, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glGenVertexArrays, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glIsVertexArray, GLuint -> GL GLboolean)+GL_EXT(glGetIntegeri_v, GLenum -> GLuint -> Ptr GLint -> GL ())+GL_EXT(glBeginTransformFeedback, GLenum -> GL ())+GL_EXT(glEndTransformFeedback, GL ())+GL_EXT(glBindBufferRange, GLenum -> GLuint -> GLuint -> GLintptr -> GLsizeiptr -> GL ())+GL_EXT(glBindBufferBase, GLenum -> GLuint -> GLuint -> GL ())+GL_EXT(glTransformFeedbackVaryings, GLuint -> GLsizei -> Ptr CString -> GLenum -> GL ())+GL_EXT(glGetTransformFeedbackVarying, GLuint -> GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLsizei -> Ptr GLenum -> CString -> GL ())+GL_EXT(glVertexAttribIPointer, GLuint -> GLint -> GLenum -> GLsizei -> Ptr () -> GL ())+GL_EXT(glGetVertexAttribIiv, GLuint -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glGetVertexAttribIuiv, GLuint -> GLenum -> Ptr GLuint -> GL ())+GL_EXT(glVertexAttribI4i, GLuint -> GLint -> GLint -> GLint -> GLint -> GL ())+GL_EXT(glVertexAttribI4ui, GLuint -> GLuint -> GLuint -> GLuint -> GLuint -> GL ())+GL_EXT(glVertexAttribI4iv, GLuint -> Ptr GLint -> GL ())+GL_EXT(glVertexAttribI4uiv, GLuint -> Ptr GLuint -> GL ())+GL_EXT(glGetUniformuiv, GLuint -> GLint -> Ptr GLuint -> GL ())+GL_EXT(glGetFragDataLocation, GLuint -> CString-> GL GLint)+GL_EXT(glUniform1ui, GLint -> GLuint -> GL ())+GL_EXT(glUniform2ui, GLint -> GLuint -> GLuint -> GL ())+GL_EXT(glUniform3ui, GLint -> GLuint -> GLuint -> GLuint -> GL ())+GL_EXT(glUniform4ui, GLint -> GLuint -> GLuint -> GLuint -> GLuint -> GL ())+GL_EXT(glUniform1uiv, GLint -> GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glUniform2uiv, GLint -> GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glUniform3uiv, GLint -> GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glUniform4uiv, GLint -> GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glClearBufferiv, GLenum -> GLint -> Ptr GLint -> GL ())+GL_EXT(glClearBufferuiv, GLenum -> GLint -> Ptr GLuint -> GL ())+GL_EXT(glClearBufferfv, GLenum -> GLint -> Ptr GLfloat -> GL ())+GL_EXT(glClearBufferfi, GLenum -> GLint -> GLfloat -> GLint -> GL ())+GL_EXT(glGetStringi, GLenum -> GLuint -> GL CString)+GL_EXT(glCopyBufferSubData, GLenum -> GLenum -> GLintptr -> GLintptr -> GLsizeiptr -> GL ())+GL_EXT(glGetUniformIndices, GLuint -> GLsizei -> Ptr CString -> Ptr GLuint -> GL ())+GL_EXT(glGetActiveUniformsiv, GLuint -> GLsizei -> Ptr GLuint -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glGetUniformBlockIndex, GLuint -> CString -> GL GLuint)+GL_EXT(glGetActiveUniformBlockiv, GLuint -> GLuint -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glGetActiveUniformBlockName, GLuint -> GLuint -> GLsizei -> Ptr GLsizei -> CString -> GL ())+GL_EXT(glUniformBlockBinding, GLuint -> GLuint -> GLuint -> GL ())+GL_EXT(glDrawArraysInstanced, GLenum -> GLint -> GLsizei -> GLsizei -> GL ())+GL_EXT(glDrawElementsInstanced, GLenum -> GLsizei -> GLenum -> Ptr () -> GLsizei -> GL ())+GL_EXT(glFenceSync, GLenum -> GLbitfield -> GL GLsync)+GL_EXT(glIsSync, GLsync -> GL GLboolean)+GL_EXT(glDeleteSync, GLsync -> GL ())+GL_EXT(glClientWaitSync, GLsync -> GLbitfield -> GLuint64 -> GL GLenum)+GL_EXT(glWaitSync, GLsync -> GLbitfield -> GLuint64 -> GL ())+GL_EXT(glGetInteger64v, GLenum -> Ptr GLint64 -> GL ())+GL_EXT(glGetSynciv, GLsync -> GLenum -> GLsizei -> Ptr GLsizei -> Ptr GLint -> GL ())+GL_EXT(glGetInteger64i_v, GLenum -> GLuint -> Ptr GLint64 -> GL ())+GL_EXT(glGetBufferParameteri64v, GLenum -> GLenum -> Ptr GLint64 -> GL ())+GL_EXT(glGenSamplers, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glDeleteSamplers, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glIsSampler, GLuint -> GL GLboolean)+GL_EXT(glBindSampler, GLuint -> GLuint -> GL ())+GL_EXT(glSamplerParameteri, GLuint -> GLenum -> GLint -> GL ())+GL_EXT(glSamplerParameteriv, GLuint -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glSamplerParameterf, GLuint -> GLenum -> GLfloat -> GL ())+GL_EXT(glSamplerParameterfv, GLuint -> GLenum -> Ptr GLfloat -> GL ())+GL_EXT(glGetSamplerParameteriv, GLuint -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glGetSamplerParameterfv, GLuint -> GLenum -> Ptr GLfloat -> GL ())+GL_EXT(glVertexAttribDivisor, GLuint -> GLuint -> GL ())+GL_EXT(glBindTransformFeedback, GLenum -> GLuint -> GL ())+GL_EXT(glDeleteTransformFeedbacks, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glGenTransformFeedbacks, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glIsTransformFeedback, GLuint -> GL GLboolean)+GL_EXT(glPauseTransformFeedback, GL ())+GL_EXT(glResumeTransformFeedback, GL ())+GL_EXT(glGetProgramBinary, GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLenum -> Ptr () -> GL ())+GL_EXT(glProgramBinary, GLuint -> GLenum -> Ptr () -> GLsizei -> GL ())+GL_EXT(glProgramParameteri, GLuint -> GLenum -> GLint -> GL ())+GL_EXT(glInvalidateFramebuffer, GLenum -> GLsizei -> Ptr GLenum -> GL ())+GL_EXT(glInvalidateSubFramebuffer, GLenum -> GLsizei -> Ptr GLenum -> GLint -> GLint -> GLsizei -> GLsizei -> GL ())+GL_EXT(glTexStorage2D, GLenum -> GLsizei -> GLenum -> GLsizei -> GLsizei -> GL ())+GL_EXT(glTexStorage3D, GLenum -> GLsizei -> GLenum -> GLsizei -> GLsizei -> GLsizei -> GL ())+GL_EXT(glGetInternalformativ, GLenum -> GLenum -> GLenum -> GLsizei -> Ptr GLint -> GL ())++-- ** Extensions++GL_EXT(glDrawTexiOES, GLint -> GLint -> GLint -> GLint -> GLint -> GL ())+GL_EXT(glMultiDrawArraysEXT, GLenum -> Ptr GLint -> Ptr GLsizei -> GLsizei -> GL ())+GL_EXT(glMultiDrawElementsEXT, GLenum -> Ptr GLsizei -> GLenum -> Ptr (Ptr ()) -> GLsizei -> GL ())+GL_DUP(glBindVertexArrayOES,glBindVertexArray, GLuint -> GL ())+GL_DUP(glDeleteVertexArraysOES,glDeleteVertexArrays, GLsizei -> Ptr GLuint -> GL ())+GL_DUP(glGenVertexArraysOES,glGenVertexArrays, GLsizei -> Ptr GLuint -> GL ())+GL_DUP(glIsVertexArrayOES,glIsVertexArray, GLuint -> GL GLboolean)++-- ** OpenGL ES 3.1++GL_EXT(glDispatchCompute, GLuint -> GLuint -> GLuint -> GL ())+GL_EXT(glDispatchComputeIndirect, GLintptr -> GL ())+GL_EXT(glDrawArraysIndirect, GLenum -> Ptr () -> GL ())+GL_EXT(glDrawElementsIndirect, GLenum -> GLenum -> Ptr () -> GL ())+GL_EXT(glFramebufferParameteri, GLenum -> GLenum -> GLint -> GL ())+GL_EXT(glGetFramebufferParameteriv, GLenum -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glGetProgramInterfaceiv, GLuint -> GLenum -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glGetProgramResourceIndex, GLuint -> GLenum -> Ptr GLchar -> GL ())+GL_EXT(glGetProgramResourceName, GLuint -> GLenum -> GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLchar -> GL ())+GL_EXT(glGetProgramResourceiv, GLuint -> GLenum -> GLuint -> GLsizei -> Ptr GLenum -> GLsizei -> Ptr GLsizei -> Ptr GLint -> GL ())+GL_EXT(glGetProgramResourceLocation, GLuint -> GLenum -> Ptr GLchar -> GL ())+GL_EXT(glUseProgramStages, GLuint -> GLbitfield -> GLuint -> GL ())+GL_EXT(glActiveShaderProgram, GLuint -> GLuint -> GL ())+GL_EXT(glCreateShaderProgramv, GLenum -> GLsizei -> Ptr CString -> GL ())+GL_EXT(glBindProgramPipeline, GLuint -> GL ())+GL_EXT(glDeleteProgramPipelines, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glGenProgramPipelines, GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glIsProgramPipeline, GLuint -> GL ())+GL_EXT(glGetProgramPipelineiv, GLuint -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glProgramUniform1i, GLuint -> GLint -> GLint -> GL ())+GL_EXT(glProgramUniform2i, GLuint -> GLint -> GLint -> GLint -> GL ())+GL_EXT(glProgramUniform3i, GLuint -> GLint -> GLint -> GLint -> GLint -> GL ())+GL_EXT(glProgramUniform4i, GLuint -> GLint -> GLint -> GLint -> GLint -> GLint -> GL ())+GL_EXT(glProgramUniform1ui, GLuint -> GLint -> GLuint -> GL ())+GL_EXT(glProgramUniform2ui, GLuint -> GLint -> GLuint -> GLuint -> GL ())+GL_EXT(glProgramUniform3ui, GLuint -> GLint -> GLuint -> GLuint -> GLuint -> GL ())+GL_EXT(glProgramUniform4ui, GLuint -> GLint -> GLuint -> GLuint -> GLuint -> GLuint -> GL ())+GL_EXT(glProgramUniform1f, GLuint -> GLint -> GLfloat -> GL ())+GL_EXT(glProgramUniform2f, GLuint -> GLint -> GLfloat -> GLfloat -> GL ())+GL_EXT(glProgramUniform3f, GLuint -> GLint -> GLfloat -> GLfloat -> GLfloat -> GL ())+GL_EXT(glProgramUniform4f, GLuint -> GLint -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> GL ())+GL_EXT(glProgramUniform1iv, GLuint -> GLint -> GLsizei -> Ptr GLint -> GL ())+GL_EXT(glProgramUniform2iv, GLuint -> GLint -> GLsizei -> Ptr GLint -> GL ())+GL_EXT(glProgramUniform3iv, GLuint -> GLint -> GLsizei -> Ptr GLint -> GL ())+GL_EXT(glProgramUniform4iv, GLuint -> GLint -> GLsizei -> Ptr GLint -> GL ())+GL_EXT(glProgramUniform1uiv, GLuint -> GLint -> GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glProgramUniform2uiv, GLuint -> GLint -> GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glProgramUniform3uiv, GLuint -> GLint -> GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glProgramUniform4uiv, GLuint -> GLint -> GLsizei -> Ptr GLuint -> GL ())+GL_EXT(glProgramUniform1fv, GLuint -> GLint -> GLsizei -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniform2fv, GLuint -> GLint -> GLsizei -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniform3fv, GLuint -> GLint -> GLsizei -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniform4fv, GLuint -> GLint -> GLsizei -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniformMatrix2fv, GLuint -> GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniformMatrix3fv, GLuint -> GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniformMatrix4fv, GLuint -> GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniformMatrix2x3fv, GLuint -> GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniformMatrix3x2fv, GLuint -> GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniformMatrix2x4fv, GLuint -> GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniformMatrix4x2fv, GLuint -> GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniformMatrix3x4fv, GLuint -> GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glProgramUniformMatrix4x3fv, GLuint -> GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+GL_EXT(glValidateProgramPipeline, GLuint -> GL ())+GL_EXT(glGetProgramPipelineInfoLog, GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLchar -> GL ())+GL_EXT(glBindImageTexture, GLuint -> GLuint -> GLint -> GLboolean -> GLint -> GLenum -> GLenum -> GL ())+GL_EXT(glGetBooleani_v, GLenum -> GLuint -> Ptr GLboolean -> GL ())+GL_EXT(glMemoryBarrier, GLbitfield -> GL ())+GL_EXT(glMemoryBarrierByRegion, GLbitfield -> GL ())+GL_EXT(glTexStorage2DMultisample, GLenum -> GLsizei -> GLenum -> GLsizei -> GLsizei -> GLboolean -> GL ())+GL_EXT(glGetMultisamplefv, GLenum -> GLuint -> Ptr GLfloat -> GL ())+GL_EXT(glSampleMaski, GLuint -> GLbitfield -> GL ())+GL_EXT(glGetTexLevelParameteriv, GLenum -> GLint -> GLenum -> Ptr GLint -> GL ())+GL_EXT(glGetTexLevelParameterfv, GLenum -> GLint -> GLenum -> Ptr GLfloat -> GL ())+GL_EXT(glBindVertexBuffer, GLuint -> GLuint -> GLintptr -> GLsizei -> GL ())+GL_EXT(glVertexAttribFormat, GLuint -> GLint -> GLenum -> GLboolean -> GLuint -> GL ())+GL_EXT(glVertexAttribIFormat, GLuint -> GLint -> GLenum -> GLuint -> GL ())+GL_EXT(glVertexAttribBinding, GLuint -> GLuint -> GL ())+GL_EXT(glVertexBindingDivisor, GLuint -> GLuint -> GL ())
+ Graphics/OpenGLES/Buffer.hs view
@@ -0,0 +1,205 @@+{-# LANGUAGE ScopedTypeVariables #-}+module Graphics.OpenGLES.Buffer (+  -- * Buffer+  -- ** Constructing Mutable Buffers+  Buffer,+  glNewBuffer, glLoadList, glLoadBS,+  -- ** Updating Mutable Buffers+  unsafeObtainStorableArray, withStorableArraySize,+  glRenewBuffer, glReloadList, glReloadBS,+  BufferUsage, app2gl, app2glDyn, app2glStream,+  gl2app, gl2appDyn, gl2appStream, gl2gl, gl2glDyn, gl2glStream,+  -- ** Raw Buffer Operations+  bindBuffer, bindBufferRange, bindBufferBase,+  bufferData, bufferSubData, +  -- | /3+ | GL_OES_mapbuffer/ glUnmapBufferOES+  unmapBuffer,+  -- | /GL_OES_mapbuffer/+  -- (*GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);+  -- define GL_WRITE_ONLY_OES                 0x88B9+  -- | /3+ | GL_EXT_map_buffer_range/+  -- glMapBufferRangeEXT glFlushMappedBufferRangeEXT+  mapBufferRange, flashMappedBufferRange,+  map_read_bit, map_write_bit, map_invalidate_range_bit,+  map_invalidate_buffer_bit, map_flush_explicit_bit, map_unsynchronized_bit,+  -- | /3+ | GL_NV_copy_buffer/ glCopyBufferSubDataNV+  copyBufferSubData,+  BufferSlot, array_buffer, element_array_buffer,+  pixel_pack_buffer, pixel_unpack_buffer,+  uniform_buffer, transform_feedback_buffer,+  copy_read_buffer, copy_write_buffer+  ) where+import Control.Applicative+import Data.Array.Base (getNumElements)+import Data.Array.Storable+import Data.Array.Storable.Internals+import qualified Data.ByteString as B+import qualified Data.ByteString.Internal as B+import Data.IORef+import Graphics.OpenGLES.Base+import Graphics.OpenGLES.Internal+import Foreign++-- ** Constructing Mutable Buffers++glNewBuffer :: forall a. Storable a => BufferUsage -> Int -> GL (Buffer a)+glNewBuffer usage elems = do+	array <- newArray_ (0, elems)+	glo <- newBuffer+	bufferData array_buffer usage (elems * sizeOf (undefined :: a)) nullPtr+	Buffer usage glo <$> newIORef array++glLoadList+	:: forall a. Storable a => BufferUsage+	-> (Int, Int)+	-> [a]+	-> GL (Buffer a)+glLoadList usage ix xs = do+	array <- newListArray ix xs+	glo <- newBuffer+	withStorableArraySize array $ \size ptr ->+		bufferData array_buffer usage size ptr+	Buffer usage glo <$> newIORef array++glLoadBS :: forall a. Storable a => BufferUsage -> B.ByteString -> GL (Buffer a)+glLoadBS usage bs@(B.PS foreignPtr offset len) = do+	let fp | offset == 0 = foreignPtr+	       | otherwise = case B.copy bs of (B.PS f _ _) -> f+	let elems = (len `div` sizeOf (undefined :: a))+	let array = StorableArray 0 (elems-1) elems (castForeignPtr fp)+	glo <- newBuffer+	withForeignPtr fp $ \ptr ->+		bufferData array_buffer usage len ptr+	Buffer usage glo <$> newIORef array+++-- ** Updating Mutable Buffers+++unsafeObtainStorableArray :: Buffer a -> IO (StorableArray Int a)+unsafeObtainStorableArray (Buffer _ _ arr) = readIORef arr++withStorableArraySize+	:: forall i e a. Storable e+	=> StorableArray i e -> (Int -> Ptr e -> IO a) -> IO a+withStorableArraySize (StorableArray _ _ n fp) f =+	withForeignPtr fp (f size)+	where size = n * sizeOf (undefined :: e)++-- Performance hint http://www.opentk.com/node/1930+glRenewBuffer :: forall a. Storable a => BufferUsage -> Int -> Buffer a -> GL ()+glRenewBuffer usage elems buf@(Buffer _ _ ref) = do+	array <- newArray_ (0, elems)+	bindBuffer array_buffer buf+	bufferData array_buffer usage (elems * sizeOf (undefined :: a)) nullPtr+	writeIORef ref array++glReloadList :: forall a. Storable a =>+	BufferUsage -> (Int, Int) -> [a] -> Buffer a -> GL ()+glReloadList usage ix xs buf@(Buffer _ _ ref) = do+	array <- newListArray ix xs+	bindBuffer array_buffer buf+	withStorableArraySize array $ \size ptr -> do+		bufferData array_buffer usage size ptr+	writeIORef ref array++glReloadBS :: forall a. Storable a =>+	BufferUsage -> B.ByteString -> Buffer a -> GL ()+glReloadBS usage bs@(B.PS foreignPtr offset len) buf = do+	let fp | offset == 0 = foreignPtr+	       | otherwise = case B.copy bs of (B.PS f _ _) -> f+	let elems = (len `div` sizeOf (undefined :: a))+	let array = StorableArray 0 (elems-1) elems (castForeignPtr fp)+	withForeignPtr fp $ \ptr -> do+		--bufferData array_buffer usage 0 nullPtr+		bufferData array_buffer usage len ptr+++-- ** Buffer Slots++-- | STATIC_DRAW (Default)+app2gl = BufferUsage 0x88E4+-- | DYNAMIC_DRAW+app2glDyn = BufferUsage 0x88E8+-- | STREAM_DRAW+app2glStream = BufferUsage 0x88E0+-- *** GL ES 3++-- | STATIC_READ+gl2app = BufferUsage 0x88E5+-- | DYNAMIC_READ+gl2appDyn = BufferUsage 0x88E9+-- | STREAM_READ+gl2appStream = BufferUsage 0x88E1+-- | STATIC_COPY+gl2gl = BufferUsage 0x88E6+-- | DYNAMIC_COPY+gl2glDyn = BufferUsage 0x88EA+-- | STREAM_COPY+gl2glStream = BufferUsage 0x88E2+++-- ** Raw Buffer Operations++bindBuffer :: BufferSlot -> Buffer a -> GL ()+bindBuffer (BufferSlot target) (Buffer _ glo _) =+	glBindBuffer target . fst =<< readIORef glo++bindBufferRange :: BufferSlot -> GLuint -> Buffer a -> Int -> Int -> GL ()+bindBufferRange (BufferSlot t) index (Buffer _ glo _) offset size = do+	buf <- fmap fst $ readIORef glo+	glBindBufferRange t index buf offset size++bindBufferBase :: BufferSlot -> GLuint -> Buffer a -> GL ()+bindBufferBase (BufferSlot t) index (Buffer _ glo _) = do+	glBindBufferBase t index . fst =<< readIORef glo++bufferData :: BufferSlot -> BufferUsage -> Int -> Ptr a -> GL ()+bufferData (BufferSlot target) (BufferUsage usage) size ptr =+	glBufferData target size (castPtr ptr) usage++bufferSubData :: BufferSlot -> Int -> Int -> Ptr a -> GL ()+bufferSubData (BufferSlot target) offset size ptr =+	glBufferSubData target offset size (castPtr ptr)++-- *** 3+ | GL_OES_mapbuffer glUnmapBufferOES+unmapBuffer :: BufferSlot -> GL Bool+unmapBuffer (BufferSlot target) =+	glUnmapBuffer target >>= return . (/= 0)++-- *** GL_OES_mapbuffer +-- (*GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);+-- define GL_WRITE_ONLY_OES                 0x88B9++-- *** 3+ | GL_EXT_map_buffer_range+-- glMapBufferRangeEXT glFlushMappedBufferRangeEXT+mapBufferRange :: BufferSlot -> Int -> Int -> GLbitfield -> GL (Ptr a)+mapBufferRange (BufferSlot target) offset size access =+	fmap castPtr $ glMapBufferRange target offset size access++flashMappedBufferRange :: BufferSlot -> Int -> Int -> GL ()+flashMappedBufferRange (BufferSlot target) offset size =+	glFlushMappedBufferRange target offset size++map_read_bit = 1 :: GLbitfield+map_write_bit = 2 :: GLbitfield+map_invalidate_range_bit = 4 :: GLbitfield+map_invalidate_buffer_bit = 8 :: GLbitfield+map_flush_explicit_bit = 16 :: GLbitfield+map_unsynchronized_bit = 32 :: GLbitfield++-- *** 3+ | GL_NV_copy_buffer glCopyBufferSubDataNV+copyBufferSubData :: BufferSlot -> BufferSlot -> Int -> Int -> Int -> GL ()+copyBufferSubData (BufferSlot read) (BufferSlot write) roffset woffset size =+	glCopyBufferSubData read write roffset woffset size++array_buffer = BufferSlot 0x8892+element_array_buffer = BufferSlot 0x8893+-- *** 3++pixel_pack_buffer = BufferSlot 0x88EB+pixel_unpack_buffer = BufferSlot 0x88EC+uniform_buffer = BufferSlot 0x8A11+transform_feedback_buffer = BufferSlot 0x8C8E+-- *** 3+ | GL_NV_copy_buffer+copy_read_buffer = BufferSlot 0x8F36+copy_write_buffer = BufferSlot 0x8F37+
+ Graphics/OpenGLES/Core.hs view
@@ -0,0 +1,437 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  Graphics.OpenGLES.Core+-- Copyright   :  (c) capsjac 2014+-- License     :  LGPL-3 (see the file LICENSE)+-- +-- The neat and easy to use wrapper for OpenGL EmbedSystems (ES).+-- The wrapper is optimised for mobile and have small footprint.+-- Assuming OpenGL ES 2.0 or any later version, however, also works+-- with OpenGL 4.1/4.3+ on desktop.+--+-----------------------------------------------------------------------------++{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE ScopedTypeVariables #-}++module Graphics.OpenGLES.Core (+  GL,+  -- * Lifecycle+  forkGL, stopGL, --destroyGL,+  endFrameGL, runGL, --runGLRes+  withGL, resetDrawQueue,+  glLog, glReadLogs, glLogContents,+  flushCommandQ, finishCommands,+  +  -- * Draw Operation+  -- ** Clear Screen+  clear, ClearBufferMask,+  depthBuffer, stencilBuffer, colorBuffer,+  +  -- ** Draw+  glDraw,++  -- ** Draw Mode+  DrawMode, drawPoints, drawLines,+  drawLineLoop, drawLineStrip,+  drawTriangles, triangleStrip, triangleFan,++  -- ** Graphics State+  GraphicsState,++  -- ** Programmable Shader+  Shader, vertexShader, fragmentShader, pixelShader,+  computeShader, geometryShader,+  tessellationEvalS, tessellationCtrlS,+  Program,+  TransformFeedback(..), ProgramBinary,+  glCompile, glValidate,+  +  -- ** Uniform Variable+  Uniform, uniform, ($=), UnifVal, UniformAssignment,+  +  -- ** Vertex Attribute Array+  Attrib, attrib, normalized, divisor, (&=),+  VertexArray, glVA,+  ShaderAttribute, AttrStruct, SetVertexAttr,+  +  -- ** Constant Vertex Attribute+  constAttrib,+  +  -- ** Texture+  -- | See "Graphics.OpenGLES.Texture"++  -- ** Vertex Picker+  VertexPicker, takeFrom,+  takeFromInstanced, takeFromMany,+  VertexIx, byIndex, byIndexInstanced,+  byIndices, byIndexLimited,+  drawCallSequence+  ) where+import Control.Applicative+import Control.Monad+import Control.Concurrent (forkOS, ThreadId, myThreadId, killThread)+import Control.Concurrent.Chan+import Control.Exception (catch, SomeException)+import Control.Future+import qualified Data.ByteString as B+import Data.IORef+import Data.Typeable+import Foreign+import Foreign.C.String (peekCString, peekCStringLen)+import Graphics.OpenGLES.Base+import Graphics.OpenGLES.Buffer+import Graphics.OpenGLES.Env+import Graphics.OpenGLES.Internal+import Graphics.OpenGLES.Types+++-- * Initialization++forkGL+	:: IO Bool+	-> GL ()+	-> GL ()+	-> IO ThreadId+forkGL resumeGL suspendGL swapBuffers = forkOS $ do+	writeIORef drawOrExit (Just swapBuffers)+	resumeGL -- Note: implicit glFlush here+	putStrLn "bindEGL"+	-- glRestoreLostObjects+	let loop count = do+		putStrLn $ "start draw " ++ show count+		readChan drawQueue >>= id+		loop (count + 1)+	catch (loop 0) $ \(e :: SomeException) -> do+		glLog $ "Rendering thread terminated: " ++ show e+		suspendGL+		putStrLn "unbindEGL"+		writeIORef drawOrExit (Just (glLog "Fatal lifecycle bug"))++stopGL :: IO ()+stopGL = do+	putStrLn "stopGL"+	writeIORef drawOrExit Nothing+	let waitGLThread = readIORef drawOrExit >>= \case+		Just _ -> nop+		Nothing -> waitGLThread+	waitGLThread+	putStrLn "Rendering has stopped."++--destroyGL :: IO ()+--destroyGL = runGL $ eglMakeCurrent Nothing, eglDestroyXXX ...++endFrameGL :: IO ()+endFrameGL = withGL go >>= waitFuture >> nop+	where go = do+		readIORef drawOrExit >>= \case+			Just eglSwapBuffer -> eglSwapBuffer+			Nothing -> myThreadId >>= killThread++runGL :: GL () -> IO ()+runGL io = writeChan drawQueue io++--runGLRes :: GL () -> IO ()+--runGLRes io = forkOS++withGL :: GL a -> IO (Future' a)+withGL io = asyncIO $ \update -> runGL (io >>= update . Finished)++-- | drawQueue may have drawcalls that use previous context,+-- so make it sure they are removed from the queue.+resetDrawQueue :: IO ()+resetDrawQueue = do+	empty <- isEmptyChan drawQueue+	when (not empty) (readChan drawQueue >> resetDrawQueue)++glReadLogs :: IO [String]+glReadLogs = do+	empty <- isEmptyChan errorQueue+	if empty+		then return []+		else (:) <$> readChan errorQueue <*> glReadLogs++glLogContents :: IO [String]+glLogContents = getChanContents errorQueue++flushCommandQ :: IO ()+flushCommandQ = runGL glFlush++finishCommands :: IO ()+finishCommands = runGL glFinish++-- | @return ()@+nop :: Monad m => m ()+nop = return ()+++-- * Drawing++-- |+-- > clear [] colorBuffer+-- > clear [bindFramebuffer buf] (colorBuffer+depthBuffer)+clear+	:: [GraphicsState]+	-> ClearBufferMask+	-> GL ()+clear gs (ClearBufferMask flags) = sequence gs >> glClear flags++depthBuffer = ClearBufferMask 0x100+stencilBuffer = ClearBufferMask 0x400+colorBuffer = ClearBufferMask 0x4000++glDraw :: Typeable p+	=> DrawMode+	-> Program p+	-> [GraphicsState]+	-> [UniformAssignment p]+	-> VertexArray p+	-> VertexPicker+	-> GL Bool+glDraw (DrawMode mode) prog@(Program pobj _ _ _) setState unifs+		(VertexArray (vao, setVA)) (VertexPicker picker) = do+	glUseProgram . fst =<< readIORef pobj+	sequence setState+	sequence unifs+	case extVAO of+		Nothing -> setVA+		Just (_, bind, _) -> readIORef vao >>= bind . fst+	--glValidate prog+	picker mode++-- | See "Graphics.OpenGLES.State"+type GraphicsState = GL ()+++-- ** Draw Mode++drawPoints = DrawMode 0+drawLines = DrawMode 1+drawLineLoop = DrawMode 2+drawLineStrip = DrawMode 3+drawTriangles = DrawMode 4+triangleStrip = DrawMode 5+triangleFan = DrawMode 6+++-- ** Programmable Shader++vertexShader, fragmentShader, pixelShader,+	computeShader, geometryShader,+	tessellationEvalS, tessellationCtrlS+	:: GLName -> B.ByteString -> Shader+vertexShader = Shader 0x8B31+fragmentShader = Shader 0x8B30+-- | Same as 'fragmentShader'+pixelShader = fragmentShader+-- | Compute shader requires /ES3.1+/+computeShader = Shader 0x91B9+-- | Geometry shader requires /GL_EXT_geometry_shader (ES3.1)/+geometryShader = Shader 0x8DD9+-- | Tessellation Shader requires /GL_EXT_tessellation_shader (ES3.1)/+tessellationEvalS = Shader 0x8E87+-- | Tessellation Shader requires /GL_EXT_tessellation_shader (ES3.1)/+tessellationCtrlS = Shader 0x8E88+++glCompile+	:: Typeable p+	=> TransformFeedback+	-> [Shader]+	-> (Program p -> Int -> String -> Maybe ProgramBinary -> GL ())+	-> GL (Progress [String] (Program p))+glCompile tf shaders progressLogger = do+	glo <- newIORef undefined+	let prog = Program glo tf shaders ([],[])+	loadProgram prog (progressLogger prog)++-- | glValidateProgram checks to see whether the executables contained in+-- program can execute given the current OpenGL state.+glValidate :: Program p -> GL String+glValidate prog = alloca $ \intptr -> do+	(pid, _) <- readIORef $ programGLO prog+	glValidateProgram pid+	glGetProgramiv pid c_info_log_length intptr+	len <- fmap fromIntegral $ peek intptr+	info <- allocaBytes len $ \buf -> do+		glGetProgramInfoLog pid (fromIntegral len) nullPtr buf+		peekCStringLen (buf, len-1)+	glLog $ "validateProgram: " ++ info+	return info+++-- ** Uniform Variable++type UniformAssignment p = GL ()++uniform+	:: forall p a. (UnifVal a, Typeable p)+	=> GLName -> IO (Uniform p a)+uniform name = do+	desc <- lookupVarDesc typ+	case desc of+		Nothing -> return $ Uniform (-1, 0, nullPtr)+		Just (unifs, _) ->+			case lookup name unifs of+				Just unif -> validateType unif+				Nothing -> glLog errmsg >> return (Uniform (-1, 0, nullPtr))+	where+		typ = typeRep (undefined :: Program p)+		errmsg = "Uniform not found: " ++ name ++ " (" ++ show typ ++ ")"+		validateType (loc, size, gltyp) = do+			-- Prevent drawtime allocation (it leaks, though)+			ptr <- mallocArray (fromIntegral size) :: IO (Ptr Float)+			return $ Uniform (loc, size, castPtr ptr)++($=) :: UnifVal a => Uniform p a -> a -> UniformAssignment p+Uniform desc $= value = glUniform desc value+++-- ** Vertex Attribute++-- normalized color `divisor` 1 &= buffer+attrib+	:: forall p a. (ShaderAttribute a, Typeable p)+	=> GLName -> IO (Attrib p a)+attrib name = do+	desc <- lookupVarDesc typ+	case desc of+		Nothing -> return $ Attrib (-1, 0, 0, 0)+		Just (_, attrs) ->+			case lookup name attrs of+				Just attr -> validateType attr+				Nothing -> glLog errmsg >> return (Attrib (-1, 0, 0, 0))+	where+		typ = typeRep (undefined :: Program p)+		errmsg = "Attribute not found: " ++ name ++ " (" ++ show typ ++ ")"+		validateType (loc, size, gltyp) =+			return $ Attrib (fromIntegral loc, size, 0, 0)++normalized :: Attrib p a -> Attrib p a+normalized (Attrib (i, s, 0, d)) = Attrib (i, s, 1, d)+normalized _ = error "inapplicable use of 'normalized'"++divisor :: Attrib p a -> Word32 -> Attrib p a+divisor (Attrib (i, s, n, _)) d = Attrib (i, s, n, d)++type SetVertexAttr p = GL ()++(&=) :: AttrStruct b a p => a -> Buffer b -> SetVertexAttr p+attrib &= buf = do+	bindBuffer array_buffer buf+	glVertexAttribPtr attrib buf+++glVA :: [SetVertexAttr p] -> GL (VertexArray p)+glVA attrs = do+	let setVA = sequence_ attrs+	glo <- case extVAO of+		Nothing -> return (error "GLO not used")+		Just (gen, bind, del) ->+			newGLO gen bind del <* setVA+	return $ VertexArray (glo, setVA)+++-- ** Constant Vertex Attribute++constAttrib :: ShaderAttribute a => Attrib p a -> a -> SetVertexAttr p+constAttrib (Attrib (idx, s, n, d)) val = do+	glDisableVertexAttribArray idx+	glVertexAttrib idx val++--withConstAttr :: Attrib p a -> GL b -> GL b+--withConstAttr (Attrib (idx, _, _, _)) io = do+--	glDisableVertexAttribArray idx+--	result <- io+--	glEnableVertexAttribArray idx+++-- ** Texture+data Texture = Texture Int32+instance UnifVal Texture where+	glUniform unif (Texture i) = glUniform unif i+++-- ** Vertex Picker++-- Wrapping glDrawArrays+takeFrom :: Int32 -> Int32 -> VertexPicker+takeFrom first count =+	VertexPicker $ \mode -> do+		glDrawArrays mode first count+		showError "glDrawArrays"++-- Wrapping glDrawArraysInstanced[EXT]+takeFromInstanced :: Int32 -> Int32 -> Int32 -> VertexPicker+takeFromInstanced first count numInstances =+	VertexPicker $ \mode -> do+		glDrawArraysInstanced mode first count numInstances+		showError "glDrawArraysInstanced"++-- Wrapping glMultiDrawArraysEXT+takeFromMany :: [(Int32, Int32)] -> VertexPicker+takeFromMany list =+	VertexPicker $ \mode -> do+		forM_ list $ \(first, count) -> do+			glDrawArrays mode first count+			showError "glDrawArrays[]"+		--	showError "glMultiDrawElementsEXT"+		return True+-- TakeFromManyRaw (Buffer Int32) (Buffer Word32)++sizePtr :: Int32 -> Ptr ()+sizePtr = intPtrToPtr . fromIntegral++-- Wrapping glDrawElements+byIndex :: VertexIx a => (Buffer a) -> Int32 -> Int32 -> VertexPicker+byIndex buf first count =+	let (typ, stride) = vxix buf in+	VertexPicker $ \mode -> do+		bindBuffer element_array_buffer buf+		glDrawElements mode count typ (sizePtr $ first * stride)+		showError "glDrawElements"++-- Wrapping glDrawElementsInstanced[EXT]+byIndexInstanced :: VertexIx a => (Buffer a) -> Int32 -> Int32 -> Int32 -> VertexPicker+byIndexInstanced buf first count instances =+	let (typ, stride) = vxix buf in+	VertexPicker $ \mode -> do+		bindBuffer element_array_buffer buf+		glDrawElementsInstanced mode count typ+			(sizePtr $ first * stride) instances+		showError "glDrawElementsInstanced"++-- Wrapping glMultiDrawElementsEXT+byIndices :: VertexIx a => (Buffer a) -> [(Int32, Int32)] -> VertexPicker+byIndices buf list =+	let (typ, stride) = vxix buf in+	VertexPicker $ \mode -> do+		bindBuffer element_array_buffer buf+		forM_ list $ \(first, count) -> do+			glDrawElements mode count typ (sizePtr $ first * stride)+			showError "glDrawElements[]"+		return True+		--withFirstCountArray list $ \cptr iptr clen -> do+		--	glMultiDrawElementsEXT mode cptr typ iptr (clen * stride)+		--	showError "glMultiDrawElementsEXT"+-- ByIndicesRaw (Buffer w) (Buffer Word32) (Buffer Word32)++-- Wrapping glDrawRangeElements[EXT]+byIndexLimited :: VertexIx a => (Buffer a) -> Int32 -> Int32 -> Word32 -> Word32 -> VertexPicker+byIndexLimited buf first count min max =+	let (typ, stride) = vxix buf in+	VertexPicker $ \mode -> do+		bindBuffer element_array_buffer buf+		glDrawElements mode count typ (sizePtr $ first * stride)+		showError "glDrawElements'"+		--showError "glDrawRangeElements[EXT]"+-- FromToIndexRaw !BufferRef !Int !Int !GLsizei !GLenum !Int++drawCallSequence :: [VertexPicker] -> VertexPicker+drawCallSequence xs =+	VertexPicker $ \mode ->+		mapM_ (\(VertexPicker f) -> f mode) xs >> return True++
+ Graphics/OpenGLES/Env.hs view
@@ -0,0 +1,386 @@+-- | Retriving implementation depend constant values.+-- Do NOT call below APIs out of OpenGL threads.+-- (glGetString could return null pointer!)+module Graphics.OpenGLES.Env where+import Foreign+import Foreign.C.String+import Graphics.OpenGLES.Base+import System.IO.Unsafe (unsafePerformIO)++-- * Extension detection++{-# NOINLINE glExtensions #-}+glExtensions :: [String]+glExtensions = unsafePerformIO $+	glGetString 0x1F03 >>= peekCString >>= return.words++{-# NOINLINE hasExt #-}+hasExt :: String -> Bool+hasExt ext = ext `elem` glExtensions+--hasExt :: CString -> Bool+--glGetString 0x1F03 >>= indexOf ext /= -1++hasES3 :: Bool+hasES3 = glEnv majorVersion > 2++extVAO :: Maybe (GLsizei -> Ptr GLuint -> GL (),+	GLuint -> GL (),+	GLsizei -> Ptr GLuint -> GL ())+extVAO | hasES3 =+		Just (glGenVertexArrays, glBindVertexArray, glDeleteVertexArrays)+        | hasExt "GL_OES_vertex_array_object" =+		Just (glGenVertexArraysOES, glBindVertexArrayOES, glDeleteVertexArraysOES)+        | otherwise = Nothing+++-- * String Parameters++glVendor, glRenderer, glVersion, glShadingLanguageVersion :: String+glVendor = unsafePerformIO $ glGetString 0x1F00 >>= peekCString+glRenderer = unsafePerformIO $ glGetString 0x1F01 >>= peekCString+glVersion = unsafePerformIO $ glGetString 0x1F02 >>= peekCString+glShadingLanguageVersion = unsafePerformIO $ glGetString 0x8B8C >>= peekCString+++-- * Integer Parameters++newtype GLParam = GLParam GLenum+-- glGetBooleanv glGetFloatv glGetIntegerv glGetInteger64v+-- glGetBooleani_v glGetIntegeri_v glGetInteger64i_v+-- As of 3.1, 188 + ext parameters are queriable.++--void glGetInteger64v( 	GLenum pname,+--  	GLint64 * data);+--void glGetBooleani_v( 	GLenum target,+--  	GLuint index,+--  	GLboolean * data);+-- GL_INVALID_ENUM is generated if pname is not an accepted value.++-- ??? add failure value?+glEnv :: GLParam -> Int32+glEnv (GLParam param) = unsafePerformIO $+	with 0 $ \ptr -> glGetIntegerv param ptr >> peek ptr++-- !!! add version for ES3+ or Ext, copy desc from man, least value for each version++majorVersion, minorVersion, numExtensions,+	numProgramBinaryFormats :: GLParam++{-+GL_MAX_3D_TEXTURE_SIZE++    params returns one value, a rough estimate of the largest 3D texture that the GL can handle. The value must be at least 256. See glTexImage3D.+GL_MAX_ARRAY_TEXTURE_LAYERS++    params returns one value. The value indicates the maximum number of layers allowed in an array texture, and must be at least 256. See glTexImage2D.+GL_MAX_AtomicCounter_BUFFER_BINDINGS++    params returns one value, the maximum number of atomic counter buffer binding points. The value must be at least 1. See glBindBuffer, glBindBufferBase, and glBindBufferRange.+GL_MAX_COLOR_ATTACHMENTS++    params returns one value, the maximum number of color attachment points in a framebuffer object. The value must be at least 4. See glFramebufferRenderbuffer and glFramebufferTexture2D.+GL_MAX_COMBINED_FRAGMENT_UniformCOMPONENTS++    params returns one value, the number of words for fragment shader uniform variables in all uniform blocks (including default). The value must be at least GL_MAX_FRAGMENT_UniformCOMPONENTS + GL_MAX_UNIFORM_BLOCK_SIZE * GL_MAX_FRAGMENT_UNIFORM_BLOCKS / 4. See glUniform.+GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS++    params returns one value, the maximum supported texture image units that can be used to access texture maps from the vertex shader and the fragment processor combined. If both the vertex shader and the fragment processing stage access the same texture image unit, then that counts as using two texture image units against this limit. The value must be at least 32. See glActiveTexture.+GL_MAX_COMBINED_UNIFORM_BLOCKS++    params returns one value, the maximum number of uniform blocks per program. The value must be at least 24. See glUniformBlockBinding.+GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS++    params returns one value, the number of words for vertex shader uniform variables in all uniform blocks (including default). The value must be at least . GL_MAX_VERTEX_UNIFORM_COMPONENTS + GL_MAX_UNIFORM_BLOCK_SIZE * GL_MAX_VERTEX_UNIFORM_BLOCKS / 4. See glUniform.+GL_MAX_CUBE_MAP_TEXTURE_SIZE++    params returns one value. The value gives a rough estimate of the largest cube-map texture that the GL can handle. The value must be at least 2048. See glTexImage2D.+GL_MAX_DRAW_BUFFERS++    params returns one value, the maximum number of simultaneous outputs that may be written in a fragment shader. The value must be at least 4. See glDrawBuffers.+GL_MAX_ELEMENT_INDEX++    params returns one value, the maximum index supported by the implementation. The value must be at least 2 24 - 1 .+GL_MAX_ELEMENTS_INDICES++    params returns one value, the recommended maximum number of vertex array indices. See glDrawRangeElements.+GL_MAX_ELEMENTS_VERTICES++    params returns one value, the recommended maximum number of vertex array vertices. See glDrawRangeElements.+GL_MAX_FRAGMENT_INPUT_COMPONENTS++    params returns one value, the maximum number of components of the inputs read by the fragment shader, which must be at least 60.+GL_MAX_FRAGMENT_UNIFORM_BLOCKS++    params returns one value, the maximum number of uniform blocks per fragment shader. The value must be at least 12. See glUniformBlockBinding.+GL_MAX_FRAGMENT_UNIFORM_COMPONENTS++    params returns one value, the maximum number of individual floating-point, integer, or boolean values that can be held in uniform variable storage for a fragment shader. The value must be at least 896. See glUniform.+GL_MAX_FRAGMENT_UNIFORM_VECTORS++    params returns one value, the maximum number of vector floating-point, integer, or boolean values that can be held in uniform variable storage for a fragment shader. The value must be at least 224. See glUniform.+GL_MAX_PROGRAM_TEXEL_OFFSET++    params returns one value, the maximum texel offset allowed in a texture lookup, which must be at least 7.+GL_MAX_RENDERBUFFER_SIZE++    params returns one value. The value indicates the maximum supported size for renderbuffers and must be at least 2048. See glFramebufferRenderbuffer.+GL_MAX_SAMPLE_MASK_WORDS++    params returns one value, the maximum number of sample mask words.+GL_MAX_SAMPLES++    params returns one value. The value indicates the maximum supported number of samples for multisampling. The value must be at least 4. See glGetInternalformativ.+GL_MAX_SERVER_WAIT_TIMEOUT++    params returns one value, the maximum glWaitSync timeout interval.+GL_MAX_SHADER_STORAGE_BLOCK_SIZE++    params returns one value, the maximum size in basic machine units of a shader storage block. The value must be at least 2 27 .+GL_MAX_TEXTURE_IMAGE_UNITS++    params returns one value, the maximum supported texture image units that can be used to access texture maps from the fragment shader. The value must be at least 16. See glActiveTexture.+GL_MAX_TEXTURE_LOD_BIAS++    params returns one value, the maximum, absolute value of the texture level-of-detail bias. The value must be at least 2.0.+GL_MAX_TEXTURE_SIZE++    params returns one value. The value gives a rough estimate of the largest texture that the GL can handle. The value must be at least 2048. See glTexImage2D.+GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS++    params returns one value, the maximum number of components which can be written to a single transform feedback buffer in interleaved mode. The value must be at least 64. See glTransformFeedbackVaryings.+GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS++    params returns one value, the maximum separate attributes or outputs which can be captured in separate transform feedback mode. The value must be at least 4. See glTransformFeedbackVaryings.+GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS++    params returns one value, the maximum number of components which can be written per attribute or output in separate transform feedback mode. The value must be at least 4. See glTransformFeedbackVaryings.+GL_MAX_UNIFORM_BLOCK_SIZE++    params returns one value, the maximum size in basic machine units of a uniform block. The value must be at least 16384. See glUniformBlockBinding.+GL_MAX_UNIFORM_BUFFER_BINDINGS++    params returns one value, the maximum number of uniform buffer binding points on the context, which must be at least 24.+GL_MAX_VARYING_COMPONENTS++    params returns one value, the number components for varying variables, which must be at least 60.+GL_MAX_VARYING_VECTORS++    params returns one value, the maximum number of interpolators available for processing varying variables used by vertex and fragment shaders. This value represents the number of vector values that can be interpolated; varying variables declared as matrices and arrays will consume multiple interpolators. The value must be at least 15.+GL_MAX_VERTEX_ATTRIBS++    params returns one value, the maximum number of 4-component generic vertex attributes accessible to a vertex shader. The value must be at least 16. See glVertexAttrib.+GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS++    params returns one value, the maximum supported texture image units that can be used to access texture maps from the vertex shader. The value may be at least 16. See glActiveTexture.+GL_MAX_VERTEX_OUTPUT_COMPONENTS++    params returns one value, the maximum number of components of output written by a vertex shader, which must be at least 64.+GL_MAX_VERTEX_UNIFORM_BLOCKS++    params returns one value, the maximum number of uniform blocks per vertex shader. The value must be at least 12. See glUniformBlockBinding.+GL_MAX_VERTEX_UNIFORM_COMPONENTS++    params returns one value, the maximum number of individual floating-point, integer, or boolean values that can be held in uniform variable storage for a vertex shader. The value must be at least 1024. See glUniform.+GL_MAX_VERTEX_UNIFORM_VECTORS++    params returns one value, the maximum number of vector floating-point, integer, or boolean values that can be held in uniform variable storage for a vertex shader. The value must be at least 256. See glUniform.+GL_MIN_PROGRAM_TEXEL_OFFSET++    params returns one value, the minimum texel offset allowed in a texture lookup, which must be at most -8.+-}++-- ** Since ES 2.0++-- | the number of available compressed texture formats.+-- The minimum value is 0-10-10.+numCompressedTextureFormats = GLParam 0x86A2++-- | The number of available shader binary formats.+-- The minimum value is 0-0-0.+-- Note: Not supported on most platforms.+numShaderBinaryFormats = GLParam 0x8DF9+++-- ** Since ES 3.0++-- | The major version number of the OpenGL ES API supported by the+-- current context. Note: ES 2 does not support this param thus returns 0.+-- (ES2 -> 0, ES3 and ES3_1 -> 3)+majorVersion = GLParam 0x821B++-- | The minor version number of the OpenGL ES API supported by the+-- current context. (ES3 -> 0, ES3_1 -> 1)+minorVersion = GLParam 0x821C++-- | The number of extensions supported by the GL implementation for the current+-- context.+numExtensions = GLParam 0x821D++-- | __GL_OES_get_program_binary or ES3+__+-- The number of available program binary formats.+-- If the value is 0, program binary is not available.+-- The minimum value is X-0-0+numProgramBinaryFormats = GLParam 0x87FE+++-- ** Since ES 3.1++-- | The maximum number of uniform blocks per compute shader. The value must be at least 14. See glUniformBlockBinding.+maxComputeUniformBlocks = GLParam 0x91BB++-- | The maximum supported texture image units that can be used to access texture maps from the compute shader. The value may be at least 16. See glActiveTexture.+maxComputeTextureImageUnits = GLParam 0x91BC++-- | The maximum number of image variables in compute shaders. The value must be at least 8.+maxComputeImageUniforms = GLParam 0x91BD++-- | +maxComputeSharedMemorySize = GLParam 0x8262++-- | The maximum number of individual floating-point, integer, or boolean values that can be held in uniform variable storage for a compute shader. The value must be at least 1024. See glUniform.+maxComputeUniformComponents = GLParam 0x8263++-- | The maximum number of atomic counter buffers that may be accessed by a compute shader.+maxComputeAtomicCounterBuffers = GLParam 0x8264++-- | The maximum number of atomic counters available to compute shaders.+maxComputeAtomicCounters = GLParam 0x8265++-- | The number of words for compute shader uniform variables in all uniform blocks (including default). The value must be at least 1. See glUniform.+maxCombinedComputeUniformComponents = GLParam 0x8266++-- | The number of invocations in a single local work group (i.e., the product of the three dimensions) that may be dispatched to a compute shader.+maxComputeWorkGroupInvocations = GLParam 0x90EB++-- -- | The maximum number of work groups that may be dispatched to a compute shader. Indices 0, 1, and 2 correspond to the X, Y and Z dimensions, respectively.+-- maxComputeWorkGroupCount = GLParamIx? 0x91BE++-- -- | The maximum size of a work groups that may be used during compilation of a compute shader. Indices 0, 1, and 2 correspond to the X, Y and Z dimensions, respectively.+-- maxComputeWorkGroupSize = GLParamXYZ? 0x91BF++-- | The maximum number of explicitly assignable uniform locations, which must be at least 1024.+maxUniformLocations = GLParam 0x826E++-- | The maximum width for a framebuffer that has no attachments, which must be at least 16384. See glFramebufferParameteri.+maxFramebufferWidth = GLParam 0x9315++-- | The maximum height for a framebuffer that has no attachments, which must be at least 16384. See glFramebufferParameteri.+maxFramebufferHeight = GLParam 0x9316++-- | The maximum samples in a framebuffer that has no attachments, which must be at least 4. See glFramebufferParameteri.+maxFramebufferSamples = GLParam 0x9318++-- |+maxVertexAtomicCounterBuffers = GLParam 0x92CC++-- |+maxFragmentAtomicCountersBuffers = GLParam 0x92D0++-- |+maxCombinedAtomicCountersBuffers = GLParam 0x92D1++-- | The maximum number of atomic counters available to vertex shaders.+maxVertexAtomicCounters = GLParam 0x92D2++-- | The maximum number of atomic counters available to fragment shaders.+maxFragmentAtomicCounters = GLParam 0x92D6++-- | The maximum number of atomic counters available to all active shaders.+maxCombinedAtomicCounters = GLParam 0x92D7++-- |+maxAtomicCounterBufferSize = GLParam 0x92D8++-- |+maxAtomicCounterBufferBindings = GLParam 0x92DC++-- |+maxImageUnits = GLParam 0x8F38++-- |+maxVertexImageUniforms = GLParam 0x90CA++-- |+maxFragmentImageUniforms = GLParam 0x90CE++-- |+maxCombinedImageUniforms = GLParam 0x90CF++-- | The maximum number of active shader storage blocks that may be accessed by a vertex shader.+maxVertexShaderStorageBlocks = GLParam 0x90D6++-- | The maximum number of active shader storage blocks that may be accessed by a fragment shader.+maxFragmentShaderStorageBlocks = GLParam 0x90DA++-- | The maximum number of active shader storage blocks that may be accessed by a compute shader.+maxComputeShaderStorageBlocks = GLParam 0x90DB++-- | The maximum total number of active shader storage blocks that may be accessed by all active shaders.+maxCombinedShaderStorageBlocks = GLParam 0x90DC++-- | The maximum number of shader storage buffer binding points on the context, which must be at least 8.+maxShaderStorageBufferBindings = GLParam 0x90DD++-- |+maxShaderStorageBlockSize = GLParam 0x90DE++-- |+maxCombinedShaderOutputResources = GLParam 0x8F39++-- |+minProgramTextureGatherOffset = GLParam 0x8E5E++-- |+maxProgramTextureGatherOffset = GLParam 0x8E5F++-- | +maxSampleMaskWords = GLParam 0x8E59++-- | The maximum number of samples in a color multisample texture.+maxColorTextureSamples = GLParam 0x910E++-- | +maxDepthTextureSamples = GLParam 0x910F++-- | The maximum number of samples supported in integer format multisample buffers.+maxIntegerSamples = GLParam 0x9110++-- | The maximum offset that may be added to a vertex binding offset.+maxVertexAttribRelativeOffset = GLParam 0x82D9++-- | The maximum number of vertex buffers that may be bound.+maxVertexAttribBindings = GLParam 0x82DA++-- | /Undocumented constant/, perhaps /does not exist?/+maxVertexAttribStride = GLParam 0x82E5+++-- * Ranged Parameters (since ES 2.0)++newtype GLParamP = GLParamP GLenum++glPair :: GLParamP -> (Float, Float)+glPair (GLParamP param) = unsafePerformIO $+	with (0 :: Double) $ \ptr -> do+		let p = castPtr ptr+		glGetFloatv param p+		r1 <- peek p+		r2 <- peekByteOff p 4+		return (r1, r2)++aliasedPointSizeRange, aliasedLineWidthRange, maxViewportDims :: GLParamP++-- | The (smallest, largest) supported sizes for points.+-- The smallest size must be \<= 1, and the largest size must be \>= 1.+aliasedPointSizeRange = GLParamP 0x846D++-- | The range of widths supported for aliased lines.+aliasedLineWidthRange = GLParamP 0x846E++-- | The maximum supported width and height of the viewport.+-- These must be at least as large as the visible dimensions of the display+-- being rendered to.+maxViewportDims = GLParamP 0x0D3A++-- Ext+--MAX_TEXTURE_MAX_ANISOTROPY_EXT      0x84FF
+ Graphics/OpenGLES/Internal.hs view
@@ -0,0 +1,450 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE FunctionalDependencies #-}+module Graphics.OpenGLES.Internal where+import Control.Applicative+import Control.Monad+import Control.Concurrent.Chan+import Control.Future+import Data.Array.Storable (StorableArray)+import qualified Data.ByteString as B+import Data.IORef+import Data.Typeable+import Foreign hiding (newForeignPtr, addForeignPtrFinalizer, void)+import Foreign.C.String (peekCString, peekCStringLen)+import Foreign.Concurrent (newForeignPtr, addForeignPtrFinalizer)+import Graphics.OpenGLES.Base+import Linear.Vect+import System.IO.Unsafe (unsafePerformIO)++-- * Internal++-- glRestoreLostObjects :: GL ()+-- saveBuffer :: Buffer -> IO ()+-- saveBuffer buf = atomicModifyIORef' (buf:) bufferArchive+-- bufferArchive = unsafePerformIO $ newIORef []+-- addCompiledProgramResources++-- ** Logging++errorQueue :: Chan String+errorQueue = unsafePerformIO newChan+{-# NOINLINE errorQueue #-}++glLog :: String -> IO ()+glLog msg = writeChan errorQueue msg+++-- ** GL Error++data GLError = InvalidEnum | InvalidValue | InvalidOperation+             | OutOfMemory | InvalidFrameBufferOperation+             deriving Show++getError :: GL (Maybe GLError)+getError = unMarshal <$> glGetError+	where unMarshal x = case x of+		0x0000 -> Nothing+		0x0500 -> Just InvalidEnum+		0x0501 -> Just InvalidValue+		0x0502 -> Just InvalidOperation+		0x0505 -> Just OutOfMemory+		0x0506 -> Just InvalidFrameBufferOperation++showError :: String -> GL Bool+showError location = do+	putStrLn location -- tmp+	getError >>= maybe (return False)+		(\err -> do+			glLog ("E " ++ location ++ ": " ++ show err)+			return True )++-- ** GL Object management++type GLO = IORef (GLuint, ForeignPtr GLuint)++instance Show GLO where+	show ref = show . unsafePerformIO $ readIORef ref++newGLO+	:: (GLsizei -> Ptr GLuint -> GL ())+	-> (GLuint -> GL ())+	-> (GLsizei -> Ptr GLuint -> GL ())+	-> GL GLO+newGLO gen bind del = do+	ref <- newIORef undefined+	genObj ref gen bind del+	return ref++-- | genObj glo glGenBuffers glDeleteBuffers+genObj+	:: GLO+	-> (GLsizei -> Ptr GLuint -> GL ())+	-> (GLuint -> GL ())+	-> (GLsizei -> Ptr GLuint -> GL ())+	-> GL GLuint+genObj ref genObjs bindObj delObjs = do+	fp <- mallocForeignPtr+	withForeignPtr fp $ \ptr -> do+		genObjs 1 ptr+		showError "genObj"+		obj <- peek ptr+		writeIORef ref (obj, fp)+		addForeignPtrFinalizer fp $ do+			(obj, _) <- readIORef ref+			with obj $ \ptr -> do+				delObjs 1 ptr+				void $ showError "delObj"+		bindObj obj+		return obj+++-- ** Buffer++-- forall s. ST s a -> a+-- Buffer usage [GLtype] stride id (latestArray, isBufferSynced)+-- DoubleBuffer BufferUsage GLO GLO (IORef (Bool, GLArray a, GLArray a))+data Buffer a =+	Buffer BufferUsage GLO (IORef (StorableArray Int a))++newtype BufferUsage = BufferUsage GLenum++newtype BufferSlot = BufferSlot GLenum++newBuffer = newGLO glGenBuffers (glBindBuffer 0x8892) glDeleteBuffers+++-- ** DrawMode++newtype DrawMode = DrawMode GLenum+++-- ** Graphics State++newtype Capability = Capability GLenum+newtype CullFace = Culling GLenum+newtype CompFunc = CompFunc GLenum+newtype StencilOp = StencilOp GLenum+newtype BlendOp = BlendOp GLenum+newtype BlendingFactor = BlendingFactor GLenum+newtype Hint = Hint GLenum+++-- ** Programmable Shader++type ShaderType = GLenum++data Shader = Shader ShaderType GLName B.ByteString+	deriving Show++data TransformFeedback =+	  NoFeedback+	| FeedbackArrays [String]+	| FeedbackPacked [String]+	deriving Show++data Program p = Program+	{ programGLO :: GLO+	, programTF :: TransformFeedback+	, programShaders :: [Shader]+	, programVariables :: ([VarDesc], [VarDesc])+	} deriving Show++type ProgramBinary = B.ByteString++-- | name: (location, length of array, type)+type VarDesc = (String, (GLint, GLsizei, GLenum))++-- binaryStore :: IORef [(String, B.ByteString)]+-- or (FilePath -> IO B.ByteString)+-- binaryStore = unsafePerformIO $ newIORef []++programDict :: IORef [(String, Program ())]+programDict = unsafePerformIO $ newIORef []++lookupVarDesc :: TypeRep -> IO (Maybe ([VarDesc], [VarDesc]))+lookupVarDesc rep = do+	let name = show rep+	entry <- lookup name <$> readIORef programDict+	case entry of+		Nothing -> do+			glLog $ "Program '" ++ name ++ "' is not compiled."+			return Nothing+		Just prog -> return $ Just (programVariables prog)++loadProgram+	:: Typeable p+	=> Program p+	-> (Int -> String -> Maybe ProgramBinary -> GL ())+	-> GL (Progress [String] (Program p))+loadProgram prog@(Program glo tf shaders ([],[])) progressLogger = do+	let numShaders = length shaders+	let progname = show (typeRep prog)+	let msg = "Start compiling: " ++ progname+	glLog msg+	progressLogger 0 msg Nothing+	+	pid <- glCreateProgram+	res <- if pid == 0 then do+		showError "glCreateProgram"+		let msg = "Fatal: glCreateProgram returned 0."+		progressLogger (numShaders + 1) msg Nothing+		return $ Fixme [msg]+	else do+		results <- mapM (loadShader progressLogger) (zip [1..] shaders)+		-- putStrLn $ show results+		let errors = [msg | Fixme [msg] <- results]+		res <- if errors /= []+		then return $ Fixme errors+		else do+			forM_ results $ \(Finished sid) -> do+				glAttachShader pid sid+				showError "glAttachShader"+			glLinkProgram pid+			showError "glLinkProgram"+			postLink progname numShaders prog pid progressLogger+		sequence_ [glDeleteShader s | Finished s <- results]+		return res+	glLog "---------------"+	return res++postLink+	:: Typeable p+	=> String -> Int -> Program p -> GLuint+	-> (Int -> String -> Maybe ProgramBinary -> GL ())+	-> GL (Progress [String] (Program p))+postLink progname numShaders prog pid+		progressLogger = alloca $ \intptr -> do+	glGetProgramiv pid c_link_status intptr+	linkStatus <- peek intptr+	glGetProgramiv pid c_info_log_length intptr+	len <- fmap fromIntegral $ peek intptr+	info <- allocaBytes len $ \buf -> do+		glGetProgramInfoLog pid (fromIntegral len) nullPtr buf+		peekCStringLen (buf, len-1)+	let info' = if info == "" then "" else '\n':info+	if linkStatus == 0 then do+		let msg = "Cannot link program " ++ progname ++ info'+		glLog msg+		progressLogger (numShaders + 1) msg Nothing+		glDeleteProgram pid+		return $ Fixme [msg]+	else do+		-- obtain shader variables+		vars <- getActiveVariables pid+		putStrLn . show $ vars+		fp <- newForeignPtr nullPtr (glDeleteProgram pid)+		writeIORef (programGLO prog) (pid, fp)+		let msg = "Successfully linked " ++ progname ++ "!" ++ info'+		glLog msg+		progressLogger (numShaders + 1) msg Nothing+		let prog' = prog { programVariables = vars }+		atomicModifyIORef' programDict $! \xs ->+			((show (typeRep prog), prog'):xs, ())+		return $ Finished prog'++c_link_status = 0x8B82+c_info_log_length = 0x8B84++{-+GL_PROGRAM_BINARY_RETRIEVABLE_HINT               0x8257+GL_PROGRAM_BINARY_LENGTH                         0x8741+GL_NUM_PROGRAM_BINARY_FORMATS                    0x87FE+loadProgramBinary :: Program p -> GLuint -> GL ()+loadProgramBinary (Program tf _ ref) pid = do+	bs <- ...+	let (fp, offset, len) = toForeignPtr bs+	withForeignPtr fp $ \p -> do+		fmt <- peek (p `plusPtr` offset)+		glProgramBinary pid fmt (p `plusPtr` (offset+4)) (fromIntegral len)+		showError "glProgramBinary"+		if err, writeIORef ref Broken+	postLink progname numShaders ref pid+-}++loadShader+	:: (Int -> String -> Maybe ProgramBinary -> GL ())+	-> (Int, Shader)+	-> GL (Progress [String] GLuint)+loadShader progressLogger (i, Shader shaderType name bs) = do+	sid <- glCreateShader shaderType+	if sid == 0 then do+		showError "glCreateShader"+		let msg = "Fatal: glCreateShader returned 0."+		glLog msg+		progressLogger i msg Nothing+		return $ Fixme [name ++ ": " ++ msg]+	else B.useAsCString bs $ \src -> do+		withArray [src] $ \ptr -> do+			glShaderSource sid 1 ptr nullPtr+			showError "glShaderSource"+			glCompileShader sid+			showError "glCompileShader"+			alloca $ \pint -> do+				glGetShaderiv sid c_compile_status pint+				compiled <- peek pint+				glGetShaderiv sid c_info_log_length pint+				len <- fmap fromIntegral $ peek pint+				info <- allocaBytes len $ \buf -> do+					glGetShaderInfoLog sid (fromIntegral len) nullPtr buf+					peekCStringLen (buf, len-1)+				let info' = if info == "" then "" else '\n':info+				if compiled == 0 then do+					let msg = "Could not compile " ++ name ++ info'+					glLog msg+					progressLogger i msg Nothing+					glDeleteShader sid+					return $ Fixme [msg]+				else do+					let msg = name ++ " ... done" ++ info'+					glLog msg+					progressLogger i msg Nothing+					return $ Finished sid++c_compile_status = 0x8B81++getActiveVariables :: GLuint -> GL ([VarDesc], [VarDesc])+getActiveVariables pid = do+	sptr <- malloc+	glGetProgramiv pid c_active_uniform_max_length sptr+	uMaxLen <- peek sptr+	glGetProgramiv pid c_active_attribute_max_length sptr+	aMaxLen <- peek sptr+	let maxlen = max uMaxLen aMaxLen+	str <- mallocBytes (fromIntegral maxlen)+	+	glGetProgramiv pid c_active_uniforms sptr+	numU <- peek sptr+	glGetProgramiv pid c_active_attributes sptr+	numA <- peek sptr+	+	tptr <- malloc+	uniforms <- forM [0..numU-1] $ \ index -> do+		-- avoid [0..maxBound] bug+		let i = (fromIntegral :: GLint -> GLuint) index+		glGetActiveUniform pid i maxlen nullPtr sptr tptr str+		name <- peekCString str+		loc <- glGetUniformLocation pid str+		size <- peek sptr+		typ <- peek tptr+		return (name, (loc, size, typ))+	+	attribs <- forM [0..numA-1] $ \index -> do+		let i = fromIntegral index+		glGetActiveAttrib pid i maxlen nullPtr sptr tptr str+		name <- peekCString str+		loc <- glGetAttribLocation pid str+		size <- peek sptr+		typ <- peek tptr+		putStrLn . show $ (index, loc)+		return (name, (loc, size, typ))+	free str; free sptr; free tptr+	return (uniforms, attribs)++c_active_uniform_max_length = 0x8B87+c_active_attribute_max_length = 0x8B8A+c_active_uniforms = 0x8B86+c_active_attributes = 0x8B89+++-- ** Uniform++-- (location, length of array or 1, ptr)+newtype Uniform p a = Uniform (GLint, GLsizei, Ptr ())++-- +class UnifVal a where+	glUniform :: (GLint, GLsizei, Ptr ()) -> a -> GL ()++--class GLVar m v a where+--	($=) :: m p a -> a -> (m (), v ())+--	($-) :: m p a -> v a -> (m (), v ())+--instance UnifVal a => GLVar Uniform UniformValue a where+--	unif $= value = unif $- unifVal value+--	unif $- value = (coerce unif, coerce value)+--instance AttrStruct a => GLVar Attrib Buffer a where+--	attr $= value = attr $- buffer "tmp" value+--	attr $- buffer = (coerce attr, coerce buffer)+-- UnifVal a => (Uniform p a, a)+-- UnifStruct a => (UniformBlock p a, Buffer a)+-- GLStruct? std130?+++-- ** Attrib++-- (index, size, normalize, divisor)+newtype Attrib p a = Attrib (GLuint, GLsizei, GLboolean, GLuint) deriving Show++class (Num a, Storable a) => GenericVertexAttribute a where+	glVertexAttrib4v :: GLuint -> Ptr (V4 a) -> GL ()++instance GenericVertexAttribute Float where+	glVertexAttrib4v idx = glVertexAttrib4fv idx . castPtr+instance GenericVertexAttribute Int32 where+	glVertexAttrib4v idx = glVertexAttribI4iv idx . castPtr+instance GenericVertexAttribute Word32 where+	glVertexAttrib4v idx = glVertexAttribI4uiv idx . castPtr++class ShaderAttribute a where+	glVertexAttrib :: GLuint -> a -> GL ()++class Storable b => AttrStruct b a p | a -> p where+	glVertexAttribPtr :: a -> Buffer b -> GL ()+++-- ** Vertex Array Object++-- (glo, init)+newtype VertexArray p = VertexArray (GLO, GL ())++newtype HalfFloat = HalfFloat Word16 deriving (Num,Read,Show,Storable)+newtype FixedFloat = FixedFloat Int32 deriving (Num,Read,Show,Storable)+newtype Int10x3_2 = Int10x3_2 Int32 deriving (Num,Read,Show,Storable)+newtype Word10x3_2 = Word10x3_2 Int32 deriving (Num,Read,Show,Storable)++class GLType a where+	glType :: m a -> Word32++instance GLType Int8 where glType _ = 0x1400+instance GLType Word8 where glType _ = 0x1401+instance GLType Int16 where glType _ = 0x1402+instance GLType Word16 where glType _ = 0x1403+instance GLType Int32 where glType _ = 0x1404+instance GLType Word32 where glType _ = 0x1405++instance GLType Float where glType _ = 0x1406+instance GLType HalfFloat where glType _ = 0x140B+instance GLType FixedFloat where glType _ = 0x140C+instance GLType Int10x3_2 where glType _ = 0x8D9F+instance GLType Word10x3_2 where glType _ = 0x8368+++-- ** Vertex Picker++newtype VertexPicker = VertexPicker (GLenum -> GL Bool)++class VertexIx a where+	vxix :: m a -> (GLenum, GLint)+instance VertexIx Word8 where+	vxix = const (0x1401, 1)+instance VertexIx Word16 where+	vxix = const (0x1403, 2)+instance VertexIx Word32 where+	vxix = const (0x1405, 4)+++-- ** Draw Operation++newtype ClearBufferMask = ClearBufferMask GLenum deriving Num++-- [MainThread, GLThread]+-- if Nothing, main GL thread should stop before the next frame.+drawOrExit :: IORef (Maybe (GL ())) -- eglSwapBuffer inside+drawOrExit = unsafePerformIO $ newIORef Nothing++drawQueue :: Chan (GL ())+drawQueue = unsafePerformIO newChan+{-# NOINLINE drawQueue #-}++
+ Graphics/OpenGLES/State.hs view
@@ -0,0 +1,207 @@+-- | Draw configurations on Rasterization and Per-Fragment Operations.+-- Note: Graphic state is sticky.+module Graphics.OpenGLES.State (+  -- * Graphics State+  lineWidth, polygonOffset, scissor,+  sampleCoverage,+  -- ** Capability+  begin, end,+  Capability,+  culling,+  blend,+  dither,+  stencilTest,+  depthTest,+  scissorTest,+  polygonOffsetFill,+  sampleAlphaToCoverage,+  multisampleCoverage,+  primitiveRestartFixedIndex,+  rasterizerDiscard,+  -- ** Cull Face+  cullFace, frontFace,+  CullFace, hideFront, hideBack, hidePolygons,+  -- ** Stencil+  stencilFunc, stencilFuncSeparate,+  stencilOp, stencilOpSeparate,+  StencilOp, opZero, opKeep, opReplace, opIncr,+  opDecr, opInvert, opIncrWrap, opDecrWrap,+  -- ** Depth+  depthFunc,+  CompFunc, glNever, glLess, glEqual, glLessEq,+  glGreater, glNotEq, glGreatEq, glAlways,+  -- ** Blend+  blendEquation, blendEquationSeparate,+  blendFunc, blendFuncSeparate,+  Clampf, blendColor,+  BlendOp, addBlending, subBlending, reverseSubBlending,+  BlendingFactor, factorZero, factorOne, srcColor, oneMinusSrcColor,+  srcAlpha, oneMinusSrcAlpha, dstAlpha, oneMinusDstAlpha,+  dstColor, oneMinusDstColor, srcAlphaSaturate,+  constColor, oneMinusConstColor, constAlpha, oneMinusConstAlpha,+  -- ** Hint+  generateMipmapHint, fragmentShaderDerivativeHint,+  Hint, dontCare, nicest, fastest+  ) where+import Data.Int+import Data.Word+import Graphics.OpenGLES.Base+import Graphics.OpenGLES.Internal++-- | Float value clamped to [0,1]+type Clampf = Float++begin :: Capability -> GL ()+begin (Capability cap) = glEnable cap++end :: Capability -> GL ()+end (Capability cap) = glDisable cap+++-- *** Capability++culling = Capability 0x0B44+blend = Capability 0x0BE2+dither = Capability 0x0BD0+stencilTest = Capability 0x0B90+depthTest = Capability 0x0B71+scissorTest = Capability 0x0C11+polygonOffsetFill = Capability 0x8037+sampleAlphaToCoverage = Capability 0x809E+multisampleCoverage = Capability 0x80A0+primitiveRestartFixedIndex = Capability 0x8D69+rasterizerDiscard = Capability 0x8C89++lineWidth :: Float -> GL ()+lineWidth = glLineWidth++-- | CW -> True, CCW -> False+frontFace :: Bool -> GL ()+frontFace cw = glFrontFace (if cw then 0x900 else 0x901)++cullFace :: CullFace -> GL ()+cullFace (Culling x) = glCullFace x++-- *** CullFace++hideFront = Culling 0x0404+hideBack = Culling 0x0405+hidePolygons = Culling 0x408++polygonOffset+	:: Float -- ^ factor+	-> Float -- ^ units+	-> GL ()+polygonOffset factor units = glPolygonOffset factor units++scissor+	:: Int32 -- ^ left+	-> Int32 -- ^ bottom+	-> Int32 -- ^ width+	-> Int32 -- ^ height+	-> GL ()+scissor l b w h = glScissor l b w h++sampleCoverage+	:: Float -- ^ multisample coverage value [0,1]+	-> Bool -- ^ whether coverage masks should be inverted or not+	-> GL ()+sampleCoverage value invert =+	glSampleCoverage value (if invert then 1 else 0)++stencilFunc :: CompFunc -> Int32 -> Word32 -> GL ()+stencilFunc (CompFunc func) comp mask =+	glStencilFunc func comp mask++stencilFuncSeparate :: CullFace -> CompFunc -> Int32 -> Word32 -> GL ()+stencilFuncSeparate (Culling cull) (CompFunc func) comp mask =+	glStencilFuncSeparate cull func comp mask++stencilOp :: StencilOp -> StencilOp -> StencilOp -> GL ()+stencilOp (StencilOp sfail) (StencilOp dpfail) (StencilOp dppass) =+	glStencilOp sfail dpfail dppass++stencilOpSeparate :: CullFace -> StencilOp -> StencilOp -> StencilOp -> GL ()+stencilOpSeparate (Culling cull) (StencilOp sfail)+		(StencilOp dpfail) (StencilOp dppass) =+	glStencilOpSeparate cull sfail dpfail dppass++depthFunc :: CompFunc -> GL ()+depthFunc (CompFunc func) = glDepthFunc func++-- *** CompFunc++glNever    = CompFunc 0x0200+glLess     = CompFunc 0x0201+glEqual    = CompFunc 0x0202+glLessEq   = CompFunc 0x0203+glGreater  = CompFunc 0x0204+glNotEq    = CompFunc 0x0205+glGreatEq  = CompFunc 0x0206+glAlways   = CompFunc 0x0207++-- *** StencilOp++opZero     = StencilOp 0x0000+opKeep     = StencilOp 0x1E00+opReplace  = StencilOp 0x1E01+opIncr      = StencilOp 0x1E02+opDecr     = StencilOp 0x1E03+opInvert   = StencilOp 0x150A+opIncrWrap = StencilOp 0x8507+opDecrWrap = StencilOp 0x8508++blendEquation :: BlendOp -> GL ()+blendEquation (BlendOp mode) = glBlendEquation mode++blendEquationSeparate :: BlendOp -> BlendOp -> GL ()+blendEquationSeparate (BlendOp rgb) (BlendOp a) =+	glBlendEquationSeparate rgb a++-- *** BlendOp++addBlending        = BlendOp 0x8006+subBlending        = BlendOp 0x800A+reverseSubBlending = BlendOp 0x800B++blendFunc :: BlendingFactor -> BlendingFactor -> GL ()+blendFunc (BlendingFactor src) (BlendingFactor dest) =+	glBlendFunc src dest++blendFuncSeparate :: BlendingFactor -> BlendingFactor -> BlendingFactor -> BlendingFactor -> GL ()+blendFuncSeparate (BlendingFactor srgb) (BlendingFactor drgb)+		(BlendingFactor salpha) (BlendingFactor dalpha) =+	glBlendFuncSeparate srgb drgb salpha dalpha++-- *** BlendingFactor++factorZero         = BlendingFactor 0+factorOne          = BlendingFactor 1+srcColor           = BlendingFactor 0x300+oneMinusSrcColor   = BlendingFactor 0x301+srcAlpha           = BlendingFactor 0x302+oneMinusSrcAlpha   = BlendingFactor 0x303+dstAlpha           = BlendingFactor 0x304+oneMinusDstAlpha   = BlendingFactor 0x305+dstColor           = BlendingFactor 0x306+oneMinusDstColor   = BlendingFactor 0x307+srcAlphaSaturate   = BlendingFactor 0x308+constColor         = BlendingFactor 0x8001+oneMinusConstColor = BlendingFactor 0x8002+constAlpha         = BlendingFactor 0x8003+oneMinusConstAlpha = BlendingFactor 0x8004++blendColor :: Clampf -> Clampf -> Clampf -> Clampf -> GL ()+blendColor r g b a = glBlendColor r g b a++generateMipmapHint :: Hint -> GL ()+generateMipmapHint (Hint hint) = glHint 0x8192 hint++fragmentShaderDerivativeHint :: Hint -> GL ()+fragmentShaderDerivativeHint (Hint hint) = glHint 0x8B8B hint++-- *** Hint++dontCare = Hint 0x1100+fastest  = Hint 0x1101+nicest   = Hint 0x1102
+ Graphics/OpenGLES/Texture.hs view
@@ -0,0 +1,281 @@+{-# LANGUAGE RecordWildCards #-}+module Graphics.OpenGLES.Texture (+  -- * Texture+  Texture,+  --TextureColorFormat,+  --TextureBitLayout,+  --TextureInternalFormat,+  --TextureData,+  glLoadKtx,+  glLoadKtxFile,++  texSlot,++  -- * Sampler+  setSampler,+  Sampler(..),+  +  MagFilter,+  magNearest,+  magLinear,+  +  MinFilter,+  minNearest,+  minLinear,+  nearestMipmapNearest,+  linearMipmapNearest,+  nearestMipmapLinear,+  linearMipmapLinear,+  +  WrapMode,+  tiledRepeat,+  clampToEdge,+  mirroredRepeat+  ) where+import Control.Applicative+import Control.Monad+import qualified Data.ByteString as B+import Data.Int+import Data.Word+import Data.IORef+import Graphics.OpenGLES.Base+import Graphics.OpenGLES.Env+import Graphics.OpenGLES.Internal+import Graphics.TextureContainer.KTX+import Foreign.Ptr (castPtr)++-- glo, target, ktx+data Texture = Texture GLenum GLO (IORef Ktx)+-- XXX Texture DoubleBufferring++texSlot :: Word32 -> Texture -> GL ()+texSlot slot (Texture target glo _) = do+	tex <- readIORef glo >>= return . fst+	glActiveTexture (0x84C0 + slot) -- GL_TEXTURE_0 + slot+	glBindTexture target tex++data TextureColorFormat = ALPHA | RGB | RGBA | LUMINANCE | LUMINANCE_ALPHA++data TextureBitLayout = UByte | US565 | US444 | US5551+	-- | ES 3.0+	| Byte | UShort | Short | UInt | Int | HalfFloat | Float | US4444 | UI2_10_10_10Rev | UI24_8 | UI_10f11f11fRev | UI5999Rev | F32UI24_8Rev++data TextureInternalFormat = Alpha | Rgb | Rgba | Luminance | LuminanceAlpha+	-- 3.0+	| R8 | R8i | R8ui | R8snorm | R16i | R16ui | R16f | R32i | R32ui | R32f+	| Rg8 | Rg8i | Rg8ui | Rg8snorm | Rg16i | Rg16ui | Rg16f | Rg32i | Rg32ui | Rg32f+	| Rgb8 | Rgb8i | Rgb8ui | Rgb8snorm | Rgb16i | Rgb16ui | Rgb16f | Rgb32i | Rgb32ui | Rgb32f+	| Rgba8 | Rgba8i | Rgba8ui | Rgba8snorm | Rgba16i | Rgba16ui | Rgba16f | Rgba32i | Rgba32ui | Rgba32f+	| Rgb5a1 | Rgb565 | Rgb9e5 | Rgb10a2 | Rgb10a2ui | Srgb8 | Rgba4 | Srgb8Alpha8+	| R11fG11fB10f | DepthComponent16 | DepthComponent24 | DepthComponent32+	| Depth24Stencil8 | Depth32fStencil8++data TextureData =+	  PlainTexture+	| PVRTC -- PowerVR SGX(iOS), Samsung S5PC110(Galaxy S/Tab)+	| ATITC -- ATI Imageon, Qualcomm Adreno+	| S3TC -- NVIDIA Tegra2, ZiiLabs ZMS-08 HD+	| ETC -- Android, ARM Mali+	-- .| _3Dc -- ATI, NVidia+	-- .| Palette++-- | Load a GL Texture object from Ktx texture container.+-- See <https://github.com/KhronosGroup/KTX/blob/master/lib/loader.c>+-- TODO: reject 2DArray/3D texture if unsupported+glLoadKtx :: Maybe Texture -> Ktx -> GL Texture+glLoadKtx oldtex ktx@Ktx{..} = do+	--putStrLn.show $ ktx+	let newTexture target = case oldtex of+		Just (Texture _ glo ref) -> do+			writeIORef ref ktx+			readIORef glo >>= glBindTexture target . fst+			return (Texture target glo ref)+		Nothing -> Texture target+			<$> newGLO glGenTextures (glBindTexture target) glDeleteTextures+			<*> newIORef ktx+	case checkKtx ktx of+		Left msg -> glLog (msg ++ ": " ++ ktxName) >> newTexture 0+		Right (comp, target, genmip) -> do+			tex <- newTexture target+			-- ES2 compat;+			let fmt = if comp || sizedFormats+				then if ktxGlInternalFormat == 0x8D64 && hasETC2 -- ETC1_RGB8_OES+					then 0x9274 -- GL_COMPRESSED_RGB8_ETC2+					else ktxGlInternalFormat+				else ktxGlBaseInternalFormat+			putStrLn . show $ (comp, target,genmip, ktxGlInternalFormat, hasETC2, fmt)+			let uploadMipmap _ _ _ _ [] = return ()+			    uploadMipmap level w h d (faces:rest) = do+				case (comp, target) of+					-- 2D Compressed+					(True, 0x0DE1) -> do+						B.useAsCStringLen (head faces) $ \(ptr, len) ->+							glCompressedTexImage2D target level fmt w h 0 (i len) (castPtr ptr)+					-- 2D Uncompressed+					(False, 0x0DE1) -> do+						B.useAsCString (head faces) $ \ptr ->+							glTexImage2D target level fmt w h 0 ktxGlFormat ktxGlType (castPtr ptr)+					-- Cube Map Compressed+					(True, 0x8513) -> do+						forM_ (zip [texture_cube_map_positive_x..] faces) $ \(face, image) ->+							B.useAsCStringLen image $ \(ptr, len) ->+								glCompressedTexImage2D face level fmt w h 0 (i len) (castPtr ptr)+					-- Cube Map Uncompressed+					(False, 0x8513) -> do+						forM_ (zip [texture_cube_map_positive_x..] faces) $ \(face, image) ->+							B.useAsCString image $ \ptr ->+								glTexImage2D face level fmt w h 0 ktxGlFormat ktxGlType (castPtr ptr)+					-- 3D Compressed+					(True, 0x806F) -> do+						B.useAsCStringLen (head faces) $ \(ptr, len) ->+							glCompressedTexImage3D target level fmt w h d 0 (i len) (castPtr ptr)+					-- 3D Uncompressed+					(False, 0x806F) -> do+						B.useAsCString (head faces) $ \ptr ->+							glTexImage3D target level fmt w h d 0 ktxGlFormat ktxGlType (castPtr ptr)+					-- 2D Array Compressed+					(True, 0x8C1A) -> do+						B.useAsCStringLen (head faces) $ \(ptr, len) ->+							glCompressedTexImage3D target level fmt w h ktxNumElems 0 (i len) (castPtr ptr)+					-- 2D Array Uncompressed+					(False, 0x8C1A) -> do+						B.useAsCString (head faces) $ \ptr ->+							glTexImage3D target level fmt w h ktxNumFaces 0 ktxGlFormat ktxGlType (castPtr ptr)+				showError $ "gl{,Compressed}TexImage{2D,3D} " ++ ktxName+				uploadMipmap (level + 1) (div2 w) (div2 h) (div2 d) rest+				+				where+					div2 x = max 1 (div x 2)+					i = fromIntegral++			uploadMipmap 0 ktxPixelWidth ktxPixelHeight ktxPixelDepth ktxImage+			when genmip $ do+				glGenerateMipmap target+				void $ showError $ "glGenerateMipmap " ++ ktxName+			return tex++glLoadKtxFile :: FilePath -> GL Texture+glLoadKtxFile path = ktxFromFile path >>= glLoadKtx Nothing++-- glPixelStorei(GL_UNPACK_ALIGNMENT, 4)+--hasES2 =+--	supportsSwizzle = GL_FALSE;+--	sizedFormats = _NO_SIZED_FORMATS;+--	R16Formats = _KTX_NO_R16_FORMATS;+--	supportsSRGB = GL_FALSE;+--hasES3 = sizedFormats = _NON_LEGACY_FORMATS;+--hasExt "GL_OES_required_internalformat" =+--	sizedFormats |= _ALL_SIZED_FORMATS+sizedFormats = hasES3 || hasExt "GL_OES_required_internalformat"+-- There are no OES extensions for sRGB textures or R16 formats.+hasETC2 = hasES3+hasPVRTC = hasExt "GL_IMG_texture_compression_pvrtc"+hasATITC = hasExt "GL_ATI_texture_compression_atitc"+hasS3TC = hasExt "GL_EXT_texture_compression_s3tc"++-- | Check a KTX file header.+-- returning (isCompressed?, textureTarget, generateMipmapNeeded?)+checkKtx :: Ktx -> Either String (Bool, GLenum, Bool)+checkKtx t = (,,) <$> isCompressed t <*> detectTarget t <*> needsGenMipmap t++isCompressed Ktx { ktxGlTypeSize = s } | s /= 1 && s /= 2 && s /= 4 = Left "checkKtx: Invalid glTypeSize"+isCompressed Ktx { ktxGlType = 0, ktxGlFormat = 0 } = Right True+isCompressed Ktx { ktxGlType = t, ktxGlFormat = f } | t == 0 || f == 0 = Left "checkKtx: Invalid glType"+isCompressed _ = Right False++detectTarget ktx@Ktx { ktxNumElems = 0 } = detectCube ktx+detectTarget ktx = detectCube ktx >>= \target ->+	if target == texture_2d+		then Right texture_2d_array+		else Left "checkKtx: No API for 3D and cube arrays yet"+detectCube ktx@Ktx { ktxNumFaces = 1 } = detectDim ktx+detectCube ktx@Ktx { ktxNumFaces = 6 } = detectDim ktx >>= \dim ->+	if dim == 2+		then Right texture_cube_map+		else Left "checkKtx: cube map needs 2D faces"+detectCube _ = Left "checkKtx: numberOfFaces must be either 1 or 6"++detectDim Ktx { ktxPixelWidth = 0 } = Left "checkKtx: texture must have width"+detectDim Ktx { ktxPixelHeight = 0, ktxPixelDepth = 0 } = Left "checkKtx: 1D texture is not supported"+detectDim Ktx { ktxPixelHeight = 0 } = Left "checkKtx: texture must have height if it has depth"+detectDim Ktx { ktxPixelDepth = 0 } = Right texture_2d+detectDim _ = Right texture_3d++needsGenMipmap Ktx { ktxNumMipLevels = 0 } = Right True+needsGenMipmap Ktx {..}+	| max (max ktxPixelDepth ktxPixelHeight) ktxPixelDepth < 2^(ktxNumMipLevels-1)+	= Left "checkKtx: Can't have more mip levels than 1 + log2(max(width, height, depth))"+needsGenMipmap _ = Right False++texture_2d = 0x0DE1+texture_cube_map = 0x8513+texture_2d_array = 0x8C1A+texture_3d = 0x806F++texture_cube_map_positive_x = 0x8515+++-- ** Sampler++-- 2d vs. 3d / mag + min vs. max+-- | (Texture wrap mode, A number of ANISOTROPY filter sampling points+-- (specify 1.0 to disable anisotropy filter), (Fallback) Mag and Min filters).+-- +-- When /EXT_texture_filter_anisotropic/ is not supported, fallback filters+-- are used instead.+data Sampler =+	Sampler (WrapMode, WrapMode, Maybe WrapMode) Float (MagFilter, MinFilter)++newtype MagFilter = MagFilter Int32+magNearest = MagFilter 0x2600+magLinear = MagFilter 0x2601++-- TODO NoMipmap => use minLinear instead / forceGenMip?+newtype MinFilter = MinFilter Int32+minNearest = MinFilter 0x2600+minLinear = MinFilter 0x2601+nearestMipmapNearest = MinFilter 0x2700+linearMipmapNearest = MinFilter 0x2701+nearestMipmapLinear = MinFilter 0x2702+linearMipmapLinear = MinFilter 0x2703++-- TODO: NPOT && not ClampToEdge && not (hasES3 || hasExt "GL_OES_texture_npot") => error+newtype WrapMode = WrapMode Int32+tiledRepeat = WrapMode 0x2901+clampToEdge = WrapMode 0x812F+mirroredRepeat = WrapMode 0x8370++setSampler :: Texture -> Sampler -> GL ()+setSampler (Texture target glo _) (Sampler (WrapMode s, WrapMode t, r) a+		(MagFilter g, MinFilter n)) = do+	tex <- readIORef glo >>= return . fst+	glBindTexture target tex+	glTexParameteri target 0x2802 s+	glTexParameteri target 0x2803 t+	maybe (return ()) (\(WrapMode x) -> glTexParameteri target 0x8072 x) r+	--if a /= 1.0 && hasExt "GL_EXT_texture_filter_anisotropic" then+	-- GL_TEXTURE_MAX_ANISOTROPY_EXT+	glTexParameterf target 0x84FE a+	glTexParameteri target 0x2800 g+	glTexParameteri target 0x2801 n++--setLOD :: Texture -> Int32 -> Int32 -> GL ()+--setTexCompFunc :: Texture ->  ->  -> GL ()++-- mipmaps, compressed, fallbacks+-- [comptex, fallback]+-- glm basepath = /data/app.name/assets/...+-- glm preffered compression type (filename suffiex)+---- iOS: PVRTC+---- Android with Alpha: PVRTC+ATITC+S3TC+Uncompressed+---- Android without Alpha: ETC1+---- PC: S3TC + Uncompressed+--glm detect compression support+-- record Gen/Del/Draw* calls and responces+-- prefferedformat == "etc1" like.+-- texture from file "name" [path..] genMipmap?flag+--Utils.hs shrinked triangles, +--  Update[Sub]Texture,UpdateVertex(Buffer)+-- "texname" [tex1,tex2,...] auto select+-- texture atlas managment+
+ Graphics/OpenGLES/Types.hs view
@@ -0,0 +1,394 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverlappingInstances #-}+{-# LANGUAGE UndecidableInstances #-}+module Graphics.OpenGLES.Types (+  -- * Shading Language Base Types+  Vec2, Vec3, Vec4,+  BVec2, BVec3, BVec4,+  IVec2, IVec3, IVec4,+  UVec2, UVec3, UVec4,+  Mat2, Mat3, Mat4,+  Mat2x3, Mat2x4, Mat3x2,+  Mat3x4, Mat4x2, Mat4x3,++  -- * Uniform Variable+  Uniform, UnifVal,+  +  -- * Vertex Attribute+  Attrib, ShaderAttribute, AttrStruct,+  +  -- * Vertex Attribute Array Source Datatypes+  HalfFloat(..), FixedFloat(..),+  Int10x3_2(..), Word10x3_2(..)+  ) where+import Control.Monad (when)+import Foreign+import Linear.Class (Transpose, transpose)+import Linear.Vect+import Linear.Mat+import Graphics.OpenGLES.Base+import Graphics.OpenGLES.Internal+++type Vec2 = V2 Float+type Vec3 = V3 Float+type Vec4 = V4 Float+type BVec2 = V2 Bool+type BVec3 = V3 Bool+type BVec4 = V4 Bool+type IVec2 = V2 Int32+type IVec3 = V3 Int32+type IVec4 = V4 Int32+type UVec2 = V2 Word32+type UVec3 = V3 Word32+type UVec4 = V4 Word32+type Mat2 = M2 Float+type Mat3 = M3 Float+type Mat4 = M4 Float+type Mat2x3 = M2x3 Float+type Mat2x4 = M2x4 Float+type Mat3x2 = M3x2 Float+type Mat3x4 = M3x4 Float+type Mat4x2 = M4x2 Float+type Mat4x3 = M4x3 Float+++--instance UnifVal Float where+--	glUniform (loc, _, _) x = glUniform1f loc x++#define Uniform(_typ, _arg, _suffix, _rhs) \+instance UnifVal (_typ) where \+	glUniform (loc, _, _) _arg = glUniform/**/_suffix loc _rhs \++Uniform(Float,x,1f,x)+Uniform(Vec2,(V2 x y),2f,x y)+Uniform(Vec3,(V3 x y z),3f,x y z)+Uniform(Vec4,(V4 x y z w),4f,x y z w)+Uniform(Int32,x,1i,x)+Uniform(IVec2,(V2 x y),2i,x y)+Uniform(IVec3,(V3 x y z),3i,x y z)+Uniform(IVec4,(V4 x y z w),4i,x y z w)+Uniform(Word32,x,1ui,x)+Uniform(UVec2,(V2 x y),2ui,x y)+Uniform(UVec3,(V3 x y z),3ui,x y z)+Uniform(UVec4,(V4 x y z w),4ui,x y z w)++--instance UnifVal [Float] where+--	glUniform (loc, len, ptr) values = do+--		let len' = fromIntegral len+--		pokeArray (castPtr ptr :: Ptr Float) (take len' values)+--		glUniform1fv loc len (castPtr ptr)++pokeUniformArray+	:: Storable b => (GLint -> GLsizei -> Ptr a -> GL ())+	-> (GLint, GLsizei, Ptr ()) -> [b] -> GL ()+pokeUniformArray glUniformV (loc, len, ptr) values = do+	let len' = fromIntegral len+	pokeArray (castPtr ptr :: Ptr b) (take len' values)+	glUniformV loc len (castPtr ptr)++instance UnifVal [Float] where glUniform = pokeUniformArray glUniform1fv+instance UnifVal [Vec2] where glUniform = pokeUniformArray glUniform2fv+instance UnifVal [Vec3] where glUniform = pokeUniformArray glUniform3fv+instance UnifVal [Vec4] where glUniform = pokeUniformArray glUniform4fv+instance UnifVal [Int32] where glUniform = pokeUniformArray glUniform1iv+instance UnifVal [IVec2] where glUniform = pokeUniformArray glUniform2iv+instance UnifVal [IVec3] where glUniform = pokeUniformArray glUniform3iv+instance UnifVal [IVec4] where glUniform = pokeUniformArray glUniform4iv+instance UnifVal [Word32] where glUniform = pokeUniformArray glUniform1uiv+instance UnifVal [UVec2] where glUniform = pokeUniformArray glUniform2uiv+instance UnifVal [UVec3] where glUniform = pokeUniformArray glUniform3uiv+instance UnifVal [UVec4] where glUniform = pokeUniformArray glUniform4uiv++-- 'transpose' argument must be GL_FALSE in GL ES 2.0+pokeMatrix :: (Transpose a b, Storable b)+	=> (GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+	-> (GLint, GLsizei, Ptr ()) -> a -> GL ()+pokeMatrix glUniformMatrixV (loc, 1, ptr) matrix = do+	poke (castPtr ptr :: Ptr b) (transpose matrix)+	glUniformMatrixV loc 1 0 (castPtr ptr)+pokeMatrix _ _ _ = return () -- poke to nullPtr+++instance UnifVal Mat2 where glUniform = pokeMatrix glUniformMatrix2fv+instance UnifVal Mat3 where glUniform = pokeMatrix glUniformMatrix3fv+instance UnifVal Mat4 where glUniform = pokeMatrix glUniformMatrix4fv++-- GL ES 3.0+ supports transpose+pokeMatrixT :: Storable a+	=> (GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+	-> (GLint, GLsizei, Ptr ()) -> a -> GL ()+pokeMatrixT glUniformMatrixV (loc, 1, ptr) matrix = do+	poke (castPtr ptr :: Ptr a) matrix+	glUniformMatrixV loc 1 1 (castPtr ptr)+pokeMatrixT _ _ _ = return ()++-- http://delphigl.de/glcapsviewer/gles_extensions.php +instance UnifVal Mat2x3 where glUniform = pokeMatrixT glUniformMatrix2x3fv+instance UnifVal Mat2x4 where glUniform = pokeMatrixT glUniformMatrix2x4fv+instance UnifVal Mat3x2 where glUniform = pokeMatrixT glUniformMatrix3x2fv+instance UnifVal Mat3x4 where glUniform = pokeMatrixT glUniformMatrix3x4fv+instance UnifVal Mat4x2 where glUniform = pokeMatrixT glUniformMatrix4x2fv+instance UnifVal Mat4x3 where glUniform = pokeMatrixT glUniformMatrix4x3fv++-- 'transpose' argument must be GL_FALSE in GL ES 2.0+pokeMatrices :: (Transpose a b, Storable b)+	=> (GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+	-> (GLint, GLsizei, Ptr ()) -> [a] -> GL ()+pokeMatrices glUniformMatrixV (loc, len, ptr) matrices = do+	let len' = fromIntegral len+	pokeArray (castPtr ptr :: Ptr b)+		(map transpose $ take len' matrices) -- maybe slow+	glUniformMatrixV loc len 0 (castPtr ptr)++instance UnifVal [Mat2] where glUniform = pokeMatrices glUniformMatrix2fv+instance UnifVal [Mat3] where glUniform = pokeMatrices glUniformMatrix3fv+instance UnifVal [Mat4] where glUniform = pokeMatrices glUniformMatrix4fv++-- GL ES 3.0+ supports transpose+pokeMatricesT :: Storable a+	=> (GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> GL ())+	-> (GLint, GLsizei, Ptr ()) -> [a] -> GL ()+pokeMatricesT glUniformMatrixV (loc, len, ptr) matrices = do+	let len' = fromIntegral len+	pokeArray (castPtr ptr :: Ptr a) (take len' matrices)+	glUniformMatrixV loc len 1 (castPtr ptr)++instance UnifVal [Mat2x3] where glUniform = pokeMatricesT glUniformMatrix2x3fv+instance UnifVal [Mat2x4] where glUniform = pokeMatricesT glUniformMatrix2x4fv+instance UnifVal [Mat3x2] where glUniform = pokeMatricesT glUniformMatrix3x2fv+instance UnifVal [Mat3x4] where glUniform = pokeMatricesT glUniformMatrix3x4fv+instance UnifVal [Mat4x2] where glUniform = pokeMatricesT glUniformMatrix4x2fv+instance UnifVal [Mat4x3] where glUniform = pokeMatricesT glUniformMatrix4x3fv+++-- Array of attributes is not supported in GLSL ES++instance GenericVertexAttribute a => ShaderAttribute a where+	glVertexAttrib idx x =+		with (V4 x 0 0 1) $ glVertexAttrib4v idx+instance GenericVertexAttribute a => ShaderAttribute (V2 a) where+	glVertexAttrib idx (V2 x y) =+		with (V4 x y 0 1) $ glVertexAttrib4v idx+instance GenericVertexAttribute a => ShaderAttribute (V3 a) where+	glVertexAttrib idx (V3 x y z) =+		with (V4 x y z 1) $ glVertexAttrib4v idx+instance GenericVertexAttribute a => ShaderAttribute (V4 a) where+	glVertexAttrib idx v4 =+		with v4 $ glVertexAttrib4v idx+instance ShaderAttribute Mat2 where+	glVertexAttrib idx (M2 (V2 a b) (V2 c d)) = do+		with (V4 a c 0 1) $ glVertexAttrib4v idx+		with (V4 b d 0 1) $ glVertexAttrib4v (idx + 1)+instance ShaderAttribute Mat3 where+	glVertexAttrib idx (M3 (V3 a b c) (V3 d e f) (V3 g h i)) = do+		with (V4 a d g 1) $ glVertexAttrib4v idx+		with (V4 b e h 1) $ glVertexAttrib4v (idx + 1)+		with (V4 c f i 1)  $ glVertexAttrib4v (idx + 2)+instance ShaderAttribute Mat4 where+	glVertexAttrib idx (M4 (V4 a b c d) (V4 e f g h) (V4 i j k l) (V4 m n o p)) = do+		with (V4 a e i m) $ glVertexAttrib4v idx+		with (V4 b f j n) $ glVertexAttrib4v (idx + 1)+		with (V4 c g k o) $ glVertexAttrib4v (idx + 2)+		with (V4 d h l p) $ glVertexAttrib4v (idx + 3)+-- XXX I'm not sure below types are actually supported by the GL+instance ShaderAttribute Mat3x2 where+	glVertexAttrib idx (M3x2 a b  c d  e f) = do+		with (V4 a c e 1) $ glVertexAttrib4v idx+		with (V4 b d f 1) $ glVertexAttrib4v (idx + 1)+instance ShaderAttribute Mat4x2 where+	glVertexAttrib idx (M4x2 a b  c d  e f  g h) = do+		with (V4 a c e g) $ glVertexAttrib4v idx+		with (V4 b d f h) $ glVertexAttrib4v (idx + 1)+instance ShaderAttribute Mat2x3 where+	glVertexAttrib idx (M2x3 a b c  d e f) = do+		with (V4 a d 0 1) $ glVertexAttrib4v idx+		with (V4 b e 0 1) $ glVertexAttrib4v (idx + 1)+		with (V4 c f 0 1) $ glVertexAttrib4v (idx + 2)+instance ShaderAttribute Mat4x3 where+	glVertexAttrib idx (M4x3 a b c  d e f  g h i  j k l) = do+		with (V4 a d g j) $ glVertexAttrib4v idx+		with (V4 b e h k) $ glVertexAttrib4v (idx + 1)+		with (V4 c f i l) $ glVertexAttrib4v (idx + 2)+instance ShaderAttribute Mat2x4 where+	glVertexAttrib idx (M2x4 a b c d  e f g h) = do+		with (V4 a e 0 1) $ glVertexAttrib4v idx+		with (V4 b f 0 1) $ glVertexAttrib4v (idx + 1)+		with (V4 c g 0 1) $ glVertexAttrib4v (idx + 2)+		with (V4 d h 0 1) $ glVertexAttrib4v (idx + 3)+instance ShaderAttribute Mat3x4 where+	glVertexAttrib idx (M3x4 a b c d  e f g h  i j k l) = do+		with (V4 a e i 1) $ glVertexAttrib4v idx+		with (V4 b f j 1) $ glVertexAttrib4v (idx + 1)+		with (V4 c g k 1) $ glVertexAttrib4v (idx + 2)+		with (V4 d h l 1) $ glVertexAttrib4v (idx + 3)++-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!+-- XXX Not completed, please add instances here+--(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)+instance AttrStruct Float (Attrib p Float) p where+	glVertexAttribPtr (Attrib (idx, 1{-size-}, normalized, divisor)) buf = do+		glEnableVertexAttribArray idx+		when (divisor /= 0) $+			glVertexAttribDivisor idx divisor+		-- XXX 3.1 spec says normalize is ignored for floating-point types, really?+		glVertexAttribPointer idx 1 (glType buf) normalized 0 nullPtr+	glVertexAttribPtr attr buf = glLog $ "Ignoring attirb: " ++ show attr+instance AttrStruct Vec2 (Attrib p Vec2) p where+	glVertexAttribPtr (Attrib (idx, 1{-size-}, normalized, divisor)) buf = do+		glEnableVertexAttribArray idx+		when (divisor /= 0) $ glVertexAttribDivisor idx divisor+		glVertexAttribPointer idx 2 (glType ([] :: [Float])) normalized 0 nullPtr+	glVertexAttribPtr attr buf = glLog $ "Ignoring attirb: " ++ show attr+instance AttrStruct Vec3 (Attrib p Vec3) p where+	glVertexAttribPtr (Attrib (idx, 1{-size-}, normalized, divisor)) buf = do+		glEnableVertexAttribArray idx+		when (divisor /= 0) $ glVertexAttribDivisor idx divisor+		glVertexAttribPointer idx 3 (glType ([] :: [Float])) normalized 0 nullPtr+	glVertexAttribPtr attr buf = glLog $ "Ignoring attirb: " ++ show attr+instance AttrStruct Vec4 (Attrib p Vec4) p where+	glVertexAttribPtr (Attrib (idx, 1{-size-}, normalized, divisor)) buf = do+		glEnableVertexAttribArray idx+		when (divisor /= 0) $ glVertexAttribDivisor idx divisor+		glVertexAttribPointer idx 4 (glType ([] :: [Float])) normalized 0 nullPtr+	glVertexAttribPtr attr buf = glLog $ "Ignoring attirb: " ++ show attr+instance AttrStruct Word8 (Attrib p Float) p where+	glVertexAttribPtr (Attrib (idx, 1{-size-}, normalized, divisor)) buf = do+		glEnableVertexAttribArray idx+		when (divisor /= 0) $ glVertexAttribDivisor idx divisor+		glVertexAttribPointer idx 1 (glType ([] :: [Word8])) normalized 0 nullPtr+	glVertexAttribPtr attr buf = glLog $ "Ignoring attirb: " ++ show attr+instance AttrStruct (V2 Word8) (Attrib p Vec2) p where+	glVertexAttribPtr (Attrib (idx, 1{-size-}, normalized, divisor)) buf = do+		glEnableVertexAttribArray idx+		when (divisor /= 0) $ glVertexAttribDivisor idx divisor+		glVertexAttribPointer idx 2 (glType ([] :: [Word8])) normalized 4 nullPtr+	glVertexAttribPtr attr buf = glLog $ "Ignoring attirb: " ++ show attr+instance AttrStruct (V3 Word8) (Attrib p Vec3) p where+	glVertexAttribPtr (Attrib (idx, 1{-size-}, normalized, divisor)) buf = do+		glEnableVertexAttribArray idx+		when (divisor /= 0) $ glVertexAttribDivisor idx divisor+		glVertexAttribPointer idx 2 (glType ([] :: [Word8])) normalized 4 nullPtr+	glVertexAttribPtr attr buf = glLog $ "Ignoring attirb: " ++ show attr+instance AttrStruct (V4 Word8) (Attrib p Vec4) p where+	glVertexAttribPtr (Attrib (idx, 1{-size-}, normalized, divisor)) buf = do+		glEnableVertexAttribArray idx+		when (divisor /= 0) $ glVertexAttribDivisor idx divisor+		glVertexAttribPointer idx 2 (glType ([] :: [Word8])) normalized 0 nullPtr+	glVertexAttribPtr attr buf = glLog $ "Ignoring attirb: " ++ show attr++{-+class (Storable a, Num a) => AttrElement a where+instance AttrElement Word8+instance AttrElement Word16+instance AttrElement Word32+instance AttrElement Int8+instance AttrElement Int16+instance AttrElement Int32+instance AttrElement Float+instance AttrElement HalfFloat+instance AttrElement FixedFloat++case splitTyConApp values of+getrepl (con, args)+	| con == float = [(1, 4, flo)]+	| con == t2 = [(2, 2*size, typ)] where [(_,size,typ)] = getrepl $ head args+	| con == m2 = [(2, 2*size, typ), (2, 2*size, typ)] where [(_,size,typ)] = getrepl . head $ args+	| con == Int10x3_2 = [(4,4,Int10x3_2)]+	| otherwise = concatMap getrepl args+Float+-> [(1, 4, flo)]+Vec2+-> [(2, 8, flo)]+Mat2+-> [(2, 8, flo), (2, 8, flo)]+((,) Word8 Word8)+-> [(1, 4, word8), (1, 4, word8)]+((,) (M2 Float) (M2 Word8))+-> [(2, 8, flo), (2, 8, flo), (2, 2, word8), (2, 2, word8)]+Int10x3_2+-> [(4, 4, Int10x3_2)]+stride = sum $ map snd3 types+foldl (\offset (size, align, typ)-> glVertexAttribPointer ...>> return offset+align) 0 types+data = Spl | Mat+word8 = typeRep (Proxy :: Proxy Word8)+word16 = typeRep (Proxy :: Proxy Word16)+word32 = typeRep (Proxy :: Proxy Word32)+int8 = typeRep (Proxy :: Proxy Int8)+int16 = typeRep (Proxy :: Proxy Int16)+int32 = typeRep (Proxy :: Proxy Int32)+float = typeRep (Proxy :: Proxy Float)++class Storable a => AttrVal a where+-- scalar+instance AttrElement a => AttrVal a+-- vector+instance AttrElement a => AttrVal (V2 a)+instance AttrElement a => AttrVal (V3 a)+instance AttrElement a => AttrVal (V4 a)+instance AttrVal Int10x3_2+instance AttrVal Word10x3_2+-- matrix+instance AttrElement a => AttrVal (M2 a)+instance AttrElement a => AttrVal (M3 a)+instance AttrElement a => AttrVal (M4 a)+instance AttrElement a => AttrVal (M2x3 a)+instance AttrElement a => AttrVal (M2x4 a)+instance AttrElement a => AttrVal (M3x2 a)+instance AttrElement a => AttrVal (M3x4 a)+instance AttrElement a => AttrVal (M4x2 a)+instance AttrElement a => AttrVal (M4x3 a)+{-- matrix (colomn major)+instance AttrVal (T2 Int10x3_2)+instance AttrVal (T3 Int10x3_2)+instance AttrVal (T4 Int10x3_2)+instance AttrVal (T2 Word10x3_2)+instance AttrVal (T3 Word10x3_2)+instance AttrVal (T4 Word10x3_2)+-}++--class AttrStruct a where+--	pokeAll :: Ptr () -> a -> IO ()++--instance AttrVal a => AttrStruct a where+--	pokeAll p a = poke (castPtr p) a+--instance (AttrVal a, AttrVal b) => AttrStruct (a, b) where+--	pokeAll p (a,b) = do+--		poke (castPtr p) a+--		pokeByteOff (castPtr p) (alignment a) b+--instance (AttrVal a, AttrVal b, AttrVal c) => AttrStruct (a, b, c) where+--	pokeAll p (a,b,c) = do+--		poke (castPtr p) a+--		pokeByteOff (castPtr p) offset1 b+--		pokeByteOff (castPtr p) offset2 c+--		where offset1 = alignment a; offset2 = offset1 + alignment b+--instance (AttrVal a, AttrVal b, AttrVal c, AttrVal d) => AttrStruct (a, b, c, d)+--instance (AttrVal a, AttrVal b, AttrVal c, AttrVal d, AttrVal e) => AttrStruct (a, b, c, d, e)+--instance (AttrVal a, AttrVal b, AttrVal c, AttrVal d, AttrVal e, AttrVal f) => AttrStruct (a, b, c, d, e, f)+--instance (AttrVal a, AttrVal b, AttrVal c, AttrVal d, AttrVal e, AttrVal f, AttrVal g) => AttrStruct (a, b, c, d, e, f, g)+--instance (AttrVal a, AttrVal b, AttrVal c, AttrVal d, AttrVal e, AttrVal f, AttrVal g, AttrVal h) => AttrStruct (a, b, c, d, e, f, g, h)+--instance (AttrVal a, AttrVal b, AttrVal c, AttrVal d, AttrVal e, AttrVal f, AttrVal g, AttrVal h, AttrVal i) => AttrStruct (a, b, c, d, e, f, g, h, i)+--instance (AttrVal a, AttrVal b, AttrVal c, AttrVal d, AttrVal e, AttrVal f, AttrVal g, AttrVal h, AttrVal i, AttrVal j) => AttrStruct (a, b, c, d, e, f, g, h, i, j)++--instance Storable FixedFloat where+--	sizeOf _ = 4; alignment _ = 4; peek = undefined+--	poke p (FixedFloat x) = poke (castPtr p) x++--instance Storable Int10x3_2 where+--	sizeOf _ = 4; alignment _ = 4; peek = undefined+--	poke p (Int10x3_2 x) = poke (castPtr p) x++--instance Storable Word10x3_2 where+--	sizeOf _ = 4; alignment _ = 4; peek = undefined+--	poke p (Word10x3_2 x) = poke (castPtr p) x++--instance Storable HalfFloat where+--	sizeOf _ = 2; alignment _ = 4; peek = undefined+--	poke p (HalfFloat x) = poke (castPtr p) x+-}+++
+ Graphics/TextureContainer/KTX.hs view
@@ -0,0 +1,124 @@+{-# LANGUAGE RecordWildCards #-}+-- | Khronos Texture Container Format+-- +-- See also <http://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/>+module Graphics.TextureContainer.KTX where+import Control.Applicative+import Control.Exception+import Control.Monad+import qualified Data.ByteString as B+import Data.Packer+import Data.Word++data Ktx = Ktx+	{ ktxName :: FilePath -- ^ for debugging+	, ktxContent :: B.ByteString -- ^ holding the original ForeignPtr.+	, ktxGlType :: Word32+	, ktxGlTypeSize :: Word32+	, ktxGlFormat :: Word32+	, ktxGlInternalFormat :: Word32+	, ktxGlBaseInternalFormat :: Word32+	, ktxPixelWidth :: Word32+	, ktxPixelHeight :: Word32+	, ktxPixelDepth :: Word32+	, ktxNumElems :: Word32+	, ktxNumFaces :: Word32+	, ktxNumMipLevels :: Word32+	, ktxMap :: [(B.ByteString, B.ByteString)] -- ^ (utf8, any)+	-- Note that if a value is utf8, it is NULL terminated.+	, ktxImage :: [[B.ByteString]]+	}  deriving Show++unpackKtx :: FilePath -> B.ByteString -> Unpacking Ktx+unpackKtx name orig = do+	let w = getWord32+	+	-- '«', 'K', 'T', 'X', ' ', '1', '1', '»', '\r', '\n', '\x1A', '\n'+	(0x58544BAB, 0xBB313120, 0x0A1A0A0D) <- (,,) <$> w <*> w <*> w+	+	-- Endianness+	-- Assuming Big-endian is a loser of history, just ignore it.+	-- Note: All modern platforms (Android, iOS, Windows, ...)+	-- runs Little-endian nevertheless the processor is bi-endian.+	0x04030201 <- getWord32+	+	ktx <- Ktx name orig <$> w <*> w <*> w <*> w <*> w <*> w+			<*> w <*> w <*> w <*> w <*> w++	bytesOfKeyValueData <- getWord32+	let getKVP 0 = return []+	    getKVP i = do+		keyAndValueByteSize <- getWord32+		x <- getBytes (fromIntegral keyAndValueByteSize)+		let padding = 3 - (keyAndValueByteSize + 3) `mod` 4+		unpackSkip (fromIntegral padding)+		xs <- getKVP (i - keyAndValueByteSize - padding)+		return (x:xs)+	kvp <- map (B.breakByte 0) <$> getKVP bytesOfKeyValueData+	let Ktx{..} = ktx kvp []++	imgs <- forM [1..max 1 ktxNumMipLevels] $ \_ -> do+		imageSize <- getWord32+		forM [1..max 1 ktxNumFaces] $ \_ -> do+			img <- getBytes (fromIntegral imageSize)+			unpackSkip $ fromIntegral (3 - (imageSize + 3) `mod` 4)+			return img++	return $ ktx kvp imgs+++ktxFromFile path = B.readFile path >>= return . readKtx path++readKtx :: FilePath -> B.ByteString -> Ktx+readKtx path bs = runUnpacking (unpackKtx path bs) bs++tryKtx :: FilePath -> B.ByteString -> Either SomeException Ktx+tryKtx path bs = tryUnpacking (unpackKtx path bs) bs++{-+type MipmapData = [Face or ArrayElements]+type ArrayElements = B.ByteString+type Face = B.ByteString++Byte[12] identifier+UInt32 endianness+UInt32 glType+UInt32 glTypeSize+UInt32 glFormat+Uint32 glInternalFormat+Uint32 glBaseInternalFormat+UInt32 pixelWidth+UInt32 pixelHeight+UInt32 pixelDepth+UInt32 numberOfArrayElements+UInt32 numberOfFaces+UInt32 numberOfMipmapLevels+UInt32 bytesOfKeyValueData+  +for each keyValuePair that fits in bytesOfKeyValueData+    UInt32   keyAndValueByteSize+    Byte     keyAndValue[keyAndValueByteSize]+    Byte     valuePadding[3 - ((keyAndValueByteSize + 3) % 4)]+end+  +for each mipmap_level in numberOfMipmapLevels*+    UInt32 imageSize; +    for each array_element in numberOfArrayElements*+       for each face in numberOfFaces+           for each z_slice in pixelDepth*+               for each row or row_of_blocks in pixelHeight*+                   for each pixel or block_of_pixels in pixelWidth+                       Byte data[format-specific-number-of-bytes]**+                   end+               end+           end+           Byte cubePadding[0-3]+       end+    end+    Byte mipPadding[3 - ((imageSize + 3) % 4)]+end++* Replace with 1 if this field is 0.++** Uncompressed texture data matches a GL_UNPACK_ALIGNMENT of 4.+-}
+ Graphics/TextureContainer/PKM.hs view
@@ -0,0 +1,90 @@+{-# LANGUAGE RecordWildCards, OverloadedStrings #-}+-- | Ericsson's ETC1\/ETC2\/EAC Texture Container Format+module Graphics.TextureContainer.PKM where+import Control.Applicative+import Control.Exception+import Control.Monad+import qualified Data.ByteString as B+import Data.Packer+import Data.Word+import Graphics.TextureContainer.KTX++data Pkm = Pkm+	{ pkmName :: FilePath+	, pkmContent :: B.ByteString+	, pkmVersion :: Word16+	, pkmType :: Word16+	, pkmWidth :: Word16+	, pkmHeight :: Word16+	, pkmActiveW :: Word16+	, pkmActiveH :: Word16+	, pkmImage :: B.ByteString+	} deriving Show++unpackPkm :: FilePath -> B.ByteString -> Unpacking Pkm+unpackPkm name orig = do+	-- 'PKM '+	0x204d4b50 <- getWord32+	+	let w = getWord16BE+	pkm <- Pkm name orig <$> w <*> w <*> w <*> w <*> w <*> w+	-- XXX calc size from pkmVersion, pkmType+	let size = pkmActiveW (pkm "") * pkmActiveH (pkm "") `div` 2+	pkm <$> getBytes (fromIntegral size)++pkmToKtx :: Pkm -> Ktx+pkmToKtx Pkm{..} = Ktx+	{ ktxName = pkmName+	, ktxContent = pkmContent+	, ktxGlType = 0+	, ktxGlTypeSize = 1+	, ktxGlFormat = 0+	, ktxGlInternalFormat = fromPkmType pkmVersion pkmType+	, ktxGlBaseInternalFormat = 0+	, ktxPixelWidth = fromIntegral pkmWidth+	, ktxPixelHeight = fromIntegral pkmHeight+	, ktxPixelDepth = 0+	, ktxNumElems = 0+	, ktxNumFaces = 1+	, ktxNumMipLevels = 1+	, ktxMap = []+	, ktxImage = [[pkmImage]]+	}+	where+		-- 12592 == '1''0', 12848 == '2''0'+		fromPkmType 12592 0 = 36196 -- ?+		fromPkmType 12592 1 = undefined+		fromPkmType 12592 2 = undefined+		fromPkmType 12592 3 = undefined+		fromPkmType 12848 0 = undefined+		fromPkmType 12848 1 = undefined+		fromPkmType 12848 2 = undefined+		fromPkmType 12848 3 = undefined+		fromPkmType 12848 4 = undefined+		fromPkmType 12848 5 = undefined+		fromPkmType 12848 6 = undefined+		fromPkmType 12848 7 = undefined+		fromPkmType 12848 8 = undefined++fromPkmFile path = B.readFile path >>= return . readPkm path++readPkm :: FilePath -> B.ByteString -> Pkm+readPkm path bs = runUnpacking (unpackPkm path bs) bs++{-++// 16bytes big-endian+unsigned int32     magic;     // 'PKM '+unsigned short16   version;   // '10' or '20'+unsigned short16   type;      // See below+unsigned short16   width;     // +unsigned short16   height;    // +unsigned short16   active_w;  // +unsigned short16   active_h;  // ++version 1.0+  type: 0=ETC1-RGB, 1=ETC1-RGBA, 2=ETC1-RGB-MIP, 3=ETC1-RGBA-MIP+version 2.0+  type: 0=ETC1_RGB, 1=ETC2_RGB, 2=ETC2_RGBA_OLD, 3=ETC2_RGBA, 4=ETC2_RGBA1, 5=ETC2_R, 6=ETC2_RG, 7=ETC2_SIGNED_R, 8=ETC2_SIGNED_R++-}
+ LICENSE view
@@ -0,0 +1,165 @@+                  GNU LESSER GENERAL PUBLIC LICENSE+                       Version 3, 29 June 2007++ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.+++  This version of the GNU Lesser General Public License incorporates+the terms and conditions of version 3 of the GNU General Public+License, supplemented by the additional permissions listed below.++  0. Additional Definitions.++  As used herein, "this License" refers to version 3 of the GNU Lesser+General Public License, and the "GNU GPL" refers to version 3 of the GNU+General Public License.++  "The Library" refers to a covered work governed by this License,+other than an Application or a Combined Work as defined below.++  An "Application" is any work that makes use of an interface provided+by the Library, but which is not otherwise based on the Library.+Defining a subclass of a class defined by the Library is deemed a mode+of using an interface provided by the Library.++  A "Combined Work" is a work produced by combining or linking an+Application with the Library.  The particular version of the Library+with which the Combined Work was made is also called the "Linked+Version".++  The "Minimal Corresponding Source" for a Combined Work means the+Corresponding Source for the Combined Work, excluding any source code+for portions of the Combined Work that, considered in isolation, are+based on the Application, and not on the Linked Version.++  The "Corresponding Application Code" for a Combined Work means the+object code and/or source code for the Application, including any data+and utility programs needed for reproducing the Combined Work from the+Application, but excluding the System Libraries of the Combined Work.++  1. Exception to Section 3 of the GNU GPL.++  You may convey a covered work under sections 3 and 4 of this License+without being bound by section 3 of the GNU GPL.++  2. Conveying Modified Versions.++  If you modify a copy of the Library, and, in your modifications, a+facility refers to a function or data to be supplied by an Application+that uses the facility (other than as an argument passed when the+facility is invoked), then you may convey a copy of the modified+version:++   a) under this License, provided that you make a good faith effort to+   ensure that, in the event an Application does not supply the+   function or data, the facility still operates, and performs+   whatever part of its purpose remains meaningful, or++   b) under the GNU GPL, with none of the additional permissions of+   this License applicable to that copy.++  3. Object Code Incorporating Material from Library Header Files.++  The object code form of an Application may incorporate material from+a header file that is part of the Library.  You may convey such object+code under terms of your choice, provided that, if the incorporated+material is not limited to numerical parameters, data structure+layouts and accessors, or small macros, inline functions and templates+(ten or fewer lines in length), you do both of the following:++   a) Give prominent notice with each copy of the object code that the+   Library is used in it and that the Library and its use are+   covered by this License.++   b) Accompany the object code with a copy of the GNU GPL and this license+   document.++  4. Combined Works.++  You may convey a Combined Work under terms of your choice that,+taken together, effectively do not restrict modification of the+portions of the Library contained in the Combined Work and reverse+engineering for debugging such modifications, if you also do each of+the following:++   a) Give prominent notice with each copy of the Combined Work that+   the Library is used in it and that the Library and its use are+   covered by this License.++   b) Accompany the Combined Work with a copy of the GNU GPL and this license+   document.++   c) For a Combined Work that displays copyright notices during+   execution, include the copyright notice for the Library among+   these notices, as well as a reference directing the user to the+   copies of the GNU GPL and this license document.++   d) Do one of the following:++       0) Convey the Minimal Corresponding Source under the terms of this+       License, and the Corresponding Application Code in a form+       suitable for, and under terms that permit, the user to+       recombine or relink the Application with a modified version of+       the Linked Version to produce a modified Combined Work, in the+       manner specified by section 6 of the GNU GPL for conveying+       Corresponding Source.++       1) Use a suitable shared library mechanism for linking with the+       Library.  A suitable mechanism is one that (a) uses at run time+       a copy of the Library already present on the user's computer+       system, and (b) will operate properly with a modified version+       of the Library that is interface-compatible with the Linked+       Version.++   e) Provide Installation Information, but only if you would otherwise+   be required to provide such information under section 6 of the+   GNU GPL, and only to the extent that such information is+   necessary to install and execute a modified version of the+   Combined Work produced by recombining or relinking the+   Application with a modified version of the Linked Version. (If+   you use option 4d0, the Installation Information must accompany+   the Minimal Corresponding Source and Corresponding Application+   Code. If you use option 4d1, you must provide the Installation+   Information in the manner specified by section 6 of the GNU GPL+   for conveying Corresponding Source.)++  5. Combined Libraries.++  You may place library facilities that are a work based on the+Library side by side in a single library together with other library+facilities that are not Applications and are not covered by this+License, and convey such a combined library under terms of your+choice, if you do both of the following:++   a) Accompany the combined library with a copy of the same work based+   on the Library, uncombined with any other library facilities,+   conveyed under the terms of this License.++   b) Give prominent notice with the combined library that part of it+   is a work based on the Library, and explaining where to find the+   accompanying uncombined form of the same work.++  6. Revised Versions of the GNU Lesser General Public License.++  The Free Software Foundation may publish revised and/or new versions+of the GNU Lesser General Public License from time to time. Such new+versions will be similar in spirit to the present version, but may+differ in detail to address new problems or concerns.++  Each version is given a distinguishing version number. If the+Library as you received it specifies that a certain numbered version+of the GNU Lesser General Public License "or any later version"+applies to it, you have the option of following the terms and+conditions either of that published version or of any later version+published by the Free Software Foundation. If the Library as you+received it does not specify a version number of the GNU Lesser+General Public License, you may choose any version of the GNU Lesser+General Public License ever published by the Free Software Foundation.++  If the Library as you received it specifies that a proxy can decide+whether future versions of the GNU Lesser General Public License shall+apply, that proxy's public statement of acceptance of any version is+permanent authorization for you to choose that version for the+Library.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ include/EGL/egl.h view
@@ -0,0 +1,329 @@+/* -*- mode: c; tab-width: 8; -*- */+/* vi: set sw=4 ts=8: */+/* Reference version of egl.h for EGL 1.4.+ * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $+ */++/*+** Copyright (c) 2007-2009 The Khronos Group Inc.+**+** Permission is hereby granted, free of charge, to any person obtaining a+** copy of this software and/or associated documentation files (the+** "Materials"), to deal in the Materials without restriction, including+** without limitation the rights to use, copy, modify, merge, publish,+** distribute, sublicense, and/or sell copies of the Materials, and to+** permit persons to whom the Materials are furnished to do so, subject to+** the following conditions:+**+** The above copyright notice and this permission notice shall be included+** in all copies or substantial portions of the Materials.+**+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.+*/++#ifndef __egl_h_+#define __egl_h_++/* All platform-dependent types and macro boilerplate (such as EGLAPI+ * and EGLAPIENTRY) should go in eglplatform.h.+ */+#include <EGL/eglplatform.h>++#ifdef __cplusplus+extern "C" {+#endif++/* EGL Types */+/* EGLint is defined in eglplatform.h */+typedef unsigned int EGLBoolean;+typedef unsigned int EGLenum;+typedef void *EGLConfig;+typedef void *EGLContext;+typedef void *EGLDisplay;+typedef void *EGLSurface;+typedef void *EGLClientBuffer;++/* EGL Versioning */+#define EGL_VERSION_1_0			1+#define EGL_VERSION_1_1			1+#define EGL_VERSION_1_2			1+#define EGL_VERSION_1_3			1+#define EGL_VERSION_1_4			1++/* EGL Enumerants. Bitmasks and other exceptional cases aside, most+ * enums are assigned unique values starting at 0x3000.+ */++/* EGL aliases */+#define EGL_FALSE			0+#define EGL_TRUE			1++/* Out-of-band handle values */+#define EGL_DEFAULT_DISPLAY		((EGLNativeDisplayType)0)+#define EGL_NO_CONTEXT			((EGLContext)0)+#define EGL_NO_DISPLAY			((EGLDisplay)0)+#define EGL_NO_SURFACE			((EGLSurface)0)++/* Out-of-band attribute value */+#define EGL_DONT_CARE			((EGLint)-1)++/* Errors / GetError return values */+#define EGL_SUCCESS			0x3000+#define EGL_NOT_INITIALIZED		0x3001+#define EGL_BAD_ACCESS			0x3002+#define EGL_BAD_ALLOC			0x3003+#define EGL_BAD_ATTRIBUTE		0x3004+#define EGL_BAD_CONFIG			0x3005+#define EGL_BAD_CONTEXT			0x3006+#define EGL_BAD_CURRENT_SURFACE		0x3007+#define EGL_BAD_DISPLAY			0x3008+#define EGL_BAD_MATCH			0x3009+#define EGL_BAD_NATIVE_PIXMAP		0x300A+#define EGL_BAD_NATIVE_WINDOW		0x300B+#define EGL_BAD_PARAMETER		0x300C+#define EGL_BAD_SURFACE			0x300D+#define EGL_CONTEXT_LOST		0x300E	/* EGL 1.1 - IMG_power_management */++/* Reserved 0x300F-0x301F for additional errors */++/* Config attributes */+#define EGL_BUFFER_SIZE			0x3020+#define EGL_ALPHA_SIZE			0x3021+#define EGL_BLUE_SIZE			0x3022+#define EGL_GREEN_SIZE			0x3023+#define EGL_RED_SIZE			0x3024+#define EGL_DEPTH_SIZE			0x3025+#define EGL_STENCIL_SIZE		0x3026+#define EGL_CONFIG_CAVEAT		0x3027+#define EGL_CONFIG_ID			0x3028+#define EGL_LEVEL			0x3029+#define EGL_MAX_PBUFFER_HEIGHT		0x302A+#define EGL_MAX_PBUFFER_PIXELS		0x302B+#define EGL_MAX_PBUFFER_WIDTH		0x302C+#define EGL_NATIVE_RENDERABLE		0x302D+#define EGL_NATIVE_VISUAL_ID		0x302E+#define EGL_NATIVE_VISUAL_TYPE		0x302F+#define EGL_SAMPLES			0x3031+#define EGL_SAMPLE_BUFFERS		0x3032+#define EGL_SURFACE_TYPE		0x3033+#define EGL_TRANSPARENT_TYPE		0x3034+#define EGL_TRANSPARENT_BLUE_VALUE	0x3035+#define EGL_TRANSPARENT_GREEN_VALUE	0x3036+#define EGL_TRANSPARENT_RED_VALUE	0x3037+#define EGL_NONE			0x3038	/* Attrib list terminator */+#define EGL_BIND_TO_TEXTURE_RGB		0x3039+#define EGL_BIND_TO_TEXTURE_RGBA	0x303A+#define EGL_MIN_SWAP_INTERVAL		0x303B+#define EGL_MAX_SWAP_INTERVAL		0x303C+#define EGL_LUMINANCE_SIZE		0x303D+#define EGL_ALPHA_MASK_SIZE		0x303E+#define EGL_COLOR_BUFFER_TYPE		0x303F+#define EGL_RENDERABLE_TYPE		0x3040+#define EGL_MATCH_NATIVE_PIXMAP		0x3041	/* Pseudo-attribute (not queryable) */+#define EGL_CONFORMANT			0x3042++/* Reserved 0x3041-0x304F for additional config attributes */++/* Config attribute values */+#define EGL_SLOW_CONFIG			0x3050	/* EGL_CONFIG_CAVEAT value */+#define EGL_NON_CONFORMANT_CONFIG	0x3051	/* EGL_CONFIG_CAVEAT value */+#define EGL_TRANSPARENT_RGB		0x3052	/* EGL_TRANSPARENT_TYPE value */+#define EGL_RGB_BUFFER			0x308E	/* EGL_COLOR_BUFFER_TYPE value */+#define EGL_LUMINANCE_BUFFER		0x308F	/* EGL_COLOR_BUFFER_TYPE value */++/* More config attribute values, for EGL_TEXTURE_FORMAT */+#define EGL_NO_TEXTURE			0x305C+#define EGL_TEXTURE_RGB			0x305D+#define EGL_TEXTURE_RGBA		0x305E+#define EGL_TEXTURE_2D			0x305F++/* Config attribute mask bits */+#define EGL_PBUFFER_BIT			0x0001	/* EGL_SURFACE_TYPE mask bits */+#define EGL_PIXMAP_BIT			0x0002	/* EGL_SURFACE_TYPE mask bits */+#define EGL_WINDOW_BIT			0x0004	/* EGL_SURFACE_TYPE mask bits */+#define EGL_VG_COLORSPACE_LINEAR_BIT	0x0020	/* EGL_SURFACE_TYPE mask bits */+#define EGL_VG_ALPHA_FORMAT_PRE_BIT	0x0040	/* EGL_SURFACE_TYPE mask bits */+#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200	/* EGL_SURFACE_TYPE mask bits */+#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400	/* EGL_SURFACE_TYPE mask bits */++#define EGL_OPENGL_ES_BIT		0x0001	/* EGL_RENDERABLE_TYPE mask bits */+#define EGL_OPENVG_BIT			0x0002	/* EGL_RENDERABLE_TYPE mask bits */+#define EGL_OPENGL_ES2_BIT		0x0004	/* EGL_RENDERABLE_TYPE mask bits */+#define EGL_OPENGL_BIT			0x0008	/* EGL_RENDERABLE_TYPE mask bits */++/* QueryString targets */+#define EGL_VENDOR			0x3053+#define EGL_VERSION			0x3054+#define EGL_EXTENSIONS			0x3055+#define EGL_CLIENT_APIS			0x308D++/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */+#define EGL_HEIGHT			0x3056+#define EGL_WIDTH			0x3057+#define EGL_LARGEST_PBUFFER		0x3058+#define EGL_TEXTURE_FORMAT		0x3080+#define EGL_TEXTURE_TARGET		0x3081+#define EGL_MIPMAP_TEXTURE		0x3082+#define EGL_MIPMAP_LEVEL		0x3083+#define EGL_RENDER_BUFFER		0x3086+#define EGL_VG_COLORSPACE		0x3087+#define EGL_VG_ALPHA_FORMAT		0x3088+#define EGL_HORIZONTAL_RESOLUTION	0x3090+#define EGL_VERTICAL_RESOLUTION		0x3091+#define EGL_PIXEL_ASPECT_RATIO		0x3092+#define EGL_SWAP_BEHAVIOR		0x3093+#define EGL_MULTISAMPLE_RESOLVE		0x3099++/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */+#define EGL_BACK_BUFFER			0x3084+#define EGL_SINGLE_BUFFER		0x3085++/* OpenVG color spaces */+#define EGL_VG_COLORSPACE_sRGB		0x3089	/* EGL_VG_COLORSPACE value */+#define EGL_VG_COLORSPACE_LINEAR	0x308A	/* EGL_VG_COLORSPACE value */++/* OpenVG alpha formats */+#define EGL_VG_ALPHA_FORMAT_NONPRE	0x308B	/* EGL_ALPHA_FORMAT value */+#define EGL_VG_ALPHA_FORMAT_PRE		0x308C	/* EGL_ALPHA_FORMAT value */++/* Constant scale factor by which fractional display resolutions &+ * aspect ratio are scaled when queried as integer values.+ */+#define EGL_DISPLAY_SCALING		10000++/* Unknown display resolution/aspect ratio */+#define EGL_UNKNOWN			((EGLint)-1)++/* Back buffer swap behaviors */+#define EGL_BUFFER_PRESERVED		0x3094	/* EGL_SWAP_BEHAVIOR value */+#define EGL_BUFFER_DESTROYED		0x3095	/* EGL_SWAP_BEHAVIOR value */++/* CreatePbufferFromClientBuffer buffer types */+#define EGL_OPENVG_IMAGE		0x3096++/* QueryContext targets */+#define EGL_CONTEXT_CLIENT_TYPE		0x3097++/* CreateContext attributes */+#define EGL_CONTEXT_CLIENT_VERSION	0x3098++/* Multisample resolution behaviors */+#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A	/* EGL_MULTISAMPLE_RESOLVE value */+#define EGL_MULTISAMPLE_RESOLVE_BOX	0x309B	/* EGL_MULTISAMPLE_RESOLVE value */++/* BindAPI/QueryAPI targets */+#define EGL_OPENGL_ES_API		0x30A0+#define EGL_OPENVG_API			0x30A1+#define EGL_OPENGL_API			0x30A2++/* GetCurrentSurface targets */+#define EGL_DRAW			0x3059+#define EGL_READ			0x305A++/* WaitNative engines */+#define EGL_CORE_NATIVE_ENGINE		0x305B++/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */+#define EGL_COLORSPACE			EGL_VG_COLORSPACE+#define EGL_ALPHA_FORMAT		EGL_VG_ALPHA_FORMAT+#define EGL_COLORSPACE_sRGB		EGL_VG_COLORSPACE_sRGB+#define EGL_COLORSPACE_LINEAR		EGL_VG_COLORSPACE_LINEAR+#define EGL_ALPHA_FORMAT_NONPRE		EGL_VG_ALPHA_FORMAT_NONPRE+#define EGL_ALPHA_FORMAT_PRE		EGL_VG_ALPHA_FORMAT_PRE++/* EGL extensions must request enum blocks from the Khronos+ * API Registrar, who maintains the enumerant registry. Submit+ * a bug in Khronos Bugzilla against task "Registry".+ */++++/* EGL Functions */++EGLAPI EGLint EGLAPIENTRY eglGetError(void);++EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);+EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);+EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);++EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);++EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,+			 EGLint config_size, EGLint *num_config);+EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,+			   EGLConfig *configs, EGLint config_size,+			   EGLint *num_config);+EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,+			      EGLint attribute, EGLint *value);++EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,+				  EGLNativeWindowType win,+				  const EGLint *attrib_list);+EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,+				   const EGLint *attrib_list);+EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,+				  EGLNativePixmapType pixmap,+				  const EGLint *attrib_list);+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);+EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,+			   EGLint attribute, EGLint *value);++EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);+EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);++EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);++EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);++EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(+	      EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,+	      EGLConfig config, const EGLint *attrib_list);++EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,+			    EGLint attribute, EGLint value);+EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);+EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);+++EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);+++EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,+			    EGLContext share_context,+			    const EGLint *attrib_list);+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);+EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,+			  EGLSurface read, EGLContext ctx);++EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);+EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);+EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);+EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,+			   EGLint attribute, EGLint *value);++EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);+EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);+EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);+EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,+			  EGLNativePixmapType target);++/* This is a generic function pointer type, whose name indicates it must+ * be cast to the proper type *and calling convention* before use.+ */+typedef void (*__eglMustCastToProperFunctionPointerType)(void);++/* Now, define eglGetProcAddress using the generic function ptr. type */+EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY+       eglGetProcAddress(const char *procname);++#ifdef __cplusplus+}+#endif++#endif /* __egl_h_ */
+ include/EGL/eglext.h view
@@ -0,0 +1,657 @@+#ifndef __eglext_h_+#define __eglext_h_ 1++#ifdef __cplusplus+extern "C" {+#endif++/*+** Copyright (c) 2013-2014 The Khronos Group Inc.+**+** Permission is hereby granted, free of charge, to any person obtaining a+** copy of this software and/or associated documentation files (the+** "Materials"), to deal in the Materials without restriction, including+** without limitation the rights to use, copy, modify, merge, publish,+** distribute, sublicense, and/or sell copies of the Materials, and to+** permit persons to whom the Materials are furnished to do so, subject to+** the following conditions:+**+** The above copyright notice and this permission notice shall be included+** in all copies or substantial portions of the Materials.+**+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.+*/+/*+** This header is generated from the Khronos OpenGL / OpenGL ES XML+** API Registry. The current version of the Registry, generator scripts+** used to make the header, and the header can be found at+**   http://www.opengl.org/registry/+**+** Khronos $Revision: 25231 $ on $Date: 2014-02-03 21:35:17 -0800 (Mon, 03 Feb 2014) $+*/++#include <EGL/eglplatform.h>++#define EGL_EGLEXT_VERSION 20140203++/* Generated C header for:+ * API: egl+ * Versions considered: .*+ * Versions emitted: _nomatch_^+ * Default extensions included: egl+ * Additional extensions included: _nomatch_^+ * Extensions removed: _nomatch_^+ */++#ifndef EGL_KHR_cl_event+#define EGL_KHR_cl_event 1+#define EGL_CL_EVENT_HANDLE_KHR           0x309C+#define EGL_SYNC_CL_EVENT_KHR             0x30FE+#define EGL_SYNC_CL_EVENT_COMPLETE_KHR    0x30FF+#endif /* EGL_KHR_cl_event */++#ifndef EGL_KHR_cl_event2+#define EGL_KHR_cl_event2 1+typedef void *EGLSyncKHR;+typedef intptr_t EGLAttribKHR;+typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list);+#endif+#endif /* EGL_KHR_cl_event2 */++#ifndef EGL_KHR_client_get_all_proc_addresses+#define EGL_KHR_client_get_all_proc_addresses 1+#endif /* EGL_KHR_client_get_all_proc_addresses */++#ifndef EGL_KHR_config_attribs+#define EGL_KHR_config_attribs 1+#define EGL_CONFORMANT_KHR                0x3042+#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR  0x0020+#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR   0x0040+#endif /* EGL_KHR_config_attribs */++#ifndef EGL_KHR_create_context+#define EGL_KHR_create_context 1+#define EGL_CONTEXT_MAJOR_VERSION_KHR     0x3098+#define EGL_CONTEXT_MINOR_VERSION_KHR     0x30FB+#define EGL_CONTEXT_FLAGS_KHR             0x30FC+#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD+#define EGL_NO_RESET_NOTIFICATION_KHR     0x31BE+#define EGL_LOSE_CONTEXT_ON_RESET_KHR     0x31BF+#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR  0x00000001+#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004+#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001+#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002+#define EGL_OPENGL_ES3_BIT_KHR            0x00000040+#endif /* EGL_KHR_create_context */++#ifndef EGL_KHR_fence_sync+#define EGL_KHR_fence_sync 1+#ifdef KHRONOS_SUPPORT_INT64+#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0+#define EGL_SYNC_CONDITION_KHR            0x30F8+#define EGL_SYNC_FENCE_KHR                0x30F9+#endif /* KHRONOS_SUPPORT_INT64 */+#endif /* EGL_KHR_fence_sync */++#ifndef EGL_KHR_get_all_proc_addresses+#define EGL_KHR_get_all_proc_addresses 1+#endif /* EGL_KHR_get_all_proc_addresses */++#ifndef EGL_KHR_gl_colorspace+#define EGL_KHR_gl_colorspace 1+#define EGL_GL_COLORSPACE_KHR             0x309D+#define EGL_GL_COLORSPACE_SRGB_KHR        0x3089+#define EGL_GL_COLORSPACE_LINEAR_KHR      0x308A+#endif /* EGL_KHR_gl_colorspace */++#ifndef EGL_KHR_gl_renderbuffer_image+#define EGL_KHR_gl_renderbuffer_image 1+#define EGL_GL_RENDERBUFFER_KHR           0x30B9+#endif /* EGL_KHR_gl_renderbuffer_image */++#ifndef EGL_KHR_gl_texture_2D_image+#define EGL_KHR_gl_texture_2D_image 1+#define EGL_GL_TEXTURE_2D_KHR             0x30B1+#define EGL_GL_TEXTURE_LEVEL_KHR          0x30BC+#endif /* EGL_KHR_gl_texture_2D_image */++#ifndef EGL_KHR_gl_texture_3D_image+#define EGL_KHR_gl_texture_3D_image 1+#define EGL_GL_TEXTURE_3D_KHR             0x30B2+#define EGL_GL_TEXTURE_ZOFFSET_KHR        0x30BD+#endif /* EGL_KHR_gl_texture_3D_image */++#ifndef EGL_KHR_gl_texture_cubemap_image+#define EGL_KHR_gl_texture_cubemap_image 1+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8+#endif /* EGL_KHR_gl_texture_cubemap_image */++#ifndef EGL_KHR_image+#define EGL_KHR_image 1+typedef void *EGLImageKHR;+#define EGL_NATIVE_PIXMAP_KHR             0x30B0+#define EGL_NO_IMAGE_KHR                  ((EGLImageKHR)0)+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);+#endif+#endif /* EGL_KHR_image */++#ifndef EGL_KHR_image_base+#define EGL_KHR_image_base 1+#define EGL_IMAGE_PRESERVED_KHR           0x30D2+#endif /* EGL_KHR_image_base */++#ifndef EGL_KHR_image_pixmap+#define EGL_KHR_image_pixmap 1+#endif /* EGL_KHR_image_pixmap */++#ifndef EGL_KHR_lock_surface+#define EGL_KHR_lock_surface 1+#define EGL_READ_SURFACE_BIT_KHR          0x0001+#define EGL_WRITE_SURFACE_BIT_KHR         0x0002+#define EGL_LOCK_SURFACE_BIT_KHR          0x0080+#define EGL_OPTIMAL_FORMAT_BIT_KHR        0x0100+#define EGL_MATCH_FORMAT_KHR              0x3043+#define EGL_FORMAT_RGB_565_EXACT_KHR      0x30C0+#define EGL_FORMAT_RGB_565_KHR            0x30C1+#define EGL_FORMAT_RGBA_8888_EXACT_KHR    0x30C2+#define EGL_FORMAT_RGBA_8888_KHR          0x30C3+#define EGL_MAP_PRESERVE_PIXELS_KHR       0x30C4+#define EGL_LOCK_USAGE_HINT_KHR           0x30C5+#define EGL_BITMAP_POINTER_KHR            0x30C6+#define EGL_BITMAP_PITCH_KHR              0x30C7+#define EGL_BITMAP_ORIGIN_KHR             0x30C8+#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR   0x30C9+#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA+#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR  0x30CB+#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC+#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD+#define EGL_LOWER_LEFT_KHR                0x30CE+#define EGL_UPPER_LEFT_KHR                0x30CF+typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);+EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface);+#endif+#endif /* EGL_KHR_lock_surface */++#ifndef EGL_KHR_lock_surface2+#define EGL_KHR_lock_surface2 1+#define EGL_BITMAP_PIXEL_SIZE_KHR         0x3110+#endif /* EGL_KHR_lock_surface2 */++#ifndef EGL_KHR_lock_surface3+#define EGL_KHR_lock_surface3 1+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value);+#endif+#endif /* EGL_KHR_lock_surface3 */++#ifndef EGL_KHR_reusable_sync+#define EGL_KHR_reusable_sync 1+typedef khronos_utime_nanoseconds_t EGLTimeKHR;+#ifdef KHRONOS_SUPPORT_INT64+#define EGL_SYNC_STATUS_KHR               0x30F1+#define EGL_SIGNALED_KHR                  0x30F2+#define EGL_UNSIGNALED_KHR                0x30F3+#define EGL_TIMEOUT_EXPIRED_KHR           0x30F5+#define EGL_CONDITION_SATISFIED_KHR       0x30F6+#define EGL_SYNC_TYPE_KHR                 0x30F7+#define EGL_SYNC_REUSABLE_KHR             0x30FA+#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR   0x0001+#define EGL_FOREVER_KHR                   0xFFFFFFFFFFFFFFFFull+#define EGL_NO_SYNC_KHR                   ((EGLSyncKHR)0)+typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);+typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync);+EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);+EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);+EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);+#endif+#endif /* KHRONOS_SUPPORT_INT64 */+#endif /* EGL_KHR_reusable_sync */++#ifndef EGL_KHR_stream+#define EGL_KHR_stream 1+typedef void *EGLStreamKHR;+typedef khronos_uint64_t EGLuint64KHR;+#ifdef KHRONOS_SUPPORT_INT64+#define EGL_NO_STREAM_KHR                 ((EGLStreamKHR)0)+#define EGL_CONSUMER_LATENCY_USEC_KHR     0x3210+#define EGL_PRODUCER_FRAME_KHR            0x3212+#define EGL_CONSUMER_FRAME_KHR            0x3213+#define EGL_STREAM_STATE_KHR              0x3214+#define EGL_STREAM_STATE_CREATED_KHR      0x3215+#define EGL_STREAM_STATE_CONNECTING_KHR   0x3216+#define EGL_STREAM_STATE_EMPTY_KHR        0x3217+#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218+#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219+#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A+#define EGL_BAD_STREAM_KHR                0x321B+#define EGL_BAD_STATE_KHR                 0x321C+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list);+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream);+EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);+#endif+#endif /* KHRONOS_SUPPORT_INT64 */+#endif /* EGL_KHR_stream */++#ifndef EGL_KHR_stream_consumer_gltexture+#define EGL_KHR_stream_consumer_gltexture 1+#ifdef EGL_KHR_stream+#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream);+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream);+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream);+#endif+#endif /* EGL_KHR_stream */+#endif /* EGL_KHR_stream_consumer_gltexture */++#ifndef EGL_KHR_stream_cross_process_fd+#define EGL_KHR_stream_cross_process_fd 1+typedef int EGLNativeFileDescriptorKHR;+#ifdef EGL_KHR_stream+#define EGL_NO_FILE_DESCRIPTOR_KHR        ((EGLNativeFileDescriptorKHR)(-1))+typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream);+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);+#endif+#endif /* EGL_KHR_stream */+#endif /* EGL_KHR_stream_cross_process_fd */++#ifndef EGL_KHR_stream_fifo+#define EGL_KHR_stream_fifo 1+#ifdef EGL_KHR_stream+#define EGL_STREAM_FIFO_LENGTH_KHR        0x31FC+#define EGL_STREAM_TIME_NOW_KHR           0x31FD+#define EGL_STREAM_TIME_CONSUMER_KHR      0x31FE+#define EGL_STREAM_TIME_PRODUCER_KHR      0x31FF+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);+#endif+#endif /* EGL_KHR_stream */+#endif /* EGL_KHR_stream_fifo */++#ifndef EGL_KHR_stream_producer_aldatalocator+#define EGL_KHR_stream_producer_aldatalocator 1+#ifdef EGL_KHR_stream+#endif /* EGL_KHR_stream */+#endif /* EGL_KHR_stream_producer_aldatalocator */++#ifndef EGL_KHR_stream_producer_eglsurface+#define EGL_KHR_stream_producer_eglsurface 1+#ifdef EGL_KHR_stream+#define EGL_STREAM_BIT_KHR                0x0800+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);+#endif+#endif /* EGL_KHR_stream */+#endif /* EGL_KHR_stream_producer_eglsurface */++#ifndef EGL_KHR_surfaceless_context+#define EGL_KHR_surfaceless_context 1+#endif /* EGL_KHR_surfaceless_context */++#ifndef EGL_KHR_vg_parent_image+#define EGL_KHR_vg_parent_image 1+#define EGL_VG_PARENT_IMAGE_KHR           0x30BA+#endif /* EGL_KHR_vg_parent_image */++#ifndef EGL_KHR_wait_sync+#define EGL_KHR_wait_sync 1+typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);+#endif+#endif /* EGL_KHR_wait_sync */++#ifndef EGL_ANDROID_blob_cache+#define EGL_ANDROID_blob_cache 1+typedef khronos_ssize_t EGLsizeiANDROID;+typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);+typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);+typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);+#endif+#endif /* EGL_ANDROID_blob_cache */++#ifndef EGL_ANDROID_framebuffer_target+#define EGL_ANDROID_framebuffer_target 1+#define EGL_FRAMEBUFFER_TARGET_ANDROID    0x3147+#endif /* EGL_ANDROID_framebuffer_target */++#ifndef EGL_ANDROID_image_native_buffer+#define EGL_ANDROID_image_native_buffer 1+#define EGL_NATIVE_BUFFER_ANDROID         0x3140+#endif /* EGL_ANDROID_image_native_buffer */++#ifndef EGL_ANDROID_native_fence_sync+#define EGL_ANDROID_native_fence_sync 1+#define EGL_SYNC_NATIVE_FENCE_ANDROID     0x3144+#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID  0x3145+#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146+#define EGL_NO_NATIVE_FENCE_FD_ANDROID    -1+typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync);+#endif+#endif /* EGL_ANDROID_native_fence_sync */++#ifndef EGL_ANDROID_recordable+#define EGL_ANDROID_recordable 1+#define EGL_RECORDABLE_ANDROID            0x3142+#endif /* EGL_ANDROID_recordable */++#ifndef EGL_ANGLE_d3d_share_handle_client_buffer+#define EGL_ANGLE_d3d_share_handle_client_buffer 1+#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200+#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */++#ifndef EGL_ANGLE_query_surface_pointer+#define EGL_ANGLE_query_surface_pointer 1+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);+#endif+#endif /* EGL_ANGLE_query_surface_pointer */++#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle+#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1+#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */++#ifndef EGL_ARM_pixmap_multisample_discard+#define EGL_ARM_pixmap_multisample_discard 1+#define EGL_DISCARD_SAMPLES_ARM           0x3286+#endif /* EGL_ARM_pixmap_multisample_discard */++#ifndef EGL_EXT_buffer_age+#define EGL_EXT_buffer_age 1+#define EGL_BUFFER_AGE_EXT                0x313D+#endif /* EGL_EXT_buffer_age */++#ifndef EGL_EXT_client_extensions+#define EGL_EXT_client_extensions 1+#endif /* EGL_EXT_client_extensions */++#ifndef EGL_EXT_create_context_robustness+#define EGL_EXT_create_context_robustness 1+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138+#define EGL_NO_RESET_NOTIFICATION_EXT     0x31BE+#define EGL_LOSE_CONTEXT_ON_RESET_EXT     0x31BF+#endif /* EGL_EXT_create_context_robustness */++#ifndef EGL_EXT_image_dma_buf_import+#define EGL_EXT_image_dma_buf_import 1+#define EGL_LINUX_DMA_BUF_EXT             0x3270+#define EGL_LINUX_DRM_FOURCC_EXT          0x3271+#define EGL_DMA_BUF_PLANE0_FD_EXT         0x3272+#define EGL_DMA_BUF_PLANE0_OFFSET_EXT     0x3273+#define EGL_DMA_BUF_PLANE0_PITCH_EXT      0x3274+#define EGL_DMA_BUF_PLANE1_FD_EXT         0x3275+#define EGL_DMA_BUF_PLANE1_OFFSET_EXT     0x3276+#define EGL_DMA_BUF_PLANE1_PITCH_EXT      0x3277+#define EGL_DMA_BUF_PLANE2_FD_EXT         0x3278+#define EGL_DMA_BUF_PLANE2_OFFSET_EXT     0x3279+#define EGL_DMA_BUF_PLANE2_PITCH_EXT      0x327A+#define EGL_YUV_COLOR_SPACE_HINT_EXT      0x327B+#define EGL_SAMPLE_RANGE_HINT_EXT         0x327C+#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D+#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E+#define EGL_ITU_REC601_EXT                0x327F+#define EGL_ITU_REC709_EXT                0x3280+#define EGL_ITU_REC2020_EXT               0x3281+#define EGL_YUV_FULL_RANGE_EXT            0x3282+#define EGL_YUV_NARROW_RANGE_EXT          0x3283+#define EGL_YUV_CHROMA_SITING_0_EXT       0x3284+#define EGL_YUV_CHROMA_SITING_0_5_EXT     0x3285+#endif /* EGL_EXT_image_dma_buf_import */++#ifndef EGL_EXT_multiview_window+#define EGL_EXT_multiview_window 1+#define EGL_MULTIVIEW_VIEW_COUNT_EXT      0x3134+#endif /* EGL_EXT_multiview_window */++#ifndef EGL_EXT_platform_base+#define EGL_EXT_platform_base 1+typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list);+EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);+EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list);+#endif+#endif /* EGL_EXT_platform_base */++#ifndef EGL_EXT_platform_wayland+#define EGL_EXT_platform_wayland 1+#define EGL_PLATFORM_WAYLAND_EXT          0x31D8+#endif /* EGL_EXT_platform_wayland */++#ifndef EGL_EXT_platform_x11+#define EGL_EXT_platform_x11 1+#define EGL_PLATFORM_X11_EXT              0x31D5+#define EGL_PLATFORM_X11_SCREEN_EXT       0x31D6+#endif /* EGL_EXT_platform_x11 */++#ifndef EGL_EXT_protected_surface+#define EGL_EXT_protected_surface 1+#define EGL_PROTECTED_CONTENT_EXT         0x32C0+#endif /* EGL_EXT_protected_surface */++#ifndef EGL_EXT_swap_buffers_with_damage+#define EGL_EXT_swap_buffers_with_damage 1+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);+#endif+#endif /* EGL_EXT_swap_buffers_with_damage */++#ifndef EGL_HI_clientpixmap+#define EGL_HI_clientpixmap 1+struct EGLClientPixmapHI {+    void  *pData;+    EGLint iWidth;+    EGLint iHeight;+    EGLint iStride;+};+#define EGL_CLIENT_PIXMAP_POINTER_HI      0x8F74+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap);+#endif+#endif /* EGL_HI_clientpixmap */++#ifndef EGL_HI_colorformats+#define EGL_HI_colorformats 1+#define EGL_COLOR_FORMAT_HI               0x8F70+#define EGL_COLOR_RGB_HI                  0x8F71+#define EGL_COLOR_RGBA_HI                 0x8F72+#define EGL_COLOR_ARGB_HI                 0x8F73+#endif /* EGL_HI_colorformats */++#ifndef EGL_IMG_context_priority+#define EGL_IMG_context_priority 1+#define EGL_CONTEXT_PRIORITY_LEVEL_IMG    0x3100+#define EGL_CONTEXT_PRIORITY_HIGH_IMG     0x3101+#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG   0x3102+#define EGL_CONTEXT_PRIORITY_LOW_IMG      0x3103+#endif /* EGL_IMG_context_priority */++#ifndef EGL_MESA_drm_image+#define EGL_MESA_drm_image 1+#define EGL_DRM_BUFFER_FORMAT_MESA        0x31D0+#define EGL_DRM_BUFFER_USE_MESA           0x31D1+#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2+#define EGL_DRM_BUFFER_MESA               0x31D3+#define EGL_DRM_BUFFER_STRIDE_MESA        0x31D4+#define EGL_DRM_BUFFER_USE_SCANOUT_MESA   0x00000001+#define EGL_DRM_BUFFER_USE_SHARE_MESA     0x00000002+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);+EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);+#endif+#endif /* EGL_MESA_drm_image */++#ifndef EGL_MESA_platform_gbm+#define EGL_MESA_platform_gbm 1+#define EGL_PLATFORM_GBM_MESA             0x31D7+#endif /* EGL_MESA_platform_gbm */++#ifndef EGL_NV_3dvision_surface+#define EGL_NV_3dvision_surface 1+#define EGL_AUTO_STEREO_NV                0x3136+#endif /* EGL_NV_3dvision_surface */++#ifndef EGL_NV_coverage_sample+#define EGL_NV_coverage_sample 1+#define EGL_COVERAGE_BUFFERS_NV           0x30E0+#define EGL_COVERAGE_SAMPLES_NV           0x30E1+#endif /* EGL_NV_coverage_sample */++#ifndef EGL_NV_coverage_sample_resolve+#define EGL_NV_coverage_sample_resolve 1+#define EGL_COVERAGE_SAMPLE_RESOLVE_NV    0x3131+#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132+#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133+#endif /* EGL_NV_coverage_sample_resolve */++#ifndef EGL_NV_depth_nonlinear+#define EGL_NV_depth_nonlinear 1+#define EGL_DEPTH_ENCODING_NV             0x30E2+#define EGL_DEPTH_ENCODING_NONE_NV        0+#define EGL_DEPTH_ENCODING_NONLINEAR_NV   0x30E3+#endif /* EGL_NV_depth_nonlinear */++#ifndef EGL_NV_native_query+#define EGL_NV_native_query 1+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id);+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window);+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap);+#endif+#endif /* EGL_NV_native_query */++#ifndef EGL_NV_post_convert_rounding+#define EGL_NV_post_convert_rounding 1+#endif /* EGL_NV_post_convert_rounding */++#ifndef EGL_NV_post_sub_buffer+#define EGL_NV_post_sub_buffer 1+#define EGL_POST_SUB_BUFFER_SUPPORTED_NV  0x30BE+typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);+#endif+#endif /* EGL_NV_post_sub_buffer */++#ifndef EGL_NV_stream_sync+#define EGL_NV_stream_sync 1+#define EGL_SYNC_NEW_FRAME_NV             0x321F+typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list);+#endif+#endif /* EGL_NV_stream_sync */++#ifndef EGL_NV_sync+#define EGL_NV_sync 1+typedef void *EGLSyncNV;+typedef khronos_utime_nanoseconds_t EGLTimeNV;+#ifdef KHRONOS_SUPPORT_INT64+#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6+#define EGL_SYNC_STATUS_NV                0x30E7+#define EGL_SIGNALED_NV                   0x30E8+#define EGL_UNSIGNALED_NV                 0x30E9+#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV    0x0001+#define EGL_FOREVER_NV                    0xFFFFFFFFFFFFFFFFull+#define EGL_ALREADY_SIGNALED_NV           0x30EA+#define EGL_TIMEOUT_EXPIRED_NV            0x30EB+#define EGL_CONDITION_SATISFIED_NV        0x30EC+#define EGL_SYNC_TYPE_NV                  0x30ED+#define EGL_SYNC_CONDITION_NV             0x30EE+#define EGL_SYNC_FENCE_NV                 0x30EF+#define EGL_NO_SYNC_NV                    ((EGLSyncNV)0)+typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);+typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);+typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync);+EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync);+EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);+EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);+EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);+#endif+#endif /* KHRONOS_SUPPORT_INT64 */+#endif /* EGL_NV_sync */++#ifndef EGL_NV_system_time+#define EGL_NV_system_time 1+typedef khronos_utime_nanoseconds_t EGLuint64NV;+#ifdef KHRONOS_SUPPORT_INT64+typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);+typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);+#ifdef EGL_EGLEXT_PROTOTYPES+EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void);+EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void);+#endif+#endif /* KHRONOS_SUPPORT_INT64 */+#endif /* EGL_NV_system_time */++#ifdef __cplusplus+}+#endif++#endif
+ include/EGL/eglplatform.h view
@@ -0,0 +1,125 @@+#ifndef __eglplatform_h_+#define __eglplatform_h_++/*+** Copyright (c) 2007-2013 The Khronos Group Inc.+**+** Permission is hereby granted, free of charge, to any person obtaining a+** copy of this software and/or associated documentation files (the+** "Materials"), to deal in the Materials without restriction, including+** without limitation the rights to use, copy, modify, merge, publish,+** distribute, sublicense, and/or sell copies of the Materials, and to+** permit persons to whom the Materials are furnished to do so, subject to+** the following conditions:+**+** The above copyright notice and this permission notice shall be included+** in all copies or substantial portions of the Materials.+**+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.+*/++/* Platform-specific types and definitions for egl.h+ * $Revision: 23432 $ on $Date: 2013-10-09 00:57:24 -0700 (Wed, 09 Oct 2013) $+ *+ * Adopters may modify khrplatform.h and this file to suit their platform.+ * You are encouraged to submit all modifications to the Khronos group so that+ * they can be included in future versions of this file.  Please submit changes+ * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)+ * by filing a bug against product "EGL" component "Registry".+ */++#include <KHR/khrplatform.h>++/* Macros used in EGL function prototype declarations.+ *+ * EGL functions should be prototyped as:+ *+ * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);+ * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);+ *+ * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h+ */++#ifndef EGLAPI+#define EGLAPI KHRONOS_APICALL+#endif++#ifndef EGLAPIENTRY+#define EGLAPIENTRY  KHRONOS_APIENTRY+#endif+#define EGLAPIENTRYP EGLAPIENTRY*++/* The types NativeDisplayType, NativeWindowType, and NativePixmapType+ * are aliases of window-system-dependent types, such as X Display * or+ * Windows Device Context. They must be defined in platform-specific+ * code below. The EGL-prefixed versions of Native*Type are the same+ * types, renamed in EGL 1.3 so all types in the API start with "EGL".+ *+ * Khronos STRONGLY RECOMMENDS that you use the default definitions+ * provided below, since these changes affect both binary and source+ * portability of applications using EGL running on different EGL+ * implementations.+ */++#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */+#ifndef WIN32_LEAN_AND_MEAN+#define WIN32_LEAN_AND_MEAN 1+#endif+#include <windows.h>++typedef HDC     EGLNativeDisplayType;+typedef HBITMAP EGLNativePixmapType;+typedef HWND    EGLNativeWindowType;++#elif defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */++typedef int   EGLNativeDisplayType;+typedef void *EGLNativeWindowType;+typedef void *EGLNativePixmapType;++#elif defined(__ANDROID__) || defined(ANDROID)++#include <android/native_window.h>++struct egl_native_pixmap_t;++typedef struct ANativeWindow*           EGLNativeWindowType;+typedef struct egl_native_pixmap_t*     EGLNativePixmapType;+typedef void*                           EGLNativeDisplayType;++#elif defined(__unix__)++/* X11 (tentative)  */+#include <X11/Xlib.h>+#include <X11/Xutil.h>++typedef Display *EGLNativeDisplayType;+typedef Pixmap   EGLNativePixmapType;+typedef Window   EGLNativeWindowType;++#else+#error "Platform not recognized"+#endif++/* EGL 1.2 types, renamed for consistency in EGL 1.3 */+typedef EGLNativeDisplayType NativeDisplayType;+typedef EGLNativePixmapType  NativePixmapType;+typedef EGLNativeWindowType  NativeWindowType;+++/* Define EGLint. This must be a signed integral type large enough to contain+ * all legal attribute names and values passed into and out of EGL, whether+ * their type is boolean, bitmask, enumerant (symbolic constant), integer,+ * handle, or other.  While in general a 32-bit integer will suffice, if+ * handles are 64 bit types, then EGLint should be defined as a signed 64-bit+ * integer type.+ */+typedef khronos_int32_t EGLint;++#endif /* __eglplatform_h */
+ include/KHR/khrplatform.h view
@@ -0,0 +1,282 @@+#ifndef __khrplatform_h_+#define __khrplatform_h_++/*+** Copyright (c) 2008-2009 The Khronos Group Inc.+**+** Permission is hereby granted, free of charge, to any person obtaining a+** copy of this software and/or associated documentation files (the+** "Materials"), to deal in the Materials without restriction, including+** without limitation the rights to use, copy, modify, merge, publish,+** distribute, sublicense, and/or sell copies of the Materials, and to+** permit persons to whom the Materials are furnished to do so, subject to+** the following conditions:+**+** The above copyright notice and this permission notice shall be included+** in all copies or substantial portions of the Materials.+**+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.+*/++/* Khronos platform-specific types and definitions.+ *+ * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $+ *+ * Adopters may modify this file to suit their platform. Adopters are+ * encouraged to submit platform specific modifications to the Khronos+ * group so that they can be included in future versions of this file.+ * Please submit changes by sending them to the public Khronos Bugzilla+ * (http://khronos.org/bugzilla) by filing a bug against product+ * "Khronos (general)" component "Registry".+ *+ * A predefined template which fills in some of the bug fields can be+ * reached using http://tinyurl.com/khrplatform-h-bugreport, but you+ * must create a Bugzilla login first.+ *+ *+ * See the Implementer's Guidelines for information about where this file+ * should be located on your system and for more details of its use:+ *    http://www.khronos.org/registry/implementers_guide.pdf+ *+ * This file should be included as+ *        #include <KHR/khrplatform.h>+ * by Khronos client API header files that use its types and defines.+ *+ * The types in khrplatform.h should only be used to define API-specific types.+ *+ * Types defined in khrplatform.h:+ *    khronos_int8_t              signed   8  bit+ *    khronos_uint8_t             unsigned 8  bit+ *    khronos_int16_t             signed   16 bit+ *    khronos_uint16_t            unsigned 16 bit+ *    khronos_int32_t             signed   32 bit+ *    khronos_uint32_t            unsigned 32 bit+ *    khronos_int64_t             signed   64 bit+ *    khronos_uint64_t            unsigned 64 bit+ *    khronos_intptr_t            signed   same number of bits as a pointer+ *    khronos_uintptr_t           unsigned same number of bits as a pointer+ *    khronos_ssize_t             signed   size+ *    khronos_usize_t             unsigned size+ *    khronos_float_t             signed   32 bit floating point+ *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds+ *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in+ *                                         nanoseconds+ *    khronos_stime_nanoseconds_t signed time interval in nanoseconds+ *    khronos_boolean_enum_t      enumerated boolean type. This should+ *      only be used as a base type when a client API's boolean type is+ *      an enum. Client APIs which use an integer or other type for+ *      booleans cannot use this as the base type for their boolean.+ *+ * Tokens defined in khrplatform.h:+ *+ *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.+ *+ *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.+ *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.+ *+ * Calling convention macros defined in this file:+ *    KHRONOS_APICALL+ *    KHRONOS_APIENTRY+ *    KHRONOS_APIATTRIBUTES+ *+ * These may be used in function prototypes as:+ *+ *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(+ *                                  int arg1,+ *                                  int arg2) KHRONOS_APIATTRIBUTES;+ */++/*-------------------------------------------------------------------------+ * Definition of KHRONOS_APICALL+ *-------------------------------------------------------------------------+ * This precedes the return type of the function in the function prototype.+ */+#if defined(_WIN32) && !defined(__SCITECH_SNAP__)+#   define KHRONOS_APICALL __declspec(dllimport)+#elif defined (__SYMBIAN32__)+#   define KHRONOS_APICALL IMPORT_C+#else+#   define KHRONOS_APICALL+#endif++/*-------------------------------------------------------------------------+ * Definition of KHRONOS_APIENTRY+ *-------------------------------------------------------------------------+ * This follows the return type of the function  and precedes the function+ * name in the function prototype.+ */+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)+    /* Win32 but not WinCE */+#   define KHRONOS_APIENTRY __stdcall+#else+#   define KHRONOS_APIENTRY+#endif++/*-------------------------------------------------------------------------+ * Definition of KHRONOS_APIATTRIBUTES+ *-------------------------------------------------------------------------+ * This follows the closing parenthesis of the function prototype arguments.+ */+#if defined (__ARMCC_2__)+#define KHRONOS_APIATTRIBUTES __softfp+#else+#define KHRONOS_APIATTRIBUTES+#endif++/*-------------------------------------------------------------------------+ * basic type definitions+ *-----------------------------------------------------------------------*/+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)+++/*+ * Using <stdint.h>+ */+#include <stdint.h>+typedef int32_t                 khronos_int32_t;+typedef uint32_t                khronos_uint32_t;+typedef int64_t                 khronos_int64_t;+typedef uint64_t                khronos_uint64_t;+#define KHRONOS_SUPPORT_INT64   1+#define KHRONOS_SUPPORT_FLOAT   1++#elif defined(__VMS ) || defined(__sgi)++/*+ * Using <inttypes.h>+ */+#include <inttypes.h>+typedef int32_t                 khronos_int32_t;+typedef uint32_t                khronos_uint32_t;+typedef int64_t                 khronos_int64_t;+typedef uint64_t                khronos_uint64_t;+#define KHRONOS_SUPPORT_INT64   1+#define KHRONOS_SUPPORT_FLOAT   1++#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)++/*+ * Win32+ */+typedef __int32                 khronos_int32_t;+typedef unsigned __int32        khronos_uint32_t;+typedef __int64                 khronos_int64_t;+typedef unsigned __int64        khronos_uint64_t;+#define KHRONOS_SUPPORT_INT64   1+#define KHRONOS_SUPPORT_FLOAT   1++#elif defined(__sun__) || defined(__digital__)++/*+ * Sun or Digital+ */+typedef int                     khronos_int32_t;+typedef unsigned int            khronos_uint32_t;+#if defined(__arch64__) || defined(_LP64)+typedef long int                khronos_int64_t;+typedef unsigned long int       khronos_uint64_t;+#else+typedef long long int           khronos_int64_t;+typedef unsigned long long int  khronos_uint64_t;+#endif /* __arch64__ */+#define KHRONOS_SUPPORT_INT64   1+#define KHRONOS_SUPPORT_FLOAT   1++#elif 0++/*+ * Hypothetical platform with no float or int64 support+ */+typedef int                     khronos_int32_t;+typedef unsigned int            khronos_uint32_t;+#define KHRONOS_SUPPORT_INT64   0+#define KHRONOS_SUPPORT_FLOAT   0++#else++/*+ * Generic fallback+ */+#include <stdint.h>+typedef int32_t                 khronos_int32_t;+typedef uint32_t                khronos_uint32_t;+typedef int64_t                 khronos_int64_t;+typedef uint64_t                khronos_uint64_t;+#define KHRONOS_SUPPORT_INT64   1+#define KHRONOS_SUPPORT_FLOAT   1++#endif+++/*+ * Types that are (so far) the same on all platforms+ */+typedef signed   char          khronos_int8_t;+typedef unsigned char          khronos_uint8_t;+typedef signed   short int     khronos_int16_t;+typedef unsigned short int     khronos_uint16_t;++/*+ * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears+ * to be the only LLP64 architecture in current use.+ */+#ifdef _WIN64+typedef signed   long long int khronos_intptr_t;+typedef unsigned long long int khronos_uintptr_t;+typedef signed   long long int khronos_ssize_t;+typedef unsigned long long int khronos_usize_t;+#else+typedef signed   long  int     khronos_intptr_t;+typedef unsigned long  int     khronos_uintptr_t;+typedef signed   long  int     khronos_ssize_t;+typedef unsigned long  int     khronos_usize_t;+#endif++#if KHRONOS_SUPPORT_FLOAT+/*+ * Float type+ */+typedef          float         khronos_float_t;+#endif++#if KHRONOS_SUPPORT_INT64+/* Time types+ *+ * These types can be used to represent a time interval in nanoseconds or+ * an absolute Unadjusted System Time.  Unadjusted System Time is the number+ * of nanoseconds since some arbitrary system event (e.g. since the last+ * time the system booted).  The Unadjusted System Time is an unsigned+ * 64 bit value that wraps back to 0 every 584 years.  Time intervals+ * may be either signed or unsigned.+ */+typedef khronos_uint64_t       khronos_utime_nanoseconds_t;+typedef khronos_int64_t        khronos_stime_nanoseconds_t;+#endif++/*+ * Dummy value used to pad enum types to 32 bits.+ */+#ifndef KHRONOS_MAX_ENUM+#define KHRONOS_MAX_ENUM 0x7FFFFFFF+#endif++/*+ * Enumerated boolean type+ *+ * Values other than zero should be considered to be true.  Therefore+ * comparisons should not be made against KHRONOS_TRUE.+ */+typedef enum {+    KHRONOS_FALSE = 0,+    KHRONOS_TRUE  = 1,+    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM+} khronos_boolean_enum_t;++#endif /* __khrplatform_h_ */
+ opengles.cabal view
@@ -0,0 +1,61 @@+name:                opengles+version:             0.4.0+synopsis:            OpenGL ES 2.0 and 3.0 with EGL 1.4+description:         A simplified OpenGL ES core wrapper library.+                     The mission statement of this library is three F: Fun, Fast, yet Flexible.+                     Please check out simple texture rendering example in just 100 lines.+                     This library is intended use on mobile, however,+                     also works in OpenGL 4.1/4.3+ environment on desktop.+license:             LGPL-3+license-file:        LICENSE+author:              capsjac@gmail.com+maintainer:          capsjac@gmail.com+-- copyright:           +category:            Graphics+build-type:          Simple+extra-source-files:+  include/EGL/egl.h+  include/EGL/eglext.h+  include/EGL/eglplatform.h+  include/KHR/khrplatform.h+stability: experimental+cabal-version:       >= 1.18++source-repository head+  type:              git+  location:          https://github.com/capsjac/opengles++library+  default-language: Haskell2010++  exposed-modules:+    Graphics.EGL,+    Graphics.OpenGLES,+    Graphics.OpenGLES.Base,+    Graphics.OpenGLES.Buffer,+    Graphics.OpenGLES.Core,+    Graphics.OpenGLES.Env,+    Graphics.OpenGLES.Internal,+    Graphics.OpenGLES.State,+    Graphics.OpenGLES.Texture,+    Graphics.OpenGLES.Types,+    Graphics.TextureContainer.KTX,+    Graphics.TextureContainer.PKM+  +  other-extensions: ForeignFunctionInterface+  extra-libraries: EGL, GLESv2+  build-depends:+    base >= 4.6 && < 5,+    bytestring >= 0.10 && < 1,+    ghc-prim,+    array >= 0.5 && < 0.6,+    future-resource >= 0.3,+    linear-vect >= 0.1,+    packer >= 0.1 && < 0.2+  +  include-dirs: include+  +  if os(ios)+    frameworks: QuartzCore, OpenGLES+  ghc-options: -Wall -fexcess-precision  -funbox-strict-fields+