Add more mutability

This commit is contained in:
2021-08-11 20:34:34 +02:00
parent b77683bafd
commit 0c4c83abb5
3 changed files with 34 additions and 15 deletions
+13 -3
View File
@@ -37,9 +37,8 @@ pokeVerxs
-> [Verx]
-> IO ()
pokeVerxs vbos count vxs = do
--count <- UMV.replicate 6 0
VS.mapM_ (pokeVerx vbos count) $ VS.fromList vxs
--vToPicShad count
s <- picShadToMV vbos
VS.mapM_ (pokeVerx' s count) $ VS.fromList vxs
vToPicShad :: UMV.MVector (PrimState IO) Int -> IO (PicShads Int)
{-# INLINE vToPicShad #-}
@@ -85,6 +84,17 @@ pokeVerx vbos offsets Verx{_vxPos=thePos,_vxCol=theCol,_vxExt=ext,_vxShadNum=the
where
sn = _unShadNum theShadNum
pokeVerx' :: MV.MVector (PrimState IO) VBO -> UMV.MVector (PrimState IO) Int -> Verx -> IO ()
pokeVerx' vbos offsets Verx{_vxPos=thePos,_vxCol=theCol,_vxExt=ext,_vxShadNum=theShadNum} = do
typeOff <- UMV.unsafeRead offsets sn
theShad <- MV.read vbos sn
let thePtr = plusPtr (_vboPtr theShad) (typeOff * pokeStride sn * floatSize)
poke34 thePtr thePos theCol
pokeArrayOff thePtr 7 ext
UMV.unsafeModify offsets (+1) sn
where
sn = _unShadNum theShadNum
poke34 :: Ptr Float -> Point3 -> Point4 -> IO ()
{-# INLINE poke34 #-}
poke34 ptr (V3 a b c) (V4 d e f g) = do