Engage multiple threads

This commit is contained in:
2021-09-23 21:19:38 +01:00
parent 85edd98d62
commit 4a1501a358
6 changed files with 69 additions and 35 deletions
+2 -5
View File
@@ -35,11 +35,8 @@ import Control.Lens
import qualified Data.Set as S
import SDL
handleEvent :: World -> Event -> Maybe World
handleEvent = flip handleEvent'
handleEvent' :: Event -> World -> Maybe World
handleEvent' e = case eventPayload e of
handleEvent :: Event -> World -> Maybe World
handleEvent e = case eventPayload e of
KeyboardEvent kev -> handleKeyboardEvent kev
MouseMotionEvent mmev -> handleMouseMotionEvent mmev
MouseButtonEvent mbev -> handleMouseButtonEvent mbev
+14 -9
View File
@@ -23,6 +23,7 @@ import Shader.Parameters
import Foreign
import Control.Lens
import Control.Monad
import qualified Control.Monad.Parallel as MP
import Graphics.Rendering.OpenGL hiding (color,scale,translate,rotate)
import qualified SDL
import qualified Data.Vector.Unboxed.Mutable as UMV
@@ -42,16 +43,20 @@ doDrawing pdata w = do
viewFrom3d = Vector3 vfx vfy 20
shadV = _pictureShaders pdata
-- bind as much data into vbos as feasible at this point
-- pictures
-- pictures setup
layerCounts <- UMV.replicate (6*6) 0
pokeBindFoldableLayer shadV layerCounts $ worldPictures w
-- poke wall points and colors
nWalls <- poke224s (shadVBOptr $ _wallTextureShader pdata) wallPointsCol
(nShapeVs,nIndices,nSilIndices) <- pokeShape
(_vboPtr $ _vaoVBO $ _shadVAO $ _shapeShader pdata)
(_eboPtr $ _shapeEBO pdata)
(_eboPtr $ _silhouetteEBO pdata)
$ worldShape w
-- attempt to do this poking in parallel
(nWalls,(nShapeVs,nIndices,nSilIndices)) <- MP.bindM3 (\ _ a b -> return (a,b))
-- pictures poking
( pokeBindFoldableLayer shadV layerCounts $ worldPictures w )
-- poke wall points and colors
( poke224s (shadVBOptr $ _wallTextureShader pdata) wallPointsCol )
( pokeShape
(_vboPtr $ _vaoVBO $ _shadVAO $ _shapeShader pdata)
(_eboPtr $ _shapeEBO pdata)
(_eboPtr $ _silhouetteEBO pdata)
$ worldShape w
)
-- bind wall points, silhouette data, surface geometry
uncurry bindShaderBuffers $ unzip
[ ( _wallTextureShader pdata, nWalls)