aboutsummaryrefslogtreecommitdiff
path: root/Graphics/Glyph/ExtendedGL.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Graphics/Glyph/ExtendedGL.hs')
-rw-r--r--Graphics/Glyph/ExtendedGL.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Graphics/Glyph/ExtendedGL.hs b/Graphics/Glyph/ExtendedGL.hs
index d42e973..7742ba8 100644
--- a/Graphics/Glyph/ExtendedGL.hs
+++ b/Graphics/Glyph/ExtendedGL.hs
@@ -4,6 +4,14 @@ import Graphics.Rendering.OpenGL
import Graphics.Rendering.OpenGL.Raw.Core31
import Graphics.Rendering.OpenGL.Raw.ARB
+import Foreign.Marshal.Alloc
+import Foreign.Ptr
+import Foreign.Storable
+import Foreign.C.Types
+
+import System.IO.Unsafe
+import Control.Monad
+
marshalPrimitiveMode :: PrimitiveMode -> GLenum
marshalPrimitiveMode x = case x of
Points -> 0x0
@@ -24,3 +32,25 @@ vertexAttributeDivisor :: AttribLocation -> SettableStateVar GLuint
vertexAttributeDivisor (AttribLocation loc) =
makeSettableStateVar $ \val ->
glVertexAttribDivisor loc val
+
+patchVertices :: (Integral a) => SettableStateVar a
+patchVertices =
+ makeSettableStateVar $ \val ->
+ glPatchParameteri gl_PATCH_VERTICES $ fromIntegral val
+
+maxPatchVertices :: IO CInt
+maxPatchVertices =
+ alloca $ \ptr -> do
+ glGetIntegerv gl_MAX_PATCH_VERTICES ptr
+ peek ptr
+
+getGLVersion :: IO String
+getGLVersion =
+ let lift2 (a,b) = do
+ x <- a ; y <- b ; return (x,y)
+ in
+ alloca $ \ptr1 -> alloca $ \ptr2 -> do
+ glGetIntegerv gl_MAJOR_VERSION ptr1
+ glGetIntegerv gl_MINOR_VERSION ptr2
+ (v1,v2) <- lift2 (peek ptr1, peek ptr2)
+ return ("OpenGL " ++ show v1 ++ "." ++ show v2)