diff options
author | Joshua Rahm <joshua.rahm@colorado.edu> | 2014-04-18 13:54:36 -0600 |
---|---|---|
committer | Joshua Rahm <joshua.rahm@colorado.edu> | 2014-04-18 13:54:36 -0600 |
commit | e1662612bec40fc131ecd306b66f6cb99f7f33e6 (patch) | |
tree | 746a288748690d4352d0ee45fe7a0fea4ab2b67e /Graphics/Glyph/ExtendedGL.hs | |
parent | e4754131548a55fea393d6fc9245b20fcd60c62c (diff) | |
download | terralloc-e1662612bec40fc131ecd306b66f6cb99f7f33e6.tar.gz terralloc-e1662612bec40fc131ecd306b66f6cb99f7f33e6.tar.bz2 terralloc-e1662612bec40fc131ecd306b66f6cb99f7f33e6.zip |
fixed reflection
Diffstat (limited to 'Graphics/Glyph/ExtendedGL.hs')
-rw-r--r-- | Graphics/Glyph/ExtendedGL.hs | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/Graphics/Glyph/ExtendedGL.hs b/Graphics/Glyph/ExtendedGL.hs index 7742ba8..86258e1 100644 --- a/Graphics/Glyph/ExtendedGL.hs +++ b/Graphics/Glyph/ExtendedGL.hs @@ -1,6 +1,7 @@ module Graphics.Glyph.ExtendedGL where -import Graphics.Rendering.OpenGL +import Graphics.Rendering.OpenGL hiding (Points,Lines,Triangles) +import qualified Graphics.Rendering.OpenGL as GL import Graphics.Rendering.OpenGL.Raw.Core31 import Graphics.Rendering.OpenGL.Raw.ARB @@ -12,20 +13,33 @@ 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 () +data ExPrimitiveMode = Points | Triangles | Lines | Patches deriving (Show,Enum) + +class IsPrimitiveModeMarshallable a where + marshalPrimitiveMode :: a -> GLuint + +instance IsPrimitiveModeMarshallable ExPrimitiveMode where + marshalPrimitiveMode x = case x of + Points -> gl_POINTS + Triangles -> gl_TRIANGLES + Lines -> gl_LINES + Patches -> gl_PATCHES + +instance IsPrimitiveModeMarshallable PrimitiveMode where + marshalPrimitiveMode x = case x of + GL.Points -> 0x0 + GL.Lines -> 0x1 + GL.LineLoop -> 0x2 + GL.LineStrip -> 0x3 + GL.Triangles -> 0x4 + GL.TriangleStrip -> 0x5 + GL.TriangleFan -> 0x6 + GL.Quads -> 0x7 + GL.QuadStrip -> 0x8 + GL.Polygon -> 0x9 + +drawArraysInstanced :: + (IsPrimitiveModeMarshallable a) => a -> ArrayIndex -> NumArrayIndices -> GLsizei -> IO () drawArraysInstanced = glDrawArraysInstanced . marshalPrimitiveMode vertexAttributeDivisor :: AttribLocation -> SettableStateVar GLuint |