Draw shadows in a framebuffer object

This commit is contained in:
jgk
2021-03-16 21:47:00 +01:00
parent 3707954913
commit b68e39ba2f
3 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ setupLoop wName xSize ySize
(\_ -> bracket customInit initCleanup $ \setup -> do -- setup <- customInit
-- swapInterval $= ImmediateUpdates
GL.blend $= GL.Enabled
GL.depthMask $= GL.Enabled
-- GL.depthMask $= GL.Enabled
GL.blendEquation $= GL.FuncAdd
GL.blendFunc $= (GL.SrcAlpha,GL.OneMinusSrcAlpha)
GL.clearColor $= GL.Color4 0 0.5 0 1
+1
View File
@@ -113,6 +113,7 @@ setupFramebuffer = do
bindRenderbuffer Renderbuffer $= fboRBO
renderbufferStorage Renderbuffer Depth24Stencil8 (RenderbufferSize 800 600)
-- not sure if the stencil is needed
framebufferRenderbuffer Framebuffer DepthStencilAttachment Renderbuffer fboRBO
fboStatus <- framebufferStatus Framebuffer
putStrLn $ show fboStatus
+2
View File
@@ -51,9 +51,11 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
-- draw lightmap
bindFramebuffer Framebuffer $= (_spareFBO pdata)
depthFunc $= Just Less
clearColor $= Color4 0 0.5 0 1
clearDepth $= (200)
clear [ColorBuffer]
-- depthMask $= Enabled
nWalls <- F.foldM (pokeShader (_wallShadowShader pdata)) wallPoints
bindShaderBuffers [_wallShadowShader pdata] [nWalls]