Commit before unifying vertex type

This commit is contained in:
jgk
2021-08-09 12:42:42 +02:00
parent ad4a70635b
commit 8cda9b4e1b
3 changed files with 28 additions and 172 deletions
+3 -23
View File
@@ -1,9 +1,7 @@
module Shader
( bindShaderLayer
, bindShaderLay
( bindShaderLay
, bindShaderBuffers
, bindShader
, bindArrayBuffers
, drawShader
, freeShaderPointers
, drawShaderLay
@@ -36,20 +34,8 @@ bindArrayBuffers numVs theVBO = do
(fromIntegral $ floatSize * numVs * sum (_vboAttribSizes theVBO))
(_vboPtr theVBO)
bindArrayBuffersLayer' :: Int -> Int -> VBO -> IO ()
bindArrayBuffersLayer' lay numVs theVBO = do
bindBuffer ArrayBuffer $= Just (_vbo theVBO)
bufferSubData
ArrayBuffer
WriteToBuffer
(fromIntegral $ floatSize * stride * numSubElements * lay)
(fromIntegral $ floatSize * numVs * stride)
(_vboPtr theVBO `plusPtr` (floatSize * stride * numSubElements * lay))
where
stride = sum $ _vboAttribSizes theVBO
bindArrayBuffersLayer :: Int -> Int -> VBO -> IO ()
bindArrayBuffersLayer numVs lay theVBO = do
bindArrayBuffersLayer lay numVs theVBO = do
bindBuffer ArrayBuffer $= Just (_vbo theVBO)
bufferSubData
ArrayBuffer
@@ -63,16 +49,10 @@ bindArrayBuffersLayer numVs lay theVBO = do
bindShaderLay :: PicShads VShader -> IM.IntMap (PicShads Int) -> IO ()
bindShaderLay shads = mapM_ (uncurry f) . IM.toList
where
f lay counts = sequence_ $ bindArrayBuffersLayer' lay <$> counts <*> (_vaoVBO . _vshaderVAO <$> shads)
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 = mapM_ (uncurry (flip bindArrayBuffers) . first (_vaoVBO . _vshaderVAO))
bindShaderLayer :: [(Int,VShader)] -> [Int] -> IO ()
bindShaderLayer = zipWithM_ f
where
f (l,fs) i = bindArrayBuffersLayer i l $ _vaoVBO $ _vshaderVAO fs
bindShaderBuffers :: [FullShader] -> [Int] -> IO ()
bindShaderBuffers = zipWithM_ f