23 lines
542 B
Haskell
23 lines
542 B
Haskell
module GLHelp where
|
|
|
|
import Foreign.Marshal
|
|
import Foreign.Ptr
|
|
import Foreign.Storable
|
|
import Graphics.GL.Core45
|
|
|
|
mglCreate :: (GLsizei -> Ptr GLuint -> IO ()) -> IO GLuint
|
|
mglCreate f = do
|
|
alloca $ \nameptr -> do
|
|
f 1 nameptr
|
|
peek nameptr
|
|
|
|
mglDelete :: (GLsizei -> Ptr GLuint -> IO ()) -> GLuint -> IO ()
|
|
mglDelete f i = with i $ \ptr -> f 1 ptr
|
|
|
|
checkGLError :: String -> IO ()
|
|
checkGLError s = do
|
|
err <- glGetError
|
|
case err of
|
|
0 -> return ()
|
|
i -> error $ "OpenGL error: " ++ show i ++ " - " ++ s
|