--------------------------------------------------------------------------------
-- |
-- Module      :  GLU_Init
-- Copyright   :  (c) Sven Panne 2003
-- License     :  BSD-style (see the file LICENSE in the toplevel directory)
-- 
-- Maintainer  :  sven_panne@yahoo.com
-- Stability   :  experimental
-- Portability :  portable
--
-- This module corresponds to chapter 2 (Initialization) of the GLU specs.
--
--------------------------------------------------------------------------------

module GLU_Init (
   getVersion, getExtensions
) where

import Control.Monad    ( liftM )
import Foreign.C.String ( CString, peekCString )
import GL_BasicTypes    ( GLenum )
import GL_Query         ( VersionInfo, parseVersionString, ExtensionsInfo(..) )
import GLU_EnumSpec     ( StringName(..), marshalStringName )

--------------------------------------------------------------------------------

getVersion :: IO VersionInfo
getVersion = liftM (parseVersionString "queryGLUVersion") (getString Version)

getExtensions :: IO ExtensionsInfo
getExtensions = liftM (ExtensionsInfo . words) (getString Extensions)

getString :: StringName -> IO String
getString n = gluGetString (marshalStringName n) >>= peekCString

foreign import CALLCONV unsafe "gluGetString" gluGetString ::
   GLenum -> IO CString
