Add picture shader container datatype
This commit is contained in:
+28
-18
@@ -153,20 +153,33 @@ renderShader shad dat = do
|
||||
eticks <- SDL.ticks
|
||||
return $ eticks - sticks
|
||||
|
||||
pokeBindFoldable
|
||||
:: Foldable f
|
||||
=> RenderData
|
||||
-> f Verx
|
||||
-> IO (PicShads Int)
|
||||
pokeBindFoldable pdata m = do
|
||||
let shads = _pictureShaders pdata
|
||||
counts = zeroCounts
|
||||
elist <- foldM (pokeVX' shads) counts m
|
||||
bindShader shads elist
|
||||
return elist
|
||||
|
||||
zeroCounts :: PicShads Int
|
||||
zeroCounts = PicShads 0 0 0 0 0 0
|
||||
|
||||
pokeBindFoldableLayer
|
||||
:: Foldable f
|
||||
=> RenderData
|
||||
-> f Verx
|
||||
-> IO (IM.IntMap [(VShader,Int)])
|
||||
-> IO (IM.IntMap (PicShads Int))
|
||||
pokeBindFoldableLayer pdata m = do
|
||||
let slist = (,) <$> [0..6] <*> _pictureShaders pdata
|
||||
slist' = IM.fromListWith (++) ((,) <$> [0..6] <*> map ((:[]) . (, 0)) (_pictureShaders pdata))
|
||||
let shads = _pictureShaders pdata
|
||||
slist' = (IM.fromList ((,) <$> [0..6] <*> [zeroCounts])) :: IM.IntMap (PicShads Int)
|
||||
|
||||
slist'' <- foldM (pokeVX shads) slist' m
|
||||
bindShaderLay shads slist''
|
||||
|
||||
-- is <- F.foldM (traverse pokeShaderLayer slist) m
|
||||
-- bindShaderLayer slist is
|
||||
slist'' <- foldM pokeVX slist' m
|
||||
bindShaderLay slist''
|
||||
--return $ IM.fromListWith (++) $ zipWith (\(i,fs) n -> (i,[(fs,n)])) slist is
|
||||
return slist''
|
||||
|
||||
renderFoldable
|
||||
@@ -177,22 +190,19 @@ renderFoldable
|
||||
renderFoldable pdata struct = do
|
||||
pokeStartTicks <- SDL.ticks
|
||||
|
||||
let slist = (,) <$> [0..6] <*> _pictureShaders pdata
|
||||
count <- pokeBindFoldable pdata struct
|
||||
let shads = _pictureShaders pdata
|
||||
|
||||
-- poke data, returns list buffer sizes for each shader
|
||||
is <- F.foldM (traverse pokeShaderLayer slist) struct
|
||||
|
||||
-- the idea of binding many buffers at once, rather than interweaving with draw
|
||||
-- calls, is to prevent opengl from waiting for a draw call to finish
|
||||
-- before it performs another state change
|
||||
bindShaderLayer slist is
|
||||
|
||||
zipWithM_ (uncurry drawShaderLay) slist is
|
||||
mapM_ (uncurry (drawShaderLay 0)) ((,) <$> shads <*> count)
|
||||
|
||||
pokeEndTicks <- SDL.ticks
|
||||
return $ pokeEndTicks - pokeStartTicks
|
||||
------------------------------end renderFoldable
|
||||
|
||||
renderLayer :: Int -> PicShads VShader -> IM.IntMap (PicShads Int) -> IO ()
|
||||
renderLayer i shads counts =
|
||||
mapM_ (uncurry $ drawShaderLay i) ((,) <$> shads <*> counts IM.! i)
|
||||
|
||||
pokeTwoOff
|
||||
:: Ptr Float
|
||||
-> Int
|
||||
|
||||
Reference in New Issue
Block a user