aboutsummaryrefslogtreecommitdiff
path: root/Graphics/Glyph/ExtendedGL.hs
diff options
context:
space:
mode:
authorJoshua Rahm <joshua.rahm@colorado.edu>2014-04-18 01:17:46 -0600
committerJoshua Rahm <joshua.rahm@colorado.edu>2014-04-18 01:17:46 -0600
commit915cda147b565880fecefe5f82ca242bad6114fc (patch)
treed6afedd6d33bdca1601faaaebd731b89aab75431 /Graphics/Glyph/ExtendedGL.hs
parent73daf65aaa31b5fb59f4a91d9185387f63c7b09f (diff)
downloadterralloc-915cda147b565880fecefe5f82ca242bad6114fc.tar.gz
terralloc-915cda147b565880fecefe5f82ca242bad6114fc.tar.bz2
terralloc-915cda147b565880fecefe5f82ca242bad6114fc.zip
starting tesselation shader
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)