blob: 7742ba8fae82904d9a46606d334f7600dd4a4b7d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
module Graphics.Glyph.ExtendedGL where
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
Lines -> 0x1
LineLoop -> 0x2
LineStrip -> 0x3
Triangles -> 0x4
TriangleStrip -> 0x5
TriangleFan -> 0x6
Quads -> 0x7
QuadStrip -> 0x8
Polygon -> 0x9
drawArraysInstanced :: PrimitiveMode -> ArrayIndex -> NumArrayIndices -> GLsizei -> IO ()
drawArraysInstanced = glDrawArraysInstanced . marshalPrimitiveMode
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)
|