diff options
author | Joe Crayne <joe@jerkface.net> | 2019-04-30 12:00:46 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-05-06 19:44:07 -0400 |
commit | fcf51c414e06ff24e7f2ec350ef0cef20b6238d2 (patch) | |
tree | 2a22c83cd3bd333667a729b66e13488816c93acd /src/LambdaCube/GL/Type.hs | |
parent | 154b25e0ad8a8ecedb02876215d29c12e87e6c93 (diff) |
TextureCube support.
Diffstat (limited to 'src/LambdaCube/GL/Type.hs')
-rw-r--r-- | src/LambdaCube/GL/Type.hs | 20 |
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 #-} | ||
2 | module LambdaCube.GL.Type where | 3 | module LambdaCube.GL.Type where |
3 | 4 | ||
5 | import Data.Coerce | ||
4 | import Data.IORef | 6 | import Data.IORef |
5 | import Data.Int | 7 | import Data.Int |
6 | import Data.IntMap.Strict (IntMap) | 8 | import 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 | -} |
72 | data GLUniform = forall c. Typeable c => GLTypedUniform (TypeTag c) (IORef (GLUniformValue c)) | 74 | data 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 | ||
75 | data GLUniformValue c = forall a. GLData a c => GLUniformValue a | 77 | data GLUniformValue c = forall a. GLData a c => GLUniformValue a |
76 | 78 | ||
79 | class (Coercible t Word32, Typeable t) => IsGLObject t where | ||
80 | objectType :: p t -> InputType | ||
81 | |||
77 | instance Show GLUniform where | 82 | instance 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 | ||
399 | newtype TextureData | 404 | newtype TextureData = Texture2DName GLuint |
400 | = TextureData | 405 | instance IsGLObject TextureData where objectType _ = FTexture2D |
401 | { textureObject :: GLuint | 406 | |
402 | } | 407 | newtype TextureCubeData = TextureCubeName GLuint |
403 | deriving Storable | 408 | instance IsGLObject TextureCubeData where objectType _ = FTextureCube |
409 | |||
404 | 410 | ||
405 | data Primitive | 411 | data Primitive |
406 | = TriangleStrip | 412 | = TriangleStrip |