diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-03-15 14:26:41 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-03-15 14:26:41 +0100 |
commit | f2389270cf83d1e5fcd9c3f1c23e26d00fb51183 (patch) | |
tree | 79a299a39ab0e430d6f6ebc5e47a2f4c6d51dd66 /src/LambdaCube/GL/Backend.hs | |
parent | 6b23454dd1f1c2faf6cf1375350859755d077a13 (diff) |
add error messages
Diffstat (limited to 'src/LambdaCube/GL/Backend.hs')
-rw-r--r-- | src/LambdaCube/GL/Backend.hs | 9 |
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 | |||
4 | import Control.Applicative | 4 | import Control.Applicative |
5 | import Control.Monad | 5 | import Control.Monad |
6 | import Control.Monad.State | 6 | import Control.Monad.State |
7 | import Data.Maybe | ||
7 | import Data.Bits | 8 | import Data.Bits |
8 | import Data.IORef | 9 | import Data.IORef |
9 | import Data.IntMap (IntMap) | 10 | import 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 | ||
270 | compileRenderTarget :: Vector TextureDescriptor -> Vector GLTexture -> RenderTarget -> IO GLRenderTarget | 271 | compileRenderTarget :: 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 | ||