Skip to content

Commit cf589db

Browse files
committed
Added extensionSupported. Bumped version to 2.13.1.0.
1 parent daf09ec commit cf589db

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

OpenGL.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: OpenGL
2-
version: 2.13.0.1
2+
version: 2.13.1.0
33
synopsis: A binding for the OpenGL graphics system
44
description:
55
A Haskell binding for the OpenGL graphics system (GL, version 4.5) and its

src/Graphics/Rendering/OpenGL/GL/QueryUtils/PName.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ data PName1I
570570
| GetDebugNextLoggedMessageLength -- ^ int
571571
| GetMaxDebugGroupStackDepth -- ^ int
572572
| GetMaxLabelLength -- ^ int
573+
-- Extensions
574+
| GetNumExtensions -- ^ uint
573575

574576
instance GetPName1I PName1I where
575577

@@ -848,6 +850,7 @@ instance GetPName PName1I where
848850
GetDebugNextLoggedMessageLength -> Just gl_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
849851
GetMaxDebugGroupStackDepth -> Just gl_MAX_DEBUG_GROUP_STACK_DEPTH
850852
GetMaxLabelLength -> Just gl_MAX_LABEL_LENGTH
853+
GetNumExtensions -> Just gl_NUM_EXTENSIONS
851854

852855
-- 0x8825 through 0x8834 are reserved for draw buffers
853856

src/Graphics/Rendering/OpenGL/GL/StringQueries.hs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
--------------------------------------------------------------------------------
1515

1616
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
1919
) where
2020

2121
import Data.Bits
@@ -39,6 +39,14 @@ glVersion = makeGettableStateVar (getString gl_VERSION)
3939
glExtensions :: GettableStateVar [String]
4040
glExtensions = 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+
4250
shadingLanguageVersion :: GettableStateVar String
4351
shadingLanguageVersion = makeGettableStateVar (getString gl_SHADING_LANGUAGE_VERSION)
4452

@@ -67,6 +75,9 @@ i2cps bitfield =
6775
getString :: GLenum -> IO String
6876
getString = 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

Comments
 (0)