Commit before attempting to stream worldSPic more effectively
This commit is contained in:
+4
-2
@@ -10,9 +10,9 @@ import Graphics.Rendering.OpenGL hiding (Line,translate,scale,imageHeight,Polygo
|
||||
import Foreign hiding (rotate)
|
||||
import qualified Data.Vector.Unboxed.Mutable as UMV
|
||||
import qualified Data.Vector.Mutable as MV
|
||||
import qualified Data.Vector.Fusion.Stream.Monadic as VS
|
||||
import Control.Monad.Primitive
|
||||
import Control.Monad
|
||||
import qualified Streaming.Prelude as S
|
||||
|
||||
bindArrayBuffers :: Int -> VBO -> IO ()
|
||||
{-# INLINABLE bindArrayBuffers #-}
|
||||
@@ -32,7 +32,9 @@ bindShaderLayers shads counts = MV.imapM_ f shads
|
||||
let theVBO = _vaoVBO $ _shadVAO shad
|
||||
stride = sum $ _vboAttribSizes theVBO
|
||||
bindBuffer ArrayBuffer $= (Just . _vbo $ theVBO)
|
||||
VS.mapM_ (g stride theVBO) $ VS.enumFromStepN 0 1 6 -- [0..5]
|
||||
--VS.mapM_ (g stride theVBO) $ VS.enumFromStepN 0 1 6 -- [0..5]
|
||||
S.mapM_ (g stride theVBO) $ S.each [0..5]
|
||||
|
||||
where
|
||||
g stride theVBO lay = do
|
||||
numVs <- UMV.unsafeRead counts $ lay * 6 + i
|
||||
|
||||
+17
-18
@@ -2,7 +2,7 @@ module Shader.Poke
|
||||
( pokeVerxs
|
||||
, pokeLayVerxs
|
||||
, pokeArrayOff
|
||||
, pokePoint33s
|
||||
-- , pokePoint33s
|
||||
, pokeShape
|
||||
, pokeWallsWindowsFloor
|
||||
) where
|
||||
@@ -18,7 +18,6 @@ import qualified Data.Vector as V
|
||||
import qualified Data.Vector.Unboxed as UV
|
||||
import qualified Data.Vector.Unboxed.Mutable as UMV
|
||||
import qualified Data.Vector.Mutable as MV
|
||||
import qualified Data.Vector.Fusion.Stream.Monadic as VS
|
||||
--import Data.Vector.Fusion.Util
|
||||
import Control.Monad.Primitive
|
||||
--import qualified Control.Monad.Parallel as MP
|
||||
@@ -52,9 +51,9 @@ pokeWallsWindowsFloor
|
||||
-> [ ( Point3 , Point3 ) ]
|
||||
-> IO (Int,Int,Int)
|
||||
pokeWallsWindowsFloor wlptr wiptr flptr wls wis fls = do
|
||||
wlcounts1 <- VS.foldM' (pokeW wlptr) 0 (VS.fromList wls)
|
||||
wlcounts2 <- VS.foldM' (pokeW wiptr) 0 (VS.fromList wis)
|
||||
flcounts <- VS.foldM' (pokeF flptr) 0 (VS.fromList fls)
|
||||
wlcounts1 <- S.foldM_ (pokeW wlptr) (return 0) return (S.each wls)
|
||||
wlcounts2 <- S.foldM_ (pokeW wiptr) (return 0) return (S.each wis)
|
||||
flcounts <- S.foldM_ (pokeF flptr) (return 0) return (S.each fls)
|
||||
return (wlcounts1,wlcounts2,flcounts)
|
||||
|
||||
pokeF :: Ptr Float -> Int -> (Point3,Point3) -> IO Int
|
||||
@@ -232,17 +231,17 @@ pokeArrayOff :: Ptr Float -> Int -> [Float] -> IO ()
|
||||
{-# INLINE pokeArrayOff #-}
|
||||
pokeArrayOff ptr i = pokeArray (plusPtr ptr (floatSize * i))
|
||||
|
||||
pokePoint33s :: Ptr Float -> [(Point3,Point3)] -> IO Int
|
||||
pokePoint33s ptr = VS.foldlM' (pokePoint33 ptr) 0 . VS.fromList
|
||||
--pokePoint33s :: Ptr Float -> [(Point3,Point3)] -> IO Int
|
||||
--pokePoint33s ptr = S.foldM_ (pokePoint33 ptr) (return 0) return . S.each
|
||||
|
||||
pokePoint33 :: Ptr Float -> Int -> (Point3,Point3) -> IO Int
|
||||
pokePoint33 ptr n (V3 a b c,V3 d e f) = do
|
||||
pokeElemOff ptr (off 0) a
|
||||
pokeElemOff ptr (off 1) b
|
||||
pokeElemOff ptr (off 2) c
|
||||
pokeElemOff ptr (off 3) d
|
||||
pokeElemOff ptr (off 4) e
|
||||
pokeElemOff ptr (off 5) f
|
||||
return (n+1)
|
||||
where
|
||||
off i = n*6 + i
|
||||
--pokePoint33 :: Ptr Float -> Int -> (Point3,Point3) -> IO Int
|
||||
--pokePoint33 ptr n (V3 a b c,V3 d e f) = do
|
||||
-- pokeElemOff ptr (off 0) a
|
||||
-- pokeElemOff ptr (off 1) b
|
||||
-- pokeElemOff ptr (off 2) c
|
||||
-- pokeElemOff ptr (off 3) d
|
||||
-- pokeElemOff ptr (off 4) e
|
||||
-- pokeElemOff ptr (off 5) f
|
||||
-- return (n+1)
|
||||
-- where
|
||||
-- off i = n*6 + i
|
||||
|
||||
Reference in New Issue
Block a user