Continue tweaking rendering

This commit is contained in:
2021-07-28 12:25:52 +02:00
parent ae84f44824
commit 3b53570c21
5 changed files with 86 additions and 32 deletions
+15
View File
@@ -1,5 +1,6 @@
module Shader
( bindShaderLayer
, bindShaderLay
, bindShaderBuffers
, bindArrayBuffers
, drawShader
@@ -16,6 +17,7 @@ import Foreign
import Control.Monad
import Graphics.Rendering.OpenGL hiding (Point,translate,scale,imageHeight)
import Graphics.GL.Core43
import qualified Data.IntMap.Strict as IM
--import Text.RawString.QQ
--import Linear.Matrix
--import Linear.V4
@@ -42,6 +44,12 @@ bindArrayBuffersLayer numVs lay theVBO = do
where
stride = sum $ _vboAttribSizes theVBO
bindShaderLay :: IM.IntMap [(VShader,Int)] -> IO ()
bindShaderLay = mapM_ f . IM.toList
where
f (lay,ps) = mapM_ (g lay) ps
g l (fs,i) = bindArrayBuffersLayer i l $ _vaoVBO $ _vshaderVAO fs
bindShaderLayer :: [(Int,VShader)] -> [Int] -> IO ()
bindShaderLayer = zipWithM_ f
where
@@ -52,6 +60,13 @@ bindShaderBuffers = zipWithM_ f
where
f fs i = bindArrayBuffers i $ _vaoVBO $ _shaderVAO fs
drawShaderLays :: IM.IntMap [(VShader,Int)] -> IO ()
{-# INLINE drawShaderLays #-}
drawShaderLays = mapM_ f . IM.toList
where
f (lay,ps) = mapM_ (g lay) ps
g lay (shad,i) = drawShaderLay lay shad i
drawShaderLay :: Int -> VShader -> Int -> IO ()
{-# INLINE drawShaderLay #-}
drawShaderLay l fs i = do