1414--------------------------------------------------------------------------------
1515
1616module Graphics.Rendering.OpenGL.GL.StringQueries (
17- vendor , renderer , glVersion , glExtensions , shadingLanguageVersion ,
18- majorMinor , ContextProfile' (.. ), contextProfile
17+ vendor , renderer , glVersion , glExtensions , extensionSupported ,
18+ shadingLanguageVersion , majorMinor , ContextProfile' (.. ), contextProfile
1919) where
2020
2121import Data.Bits
@@ -39,6 +39,14 @@ glVersion = makeGettableStateVar (getString gl_VERSION)
3939glExtensions :: GettableStateVar [String ]
4040glExtensions = makeGettableStateVar (fmap words $ getString gl_EXTENSIONS)
4141
42+ extensionSupported :: String -> GettableStateVar Bool
43+ extensionSupported ext = makeGettableStateVar $ do
44+ n <- getInteger1 fromIntegral GetNumExtensions
45+ anyM $ map isExt [ 0 .. n - 1 ]
46+ where anyM = foldr orM (return False )
47+ x `orM` y = x >>= \ q -> if q then return True else y
48+ isExt = fmap (== ext) . getStringi gl_EXTENSIONS
49+
4250shadingLanguageVersion :: GettableStateVar String
4351shadingLanguageVersion = makeGettableStateVar (getString gl_SHADING_LANGUAGE_VERSION)
4452
@@ -67,6 +75,9 @@ i2cps bitfield =
6775getString :: GLenum -> IO String
6876getString = getStringWith . glGetString
6977
78+ getStringi :: GLenum -> GLuint -> IO String
79+ getStringi n = getStringWith . glGetStringi n
80+
7081--------------------------------------------------------------------------------
7182
7283-- | A utility function to be used with e.g. 'glVersion' or
0 commit comments