14
14
--------------------------------------------------------------------------------
15
15
16
16
module 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
19
19
) where
20
20
21
21
import Data.Bits
@@ -39,6 +39,14 @@ glVersion = makeGettableStateVar (getString gl_VERSION)
39
39
glExtensions :: GettableStateVar [String ]
40
40
glExtensions = makeGettableStateVar (fmap words $ getString gl_EXTENSIONS)
41
41
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
+
42
50
shadingLanguageVersion :: GettableStateVar String
43
51
shadingLanguageVersion = makeGettableStateVar (getString gl_SHADING_LANGUAGE_VERSION)
44
52
@@ -67,6 +75,9 @@ i2cps bitfield =
67
75
getString :: GLenum -> IO String
68
76
getString = getStringWith . glGetString
69
77
78
+ getStringi :: GLenum -> GLuint -> IO String
79
+ getStringi n = getStringWith . glGetStringi n
80
+
70
81
--------------------------------------------------------------------------------
71
82
72
83
-- | A utility function to be used with e.g. 'glVersion' or
0 commit comments