summaryrefslogtreecommitdiff
path: root/src/LambdaCube/GL/Type.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LambdaCube/GL/Type.hs')
-rw-r--r--src/LambdaCube/GL/Type.hs50
1 files changed, 33 insertions, 17 deletions
diff --git a/src/LambdaCube/GL/Type.hs b/src/LambdaCube/GL/Type.hs
index 5a9117d..776a425 100644
--- a/src/LambdaCube/GL/Type.hs
+++ b/src/LambdaCube/GL/Type.hs
@@ -128,7 +128,7 @@ data GLTexture
128 = GLTexture 128 = GLTexture
129 { glTextureObject :: GLuint 129 { glTextureObject :: GLuint
130 , glTextureTarget :: GLenum 130 , glTextureTarget :: GLenum
131 } 131 } deriving Eq
132 132
133data InputConnection 133data InputConnection
134 = InputConnection 134 = InputConnection
@@ -159,34 +159,50 @@ data GLRenderer
159 , glVAO :: GLuint 159 , glVAO :: GLuint
160 , glTexUnitMapping :: Map String (IORef GLint) -- maps texture uniforms to texture units 160 , glTexUnitMapping :: Map String (IORef GLint) -- maps texture uniforms to texture units
161 , glStreams :: Vector GLStream 161 , glStreams :: Vector GLStream
162 , glDrawContextRef :: IORef GLDrawContext
163 , glForceSetup :: IORef Bool
164 , glVertexBufferRef :: IORef GLuint
165 , glIndexBufferRef :: IORef GLuint
162 } 166 }
163 167
164data GLSampler 168data GLSampler
165 = GLSampler 169 = GLSampler
166 { glSamplerObject :: GLuint 170 { glSamplerObject :: GLuint
167 } 171 } deriving Eq
168 172
169data GLRenderTarget 173data GLRenderTarget
170 = GLRenderTarget 174 = GLRenderTarget
171 { framebufferObject :: GLuint 175 { framebufferObject :: GLuint
172 , framebufferDrawbuffers :: Maybe [GLenum] 176 , framebufferDrawbuffers :: Maybe [GLenum]
173 } 177 } deriving Eq
178
179type GLTextureUnit = Int
180type GLUniformBinding = GLint
181
182data GLSamplerUniform
183 = GLSamplerUniform
184 { glUniformBinding :: GLUniformBinding
185 , glUniformBindingRef :: IORef GLUniformBinding
186 }
187
188instance Eq GLSamplerUniform where
189 a == b = glUniformBinding a == glUniformBinding b
190
191data GLDrawContext
192 = GLDrawContext
193 { glRasterContext :: RasterContext
194 , glAccumulationContext :: AccumulationContext
195 , glRenderTarget :: GLRenderTarget
196 , glProgram :: GLuint
197 , glTextureMapping :: [(GLTextureUnit,GLTexture)]
198 , glSamplerMapping :: [(GLTextureUnit,GLSampler)]
199 , glSamplerUniformMapping :: [(GLTextureUnit,GLSamplerUniform)]
200 }
174 201
175data GLCommand 202data GLCommand
176 = GLSetRasterContext !RasterContext 203 = GLRenderSlot GLDrawContext SlotName ProgramName
177 | GLSetAccumulationContext !AccumulationContext 204 | GLRenderStream GLDrawContext StreamName ProgramName
178 | GLSetRenderTarget !GLuint !(Maybe [GLenum]) 205 | GLClearRenderTarget GLRenderTarget [ClearImage]
179 | GLSetProgram !GLuint
180 | GLSetSamplerUniform !GLint !GLint (IORef GLint) -- sampler index, texture unit, IORef stores the actual texture unit mapping
181 | GLSetTexture !GLenum !GLuint !GLuint
182 | GLSetSampler !GLuint !GLuint
183 | GLRenderSlot !SlotName !ProgramName
184 | GLRenderStream !StreamName !ProgramName
185 | GLClearRenderTarget [ClearImage]
186 | GLGenerateMipMap !GLenum !GLenum
187 | GLSaveImage FrameBufferComponent ImageRef -- from framebuffer component to texture (image)
188 | GLLoadImage ImageRef FrameBufferComponent -- from texture (image) to framebuffer component
189 deriving Show
190 206
191instance Show (IORef GLint) where 207instance Show (IORef GLint) where
192 show _ = "(IORef GLint)" 208 show _ = "(IORef GLint)"