summaryrefslogtreecommitdiff
path: root/src/LambdaCube/GL/Backend.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LambdaCube/GL/Backend.hs')
-rw-r--r--src/LambdaCube/GL/Backend.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/LambdaCube/GL/Backend.hs b/src/LambdaCube/GL/Backend.hs
index 478dfd1..282c281 100644
--- a/src/LambdaCube/GL/Backend.hs
+++ b/src/LambdaCube/GL/Backend.hs
@@ -4,6 +4,7 @@ module LambdaCube.GL.Backend where
4import Control.Applicative 4import Control.Applicative
5import Control.Monad 5import Control.Monad
6import Control.Monad.State 6import Control.Monad.State
7import Data.Maybe
7import Data.Bits 8import Data.Bits
8import Data.IORef 9import Data.IORef
9import Data.IntMap (IntMap) 10import Data.IntMap (IntMap)
@@ -264,7 +265,7 @@ compileProgram p = do
264 , inputUniforms = Map.fromList inUniforms 265 , inputUniforms = Map.fromList inUniforms
265 , inputTextures = Map.fromList inTextures 266 , inputTextures = Map.fromList inTextures
266 , inputTextureUniforms = S.fromList $ texUnis 267 , inputTextureUniforms = S.fromList $ texUnis
267 , inputStreams = Map.fromList [(n,(idx, attrName)) | (n,idx) <- Map.toList $ attributes, let Just attrName = Map.lookup n lcStreamName] 268 , inputStreams = Map.fromList [(n,(idx, attrName)) | (n,idx) <- Map.toList $ attributes, let attrName = fromMaybe (error $ "missing attribute: " ++ n) $ Map.lookup n lcStreamName]
268 } 269 }
269 270
270compileRenderTarget :: Vector TextureDescriptor -> Vector GLTexture -> RenderTarget -> IO GLRenderTarget 271compileRenderTarget :: Vector TextureDescriptor -> Vector GLTexture -> RenderTarget -> IO GLRenderTarget
@@ -393,7 +394,7 @@ compileStreamData s = do
393 buffer <- compileBuffer arrays 394 buffer <- compileBuffer arrays
394 cmdRef <- newIORef [] 395 cmdRef <- newIORef []
395 let toStream (n,i) = (n,Stream 396 let toStream (n,i) = (n,Stream
396 { streamType = fromJust $ toStreamType =<< Map.lookup n (IR.streamType s) 397 { streamType = fromMaybe (error $ "missing attribute: " ++ n) $ toStreamType =<< Map.lookup n (IR.streamType s)
397 , streamBuffer = buffer 398 , streamBuffer = buffer
398 , streamArrIdx = i 399 , streamArrIdx = i
399 , streamStart = 0 400 , streamStart = 0
@@ -436,7 +437,7 @@ createStreamCommands texUnitMap topUnis attrs primitive prg = streamUniCmds ++ s
436 uniInputType (GLUniform ty _) = ty 437 uniInputType (GLUniform ty _) = ty
437 438
438 -- object attribute stream commands 439 -- object attribute stream commands
439 streamCmds = [attrCmd i s | (i,name) <- Map.elems attrMap, let Just s = Map.lookup name attrs] 440 streamCmds = [attrCmd i s | (i,name) <- Map.elems attrMap, let s = fromMaybe (error $ "missing attribute: " ++ name) $ Map.lookup name attrs]
440 where 441 where
441 attrMap = inputStreams prg 442 attrMap = inputStreams prg
442 attrCmd i s = case s of 443 attrCmd i s = case s of
@@ -603,7 +604,7 @@ setStorage' p@GLRenderer{..} input' = do
603 return (i,Nothing) 604 return (i,Nothing)
604 -- create input connection 605 -- create input connection
605 let sm = slotMap input 606 let sm = slotMap input
606 pToI = [i | n <- glSlotNames, let Just i = Map.lookup n sm] 607 pToI = [i | n <- glSlotNames, let i = fromMaybe (error $ "missing object array: " ++ n) $ Map.lookup n sm]
607 iToP = V.update (V.replicate (Map.size sm) Nothing) (V.imap (\i v -> (v, Just i)) pToI) 608 iToP = V.update (V.replicate (Map.size sm) Nothing) (V.imap (\i v -> (v, Just i)) pToI)
608 writeIORef glInput $ Just $ InputConnection idx input pToI iToP 609 writeIORef glInput $ Just $ InputConnection idx input pToI iToP
609 610