module Graphics.Rendering.OpenGL.GLU.Initialization (
gluVersion, gluExtensions
) where
import Foreign.Ptr ( Ptr, nullPtr, castPtr )
import Foreign.C.String ( peekCString )
import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLubyte )
import Graphics.Rendering.OpenGL.GL.StateVar (
GettableStateVar, makeGettableStateVar )
gluVersion :: GettableStateVar String
gluVersion = makeGettableStateVar (getString Version)
gluExtensions :: GettableStateVar [String]
gluExtensions = makeGettableStateVar (fmap words $ getString Extensions)
data StringName =
Version
| Extensions
deriving ( Eq, Ord, Show )
marshalStringName :: StringName -> GLenum
marshalStringName x = case x of
Version -> 0x189c0
Extensions -> 0x189c1
getString :: StringName -> IO String
getString n = do
ptr <- gluGetString (marshalStringName n)
if ptr == nullPtr
then return ""
else peekCString (castPtr ptr)
foreign import CALLCONV unsafe "gluGetString" gluGetString ::
GLenum -> IO (Ptr GLubyte)