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 -7
View File
@@ -5,6 +5,7 @@ module Shader
, drawShader
, freeShaderPointers
, drawShaderLay
, drawShaderLay'
, shadVBOptr
) where
--import Geometry.Data
@@ -57,13 +58,6 @@ bindShaderLay shads = mapM_ (uncurry f) . IM.toList
where
f lay counts = sequence_ $ bindArrayBuffersLayer lay <$> counts <*> (_vaoVBO . _vshaderVAO <$> shads)
--bindShader :: PicShads VShader -> PicShads Int -> IO ()
----bindShader shads counts = sequence_ $ bindArrayBuffers <$> counts <*> (_vaoVBO . _vshaderVAO <$> shads)
--bindShader shads count = do
-- s <- picShadToMV shads
-- c <- picShadToUMV count
-- bindShader' s c
bindShader :: MV.MVector (PrimState IO) VShader -> UMV.MVector (PrimState IO) Int -> IO ()
bindShader shads counts = MV.imapM_ f shads
where
@@ -86,6 +80,18 @@ drawShaderLay l fs i = do
_ -> return ()
glDrawArrays (marshalEPrimitiveMode $ _vshaderDrawPrimitive fs) (fromIntegral $ l*numSubElements) (fromIntegral i)
drawShaderLay' :: Int -> UMV.MVector (PrimState IO) Int -> Int -> VShader -> IO ()
{-# INLINE drawShaderLay' #-}
drawShaderLay' l countsVector index fs = do
i <- UMV.read countsVector index
currentProgram $= Just (_vshaderProgram fs)
bindVertexArrayObject $= Just (_vao $ _vshaderVAO fs)
case _vshaderTexture fs of
Just ShaderTexture{_textureObject = txo}
-> textureBinding Texture2D $= Just txo
_ -> return ()
glDrawArrays (marshalEPrimitiveMode $ _vshaderDrawPrimitive fs) (fromIntegral $ l*numSubElements) (fromIntegral i)
drawShader :: FullShader -> Int -> IO ()
{-# INLINE drawShader #-}
drawShader fs i = do