module Graphics.Rendering.OpenGL.GL.Extensions (
FunPtr, unsafePerformIO,
Invoker, getProcAddress
) where
import Foreign.C.String ( CString, withCString )
import Foreign.Ptr ( FunPtr, nullFunPtr )
import System.IO.Unsafe ( unsafePerformIO )
#ifdef __HUGS__
#endif
type Invoker a = FunPtr a -> a
getProcAddress :: String -> String -> IO (FunPtr a)
getProcAddress ext call =
throwIfNull ("unknown OpenGL call " ++ call ++ ", check for " ++ ext) $
withCString call hs_OpenGL_getProcAddress
throwIfNull :: String -> IO (FunPtr a) -> IO (FunPtr a)
throwIfNull msg act = do
res <- act
if res == nullFunPtr
then ioError (userError msg)
else return res
foreign import ccall unsafe "hs_OpenGL_getProcAddress" hs_OpenGL_getProcAddress
:: CString -> IO (FunPtr a)