Broken binding of central picture in one pass
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
module Shader.Poke
|
||||
( pokeArrayOff
|
||||
, pokeShader
|
||||
, pokeShaderLayer
|
||||
) where
|
||||
import Shader.Data
|
||||
import Shader.Parameters
|
||||
import Picture.Data
|
||||
|
||||
import Foreign
|
||||
@@ -17,6 +19,15 @@ pokeShader fs = F.FoldM (pokeVertices fls ptr stride) (return 0) return
|
||||
stride = sum $ _vboAttribSizes theVBO
|
||||
fls = _shaderPokeStrategy fs
|
||||
|
||||
pokeShaderLayer :: (Int,FullShader) -> F.FoldM IO (Int,RenderType) Int
|
||||
pokeShaderLayer (l,fs) = F.FoldM (pokeVerticesOff fls ptr stride l) (return 0) return
|
||||
where
|
||||
theVBO = _vaoVBO $ _shaderVAO fs
|
||||
ptr = _vboPointer theVBO
|
||||
stride = sum $ _vboAttribSizes theVBO
|
||||
fls = _shaderPokeStrategy fs
|
||||
|
||||
|
||||
pokeVertices
|
||||
:: (RenderType -> [[Float]])
|
||||
-> Ptr Float
|
||||
@@ -26,6 +37,24 @@ pokeVertices
|
||||
-> IO Int
|
||||
pokeVertices toFs ptr stride n rt = foldM (pokeVertex ptr stride) n (toFs rt)
|
||||
|
||||
pokeVerticesOff
|
||||
:: (RenderType -> [[Float]])
|
||||
-> Ptr Float
|
||||
-> Int -- ^ stride
|
||||
-> Int -- ^ offset
|
||||
-> Int -- ^ number of vertices already poked
|
||||
-> (Int,RenderType)
|
||||
-> IO Int
|
||||
pokeVerticesOff toFs ptr stride offset n (i,rt)
|
||||
| offset == i = foldM (pokeVertexOff ptr stride offset) n (toFs rt)
|
||||
| otherwise = return n
|
||||
|
||||
pokeVertexOff :: Ptr Float -> Int -> Int -> Int -> [Float] -> IO Int
|
||||
pokeVertexOff ptr stride offset n fs = do
|
||||
pokeArrayOff ptr (stride * (n + offset * numSubElements)) fs
|
||||
return $ n + 1
|
||||
|
||||
|
||||
pokeVertex :: Ptr Float -> Int -> Int -> [Float] -> IO Int
|
||||
pokeVertex ptr stride n fs = do
|
||||
pokeArrayOff ptr (stride * n) fs
|
||||
|
||||
Reference in New Issue
Block a user