diff options
Diffstat (limited to 'Graphics/Glyph/ExtendedGL/Base.hs')
-rw-r--r-- | Graphics/Glyph/ExtendedGL/Base.hs | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/Graphics/Glyph/ExtendedGL/Base.hs b/Graphics/Glyph/ExtendedGL/Base.hs index 48f61a5..88566f4 100644 --- a/Graphics/Glyph/ExtendedGL/Base.hs +++ b/Graphics/Glyph/ExtendedGL/Base.hs @@ -5,8 +5,8 @@ module Graphics.Glyph.ExtendedGL.Base where import qualified Graphics.Rendering.OpenGL as GL -import Graphics.Rendering.OpenGL.Raw.Core31 -import Graphics.Rendering.OpenGL.Raw.ARB +import Graphics.GL.Core43 +import Graphics.GL.Compatibility30 import Foreign.Marshal.Alloc import Foreign.Ptr @@ -18,6 +18,7 @@ import Control.Monad import Data.StateVar import Unsafe.Coerce +import Data.Proxy data ExPrimitiveMode = Points | Triangles | Lines | Patches deriving (Show,Enum) @@ -40,8 +41,8 @@ class HasParamOfType b t a where class IsPrimitiveModeMarshallable a where marshalPrimitiveMode :: a -> GLuint -castPrimitive :: forall a b t. (IsWrappedPrimitive t a, IsWrappedPrimitive t b) => a -> b -castPrimitive x = wrap unw +castPrimitive :: forall a b t. (IsWrappedPrimitive t a, IsWrappedPrimitive t b) => Proxy t -> a -> b +castPrimitive _ x = wrap unw where unw :: t unw = unwrap x @@ -54,10 +55,10 @@ instance (IsWrappedPrimitive GLenum a) => IsGLEnumMarshallable a where instance IsPrimitiveModeMarshallable ExPrimitiveMode where marshalPrimitiveMode x = case x of - Points -> gl_POINTS - Triangles -> gl_TRIANGLES - Lines -> gl_LINES - Patches -> gl_PATCHES + Points -> GL_POINTS + Triangles -> GL_TRIANGLES + Lines -> GL_LINES + Patches -> GL_PATCHES instance IsPrimitiveModeMarshallable GL.PrimitiveMode where marshalPrimitiveMode x = case x of @@ -75,13 +76,6 @@ instance IsPrimitiveModeMarshallable GL.PrimitiveMode where instance IsPrimitiveModeMarshallable GLuint where marshalPrimitiveMode = id -drawArraysInstanced :: - (IsPrimitiveModeMarshallable a) => - a -> GL.ArrayIndex -> - GL.NumArrayIndices -> - GLsizei -> IO () -drawArraysInstanced = glDrawArraysInstanced . marshalPrimitiveMode - vertexAttributeDivisor :: GL.AttribLocation -> SettableStateVar GLuint vertexAttributeDivisor (GL.AttribLocation loc) = makeSettableStateVar $ \val -> @@ -92,15 +86,15 @@ vertexAttributeDivisor (GL.AttribLocation loc) = patchVertices :: (Integral a) => SettableStateVar a patchVertices = makeSettableStateVar $ \val -> - glPatchParameteri gl_PATCH_VERTICES $ fromIntegral val + glPatchParameteri GL_PATCH_VERTICES $ fromIntegral val {- Returns the maximum number of patches - for a tessilation shader -} maxPatchVertices :: IO CInt maxPatchVertices = alloca $ \ptr -> do - glGetIntegerv gl_MAX_PATCH_VERTICES ptr - peek ptr + glGetIntegerv GL_MAX_PATCH_VERTICES ptr + fromIntegral <$> peek ptr getGLVersion :: IO String getGLVersion = @@ -108,8 +102,8 @@ getGLVersion = x <- a ; y <- b ; return (x,y) in alloca $ \ptr1 -> alloca $ \ptr2 -> do - glGetIntegerv gl_MAJOR_VERSION ptr1 - glGetIntegerv gl_MINOR_VERSION ptr2 + glGetIntegerv GL_MAJOR_VERSION ptr1 + glGetIntegerv GL_MINOR_VERSION ptr2 (v1,v2) <- lift2 (peek ptr1, peek ptr2) return ("OpenGL " ++ show v1 ++ "." ++ show v2) |