Add test tileset textures

This commit is contained in:
jgk
2021-06-11 13:51:06 +02:00
parent 02511afa80
commit a9aa2ca2cb
18 changed files with 75 additions and 38 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

+1 -1
View File
@@ -16,7 +16,7 @@ useItem n w = itemEffect c it w
-- TODO this needs sorting out and possibly removing -- TODO this needs sorting out and possibly removing
crUseItem :: Creature -> World -> World crUseItem :: Creature -> World -> World
--crUseItem cr = itemEffect (_crID cr) (_crInv cr IM.! _crInvSel cr) --crUseItem cr = itemEffect (_crID cr) (_crInv cr IM.! _crInvSel cr)
crUseItem cr = tryUseItem cr crUseItem = tryUseItem
tryUseItem tryUseItem
:: Creature :: Creature
+6 -6
View File
@@ -68,7 +68,7 @@ feet cr = case cr ^? crStance . carriage of
, translate 0 (-off) $ circleSolid 5 , translate 0 (-off) $ circleSolid 5
] ]
where where
setL = onLayerL [levLayer CrLayer, (-5)] . color (greyN 0.3) . pictures setL = onLayerL [levLayer CrLayer, -5] . color (greyN 0.3) . pictures
off = 5 off = 5
sLen = _strideLength $ _crStance cr sLen = _strideLength $ _crStance cr
f i = 6 * fromIntegral (sLen - i) / fromIntegral sLen f i = 6 * fromIntegral (sLen - i) / fromIntegral sLen
@@ -86,7 +86,7 @@ arms col cr
_ -> blank _ -> blank
where where
sc = scale 1 1 sc = scale 1 1
setL = onLayerL [levLayer CrLayer, (-4)] . color (light4 col) . pictures setL = onLayerL [levLayer CrLayer, -4] . color (light4 col) . pictures
off = 8 off = 8
sLen = _strideLength $ _crStance cr sLen = _strideLength $ _crStance cr
f i = negate 2 + negate 6 * fromIntegral (sLen - i) / fromIntegral sLen f i = negate 2 + negate 6 * fromIntegral (sLen - i) / fromIntegral sLen
@@ -103,20 +103,20 @@ naked col cr
[ translate (0.25 * crad) 0 $ circleSolid (crad * 0.5) [ translate (0.25 * crad) 0 $ circleSolid (crad * 0.5)
, onCrL . translate 8 (-8) . color col' $ circleSolid 4 , onCrL . translate 8 (-8) . color col' $ circleSolid 4
, translate 0 3 . rotate (negate 0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr , translate 0 3 . rotate (negate 0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr
, translate 0 (negate 3) . rotate (0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr , translate 0 (negate 3) . rotate 0.2 . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr
] ]
| aimingTwist = translate 0 (0.5* crad) . rotate twistA $ pictures | aimingTwist = translate 0 (0.5* crad) . rotate twistA $ pictures
[ aboveIt . translate (negate 0.25 * crad) 0.25 $ [ aboveIt . translate (negate 0.25 * crad) 0.25 $
circleSolid (crad * 0.5) circleSolid (crad * 0.5)
, onCrL . translate 12 (4) . color col' $ circleSolid 4 , onCrL . translate 12 4 . color col' $ circleSolid 4
, onCrL . translate 4 (-10) . color col' $ circleSolid 4 , onCrL . translate 4 (-10) . color col' $ circleSolid 4
, onCrL . rotate (negate 0.2) . translate 2 3 . rotate (negate 0.4) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr , onCrL . rotate (negate 0.2) . translate 2 3 . rotate (negate 0.4) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr
, onCrL . rotate (negate 0.2) . translate 0 (negate 3) . rotate (0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr , onCrL . rotate (negate 0.2) . translate 0 (negate 3) . rotate 0.2 . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr
] ]
| otherwise = onCrL $ pictures | otherwise = onCrL $ pictures
[ translate (0.25 * crad) 0 $ circleSolid (crad * 0.5) [ translate (0.25 * crad) 0 $ circleSolid (crad * 0.5)
, translate 0 3 . rotate (negate 0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr , translate 0 3 . rotate (negate 0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr
, translate 0 (negate 3) . rotate (0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr , translate 0 (negate 3) . rotate 0.2 . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr
] ]
where where
aboveIt = onLayer HPtLayer aboveIt = onLayer HPtLayer
+2 -2
View File
@@ -162,9 +162,9 @@ defaultPT = Projectile
{ _pjPos = (0,0) { _pjPos = (0,0)
, _pjStartPos = (0,0) , _pjStartPos = (0,0)
, _pjVel = (0,0) , _pjVel = (0,0)
, _pjDraw = \_ -> blank , _pjDraw = const blank
, _pjID = 0 , _pjID = 0
, _pjUpdate = \_ -> id , _pjUpdate = const id
} }
defaultPP :: PressPlate defaultPP :: PressPlate
defaultPP = PressPlate defaultPP = PressPlate
+3 -3
View File
@@ -11,9 +11,9 @@ defaultShell = Shell
, _pjAcc = (0,0) , _pjAcc = (0,0)
, _pjDir = 0 , _pjDir = 0
, _pjSpin = 0 , _pjSpin = 0
, _pjDraw = \_ -> blank , _pjDraw = const blank
, _pjID = 0 , _pjID = 0
, _pjTimer = 0 , _pjTimer = 0
, _pjUpdate = \_ -> id , _pjUpdate = const id
, _pjPayload = \_ -> id , _pjPayload = const id
} }
+2 -2
View File
@@ -46,9 +46,9 @@ defaultAutoGun = defaultGun
} }
defaultShellAmmo :: Ammo defaultShellAmmo :: Ammo
defaultShellAmmo = ShellAmmo defaultShellAmmo = ShellAmmo
{ _amPayload = \_ -> id { _amPayload = const id
, _amString = "Shell" , _amString = "Shell"
, _amPjParams = [] , _amPjParams = []
, _amPjDraw = \_ -> blank , _amPjDraw = const blank
, _amParamSel = 0 , _amParamSel = 0
} }
+1 -1
View File
@@ -114,7 +114,7 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
moveYourAmmoSel :: Int -> World -> World moveYourAmmoSel :: Int -> World -> World
moveYourAmmoSel i w = case yourItem w ^? wpAmmo . amPjParams of moveYourAmmoSel i w = case yourItem w ^? wpAmmo . amPjParams of
Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w)) Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
. wpAmmo . amParamSel %~ (`mod` (length l)) . (subtract i) . wpAmmo . amParamSel %~ (`mod` (length l)) . subtract i
_ -> w _ -> w
moveYourAmmoParam :: Int -> World -> World moveYourAmmoParam :: Int -> World -> World
moveYourAmmoParam i w = case yourItem w ^? wpAmmo . amPjParams . ix paramid . pjMaxParam of moveYourAmmoParam i w = case yourItem w ^? wpAmmo . amPjParams . ix paramid . pjMaxParam of
+3 -3
View File
@@ -92,12 +92,12 @@ useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
effectGun :: String -> (Creature -> World -> World) -> Item effectGun :: String -> (Creature -> World -> World) -> Item
effectGun name eff = defaultGun effectGun name eff = defaultGun
{ _itName = name ++ "Gun" { _itName = name ++ "Gun"
, _itUse = \_ -> eff , _itUse = const eff
} }
autoEffectGun :: String -> (Creature -> World -> World) -> Item autoEffectGun :: String -> (Creature -> World -> World) -> Item
autoEffectGun name eff = defaultAutoGun autoEffectGun name eff = defaultAutoGun
{ _itName = name ++ "Gun" { _itName = name ++ "Gun"
, _itUse = \_ -> eff , _itUse = const eff
} }
rezGun :: Item rezGun :: Item
rezGun = defaultGun rezGun = defaultGun
@@ -876,7 +876,7 @@ throwRemoteBomb cr w = setLocation
explodeRemoteBomb :: Int -> Int -> Creature -> World -> World explodeRemoteBomb :: Int -> Int -> Creature -> World -> World
explodeRemoteBomb itid pjid cr w explodeRemoteBomb itid pjid cr w
= set (projectiles . ix pjid . pjUpdate) (\_ -> retireRemoteBomb itid 30 pjid) = set (projectiles . ix pjid . pjUpdate) (\_ -> retireRemoteBomb itid 30 pjid)
$ set (projectiles . ix pjid . pjDraw) (\_ -> blank) -- $ set (projectiles . ix pjid . pjDraw) (\_ -> blank)
$ set (creatures . ix cid . crInv . ix j . itUse) (\_ -> const id) $ set (creatures . ix cid . crInv . ix j . itUse) (\_ -> const id)
$ resetName $ resetName
$ resetPict $ resetPict
+3 -3
View File
@@ -46,7 +46,7 @@ boostSelfL x cr invid w = case boostPoint x cr w of
. (crInv . ix invid %~ . (crInv . ix invid %~
ammoEff ammoEff
. (itEffect . itEffectCounter .~ 1) . (itEffect . itEffectCounter .~ 1)
. (itAttachment .~ Just (ItInt pid)) . (itAttachment ?~ ItInt pid)
) )
boostSelf boostSelf
@@ -85,8 +85,8 @@ updateLinearShockwave pj w
drawBoostShockwave :: Projectile -> Picture drawBoostShockwave :: Projectile -> Picture
drawBoostShockwave pj = setLayer 1 $ onLayer UPtLayer $ pictures $ drawBoostShockwave pj = setLayer 1 $ onLayer UPtLayer $ pictures $
theArc ++ theArc ++
[ lineCol $ zip (reverse lps) $ map (flip withAlpha white) [0,0.05..] [ lineCol $ zip (reverse lps) $ map (`withAlpha` white) [0,0.05..]
, lineCol $ zip (reverse rps) $ map (flip withAlpha white) [0,0.05..] , lineCol $ zip (reverse rps) $ map (`withAlpha` white) [0,0.05..]
] ]
where where
-- drawing half a circle here is not perfect, a slightly smaller arc would fit -- drawing half a circle here is not perfect, a slightly smaller arc would fit
+1 -1
View File
@@ -56,7 +56,7 @@ itemLaserScopeEffect :: ItEffect
itemLaserScopeEffect itemLaserScopeEffect
= ItInvEffect {_itInvEffect = f ,_itEffectCounter = 0 } = ItInvEffect {_itInvEffect = f ,_itEffectCounter = 0 }
where where
moveHammerUp !HammerDown = HammerReleased moveHammerUp HammerDown = HammerReleased
moveHammerUp !_ = HammerUp moveHammerUp !_ = HammerUp
f _ cr invid w f _ cr invid w
| invid == _crInvSel cr && crIsAiming' cr = w | invid == _crInvSel cr && crIsAiming' cr = w
+4 -4
View File
@@ -35,7 +35,7 @@ launcher = defaultGun
, _wpReloadState = 0 , _wpReloadState = 0
, _itUseRate = 20 , _itUseRate = 20
, _itUseTime = 0 , _itUseTime = 0
, _itUse = \it -> shootWithSound (fromIntegral launcherSound) $ aRocketWithItemParams it , _itUse = shootWithSound (fromIntegral launcherSound) . aRocketWithItemParams
, _wpSpread = 0.02 , _wpSpread = 0.02
, _wpRange = 20 , _wpRange = 20
, _itFloorPict = onLayer FlItLayer launcherPic , _itFloorPict = onLayer FlItLayer launcherPic
@@ -64,7 +64,7 @@ basicAmPjMoves =
] ]
spinDrag :: PjParam spinDrag :: PjParam
spinDrag = PjParam spinDrag = PjParam
{ _pjMoveParam = \i _ _ -> reduceSpinBy (1 - (fromIntegral i)*2 / 200) { _pjMoveParam = \i _ _ -> reduceSpinBy (1 - fromIntegral i*2 / 200)
, _pjIntParam = 1 , _pjIntParam = 1
, _pjDisplayParam = pjPadText "SPIN SLOWDOWN" . show , _pjDisplayParam = pjPadText "SPIN SLOWDOWN" . show
, _pjMaxParam = 5 , _pjMaxParam = 5
@@ -87,7 +87,7 @@ thrustParam = PjParam
} }
pjThrust :: Int -> Projectile -> World -> World pjThrust :: Int -> Projectile -> World -> World
pjThrust i = pjEffTimeRange (st,et) $ doThrust pjThrust i = pjEffTimeRange (st,et) doThrust
where where
et | i == 0 = 36 et | i == 0 = 36
| otherwise = 40 - (fromIntegral i * 20) | otherwise = 40 - (fromIntegral i * 20)
@@ -131,7 +131,7 @@ aRocketWithItemParams it cr w = over projectiles (IM.insert i theShell) w
i = IM.newKey $ _projectiles w i = IM.newKey $ _projectiles w
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir) pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
dir = _crDir cr dir = _crDir cr
ammoMvs pj w' = foldr (\pjP -> (_pjMoveParam pjP) (_pjIntParam pjP) it cr pj) w' (_amPjParams am) ammoMvs pj w' = foldr (\pjP -> _pjMoveParam pjP (_pjIntParam pjP) it cr pj) w' (_amPjParams am)
theShell = defaultShell theShell = defaultShell
{ _pjPos = pos { _pjPos = pos
, _pjStartPos = pos , _pjStartPos = pos
+2 -2
View File
@@ -126,7 +126,7 @@ tractorBeamAt colID i pos dir = Projectile
{ _pjPos = pos { _pjPos = pos
, _pjStartPos = p' , _pjStartPos = p'
, _pjVel = d , _pjVel = d
, _pjDraw = \_ -> blank , _pjDraw = const blank
, _pjID = i , _pjID = i
, _pjUpdate = \_ -> updateTractor colID 10 i , _pjUpdate = \_ -> updateTractor colID 10 i
} }
@@ -139,7 +139,7 @@ The interaction of this with objects, walls etc needs more thought. -}
updateTractor :: Int -> Int -> Int -> World -> World updateTractor :: Int -> Int -> Int -> World -> World
updateTractor colID time i w updateTractor colID time i w
| time > 0 = set (projectiles . ix i . pjUpdate) (\_ -> updateTractor colID (time-1) i) | time > 0 = set (projectiles . ix i . pjUpdate) (\_ -> updateTractor colID (time-1) i)
$ set (projectiles . ix i . pjDraw) (\_ -> pic) $ set (projectiles . ix i . pjDraw) (const pic)
$ over creatures (IM.map tractCr) $ over creatures (IM.map tractCr)
$ over floorItems (IM.map tractFlIt) $ over floorItems (IM.map tractFlIt)
w w
+3 -5
View File
@@ -54,7 +54,7 @@ doDrawing pdata w = do
pic = worldPictures w pic = worldPictures w
wallPoints = map fst wallPointsCol wallPoints = map fst wallPointsCol
-- set the coordinate uniforms ready for drawing elements using world coordinates -- set the coordinate uniforms ready for drawing elements using world coordinates
setCommonUniforms pdata rot camzoom trans wins setIsoMatrixUniforms pdata rot camzoom trans wins
depthFunc $= Just Less depthFunc $= Just Less
pmat <- (newMatrix RowMajor $ perspectiveMatrix rot camzoom trans wins viewFroms) pmat <- (newMatrix RowMajor $ perspectiveMatrix rot camzoom trans wins viewFroms)
:: IO (GLmatrix GLfloat) :: IO (GLmatrix GLfloat)
@@ -138,8 +138,7 @@ renderBlankWalls pdata wps pmat = do
n <- F.foldM (pokeShader $ _wallBlankShader pdata) wps n <- F.foldM (pokeShader $ _wallBlankShader pdata) wps
bindShaderBuffers [_wallBlankShader pdata] [n] bindShaderBuffers [_wallBlankShader pdata] [n]
currentProgram $= Just (_shaderProgram $ _wallBlankShader pdata) currentProgram $= Just (_shaderProgram $ _wallBlankShader pdata)
uniform (( _shaderMatrixUniform $ _wallBlankShader pdata) ) uniform (_shaderMatrixUniform $ _wallBlankShader pdata) $= pmat
$= pmat
cullFace $= Just Back cullFace $= Just Back
drawShader (_wallBlankShader pdata) n drawShader (_wallBlankShader pdata) n
cullFace $= Nothing cullFace $= Nothing
@@ -153,8 +152,7 @@ renderTextureWalls pdata wps pmat = do
n <- F.foldM (pokeShader $ _wallTextureShader pdata) wps n <- F.foldM (pokeShader $ _wallTextureShader pdata) wps
bindShaderBuffers [_wallTextureShader pdata] [n] bindShaderBuffers [_wallTextureShader pdata] [n]
currentProgram $= Just (_shaderProgram $ _wallTextureShader pdata) currentProgram $= Just (_shaderProgram $ _wallTextureShader pdata)
uniform (( _shaderMatrixUniform $ _wallTextureShader pdata) ) uniform (_shaderMatrixUniform $ _wallTextureShader pdata) $= pmat
$= pmat
cullFace $= Just Back cullFace $= Just Back
drawShader (_wallTextureShader pdata) n drawShader (_wallTextureShader pdata) n
cullFace $= Nothing cullFace $= Nothing
+1 -1
View File
@@ -55,7 +55,7 @@ testPic w =
] ]
crDraw :: World -> Creature -> Picture crDraw :: World -> Creature -> Picture
crDraw w c = (_crPict c c w) crDraw w c = _crPict c c w
ppDraw :: PressPlate -> Picture ppDraw :: PressPlate -> Picture
ppDraw c = uncurry translate (_ppPos c) $ rotate (_ppRot c) (_ppPict c) ppDraw c = uncurry translate (_ppPos c) $ rotate (_ppRot c) (_ppPict c)
btDraw :: Button -> Picture btDraw :: Button -> Picture
+10
View File
@@ -22,6 +22,7 @@ data RenderData = RenderData
, _wallBlankShader :: FullShader ((Point2,Point2),Point4) , _wallBlankShader :: FullShader ((Point2,Point2),Point4)
, _wallTextureShader :: FullShader ((Point2,Point2),Point4) , _wallTextureShader :: FullShader ((Point2,Point2),Point4)
, _backgroundShader :: FullShader (Point2,Point2,Point2,Point2) , _backgroundShader :: FullShader (Point2,Point2,Point2,Point2)
, _textureShader :: FullShader (Point3,Point2)
, _fullscreenShader :: FullShader () , _fullscreenShader :: FullShader ()
, _boxBlurShader :: FullShader () , _boxBlurShader :: FullShader ()
, _grayscaleShader :: FullShader () , _grayscaleShader :: FullShader ()
@@ -85,6 +86,11 @@ preloadRender = do
-- textured wallShader -- textured wallShader
wlTexture <- makeShader "wall/texture" [vert,geom,frag] [(0,4),(1,4)] Points pokeWPColStrat wlTexture <- makeShader "wall/texture" [vert,geom,frag] [(0,4),(1,4)] Points pokeWPColStrat
>>= addTexture "data/texture/grayscaleDirt.png" >>= addTexture "data/texture/grayscaleDirt.png"
-- texture shader
textShad <- makeShader "texture/simpleWorld" [vert,frag] [(0,3),(1,2)] Triangles poke32
>>= addTexture "data/texture/ayene_wooden_floor.png"
-- framebuffer for lighting -- framebuffer for lighting
(fbo,fboTO,fboRBO) <- setupFramebufferWithStencil (fbo,fboTO,fboRBO) <- setupFramebufferWithStencil
framebuf2 <- setupFramebufferWithStencil framebuf2 <- setupFramebufferWithStencil
@@ -98,6 +104,7 @@ preloadRender = do
, _lightingWallShader = wlLightShad , _lightingWallShader = wlLightShad
, _wallBlankShader = wlBlank , _wallBlankShader = wlBlank
, _wallTextureShader = wlTexture , _wallTextureShader = wlTexture
, _textureShader = textShad
, _backgroundShader = bgShad , _backgroundShader = bgShad
, _fullscreenShader = fsShad , _fullscreenShader = fsShad
, _boxBlurShader = boxBlurShad , _boxBlurShader = boxBlurShad
@@ -209,5 +216,8 @@ pokeWPStrat ((x,y),(z,w)) = [[[x,y,z,w]]]
pokeWPColStrat :: ((Point2,Point2),Point4) -> [[[Float]]] pokeWPColStrat :: ((Point2,Point2),Point4) -> [[[Float]]]
pokeWPColStrat (((x,y),(z,w)),(r,g,b,a)) = [[[x,y,z,w],[r,g,b,a]]] pokeWPColStrat (((x,y),(z,w)),(r,g,b,a)) = [[[x,y,z,w],[r,g,b,a]]]
poke32 :: (Point3,Point2) -> [[[Float]]]
poke32 ((x,y,z),(a,b)) = [[[x,y,z],[a,b]]]
pokeBGStrat :: a -> [[[Float]]] pokeBGStrat :: a -> [[[Float]]]
pokeBGStrat = const [] pokeBGStrat = const []
+32 -3
View File
@@ -31,7 +31,7 @@ setWallDepth
-> (Float,Float) -- ^ View from point -> (Float,Float) -- ^ View from point
-> GLmatrix GLfloat -> GLmatrix GLfloat
-> IO Word32 -> IO Word32
setWallDepth pdata wallPoints (viewFromx,viewFromy) pmat = do setWallDepth pdata wallPoints (viewFromx,viewFromy) _ = do
startTicks <- SDL.ticks startTicks <- SDL.ticks
colorMask $= Color4 Disabled Disabled Disabled Disabled colorMask $= Color4 Disabled Disabled Disabled Disabled
nWalls <- F.foldM (pokeShader $ _lightingOccludeShader pdata) wallPoints nWalls <- F.foldM (pokeShader $ _lightingOccludeShader pdata) wallPoints
@@ -41,6 +41,8 @@ setWallDepth pdata wallPoints (viewFromx,viewFromy) pmat = do
-- reseting this uniform appears to be necessary -- reseting this uniform appears to be necessary
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata) uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
$= Vector2 viewFromx viewFromy $= Vector2 viewFromx viewFromy
-- the following uniform, however, was probably already set by
-- createLightMap
-- uniform ( (_shaderMatrixUniform $ _lightingOccludeShader pdata)) -- uniform ( (_shaderMatrixUniform $ _lightingOccludeShader pdata))
-- $= pmat -- $= pmat
-- cullFace $= Just Front -- cullFace $= Just Front
@@ -92,8 +94,7 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat _
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata) currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata) uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
$= Vector2 viewFromx viewFromy $= Vector2 viewFromx viewFromy
uniform ( (_shaderMatrixUniform $ _lightingOccludeShader pdata)) uniform (_shaderMatrixUniform $ _lightingOccludeShader pdata) $= pmat
$= pmat
cullFace $= Just Back cullFace $= Just Back
drawShader (_lightingOccludeShader pdata) nWalls drawShader (_lightingOccludeShader pdata) nWalls
@@ -225,6 +226,34 @@ setCommonUniforms pdata rot camZoom (tranx,trany) (winx,winy) = do
: map extractProgAndUnis (_pictureShaders pdata) : map extractProgAndUnis (_pictureShaders pdata)
) )
setIsoMatrixUniforms
:: RenderData
-> Float -- ^ Rotation
-> Float -- ^ Zoom
-> (Float,Float) -- ^ Translation
-> (Float,Float) -- ^ Window size
-> IO ()
setIsoMatrixUniforms pdata rot camZoom (tranx,trany) (winx,winy) = do
setShaderUniforms rot camZoom (tranx,trany) (winx,winy)
( extractProgAndUnis (_lightingFloorShader pdata)
: extractProgAndUnis (_backgroundShader pdata)
: extractProgAndUnis (_textureShader pdata)
: map extractProgAndUnis (_pictureShaders pdata)
)
renderShader
:: Foldable f
=> FullShader a
-> f a
-> IO Word32
renderShader shad dat = do
sticks <- SDL.ticks
i <- F.foldM (pokeShader shad) dat
bindShaderBuffers [shad] [i]
drawShader shad i
eticks <- SDL.ticks
return $ eticks - sticks
renderFoldable renderFoldable
:: Foldable f :: Foldable f
=> RenderData => RenderData
+1 -1
View File
@@ -70,7 +70,7 @@ bindArrayBuffers :: Int -> [(BufferObject,Ptr Float,Int)] -> IO ()
bindArrayBuffers numVs ps = do bindArrayBuffers numVs ps = do
forM_ ps $ \(bo,ptr,i) -> do forM_ ps $ \(bo,ptr,i) -> do
bindBuffer ArrayBuffer $= Just bo bindBuffer ArrayBuffer $= Just bo
bufferData ArrayBuffer $= (fromIntegral $ floatSize * numVs * i, ptr, StreamDraw) bufferData ArrayBuffer $= (fromIntegral $ floatSize * numVs * i, ptr, DynamicDraw)
bindShaderBuffers :: [FullShader a] -> [Int] -> IO () bindShaderBuffers :: [FullShader a] -> [Int] -> IO ()
bindShaderBuffers = zipWithM_ f bindShaderBuffers = zipWithM_ f