summaryrefslogtreecommitdiff
path: root/src/LambdaCube/GL/Type.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-04-30 12:00:46 -0400
committerJoe Crayne <joe@jerkface.net>2019-05-06 19:44:07 -0400
commitfcf51c414e06ff24e7f2ec350ef0cef20b6238d2 (patch)
tree2a22c83cd3bd333667a729b66e13488816c93acd /src/LambdaCube/GL/Type.hs
parent154b25e0ad8a8ecedb02876215d29c12e87e6c93 (diff)
TextureCube support.
Diffstat (limited to 'src/LambdaCube/GL/Type.hs')
-rw-r--r--src/LambdaCube/GL/Type.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/LambdaCube/GL/Type.hs b/src/LambdaCube/GL/Type.hs
index 97b8e25..ce3a365 100644
--- a/src/LambdaCube/GL/Type.hs
+++ b/src/LambdaCube/GL/Type.hs
@@ -1,6 +1,8 @@
1{-# LANGUAGE ExistentialQuantification, FlexibleInstances, GeneralizedNewtypeDeriving, ScopedTypeVariables #-} 1{-# LANGUAGE ExistentialQuantification, FlexibleInstances, GeneralizedNewtypeDeriving, ScopedTypeVariables #-}
2{-# LANGUAGE FlexibleContexts #-}
2module LambdaCube.GL.Type where 3module LambdaCube.GL.Type where
3 4
5import Data.Coerce
4import Data.IORef 6import Data.IORef
5import Data.Int 7import Data.Int
6import Data.IntMap.Strict (IntMap) 8import Data.IntMap.Strict (IntMap)
@@ -70,10 +72,13 @@ data ArrayDesc
70 - per object features: enable/disable visibility, set render ordering 72 - per object features: enable/disable visibility, set render ordering
71-} 73-}
72data GLUniform = forall c. Typeable c => GLTypedUniform (TypeTag c) (IORef (GLUniformValue c)) 74data GLUniform = forall c. Typeable c => GLTypedUniform (TypeTag c) (IORef (GLUniformValue c))
73 | GLUniform !InputType !(IORef TextureData) 75 | forall t. IsGLObject t => GLUniform (IORef t)
74 76
75data GLUniformValue c = forall a. GLData a c => GLUniformValue a 77data GLUniformValue c = forall a. GLData a c => GLUniformValue a
76 78
79class (Coercible t Word32, Typeable t) => IsGLObject t where
80 objectType :: p t -> InputType
81
77instance Show GLUniform where 82instance Show GLUniform where
78 showsPrec d (GLTypedUniform t _) = paren '(' 83 showsPrec d (GLTypedUniform t _) = paren '('
79 . mappend "GLUniform " 84 . mappend "GLUniform "
@@ -81,7 +86,7 @@ instance Show GLUniform where
81 . paren ')' 86 . paren ')'
82 where paren | d<=10 = (:) 87 where paren | d<=10 = (:)
83 | otherwise = \_ -> id 88 | otherwise = \_ -> id
84 showsPrec d (GLUniform t _) = paren '(' . mappend "GLUniform " . showsPrec (d+10) t . paren ')' 89 showsPrec d (GLUniform r) = paren '(' . mappend "GLUniform " . showsPrec (d+10) (objectType r) . paren ')'
85 where paren | d<=10 = (:) 90 where paren | d<=10 = (:)
86 | otherwise = \_ -> id 91 | otherwise = \_ -> id
87 92
@@ -396,11 +401,12 @@ data IndexStream b
396 , indexLength :: Int 401 , indexLength :: Int
397 } 402 }
398 403
399newtype TextureData 404newtype TextureData = Texture2DName GLuint
400 = TextureData 405instance IsGLObject TextureData where objectType _ = FTexture2D
401 { textureObject :: GLuint 406
402 } 407newtype TextureCubeData = TextureCubeName GLuint
403 deriving Storable 408instance IsGLObject TextureCubeData where objectType _ = FTextureCube
409
404 410
405data Primitive 411data Primitive
406 = TriangleStrip 412 = TriangleStrip