Remove renderbuffer from ping-pong framebuffers

This commit is contained in:
2021-07-11 17:56:43 +02:00
parent 26c6c3e426
commit 75254cd3e4
5 changed files with 17 additions and 87 deletions
+8 -31
View File
@@ -18,46 +18,23 @@ import qualified Control.Foldl as F
import Foreign hiding (rotate)
import Graphics.Rendering.OpenGL hiding (Line,translate,scale,imageHeight,Polygon,Color,T)
--import Data.Foldable
import Data.Tuple.Extra
--import Data.Tuple.Extra
--import qualified Data.IntMap.Strict as IM
import qualified SDL
--setWallDepth
-- :: RenderData
-- -> [(Point2,Point2)] -- ^ Wall points
-- -> (Float,Float) -- ^ View from point
-- -> IO Word32
--setWallDepth pdata wallPoints (viewFromx,viewFromy) = do
-- startTicks <- SDL.ticks
-- colorMask $= Color4 Disabled Disabled Disabled Disabled
-- nWalls <- F.foldM (pokeShader $ _lightingOccludeShader pdata) (map Render22 wallPoints)
-- bindShaderBuffers [_lightingOccludeShader pdata] [nWalls]
--
-- currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
-- -- reseting this uniform appears to be necessary
-- uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
-- $= Vector2 viewFromx viewFromy
---- cullFace $= Just Front
-- drawShader (_lightingOccludeShader pdata) nWalls
-- colorMask $= Color4 Enabled Enabled Enabled Enabled
-- endTicks <- SDL.ticks
-- return $ endTicks - startTicks
divideSize :: Int -> Size -> Size
divideSize i (Size x y) = Size (div x $ fromIntegral i) (div y $ fromIntegral i)
sizeToTexSize :: Size -> TextureSize2D
sizeToTexSize (Size x y) = TextureSize2D x y
{- |
Determine where light is shining in the world.
-}
{- | Determine where light is shining in the world. -}
createLightMap
:: RenderData
-> Int -- Resolution division
-> [(Point3,Float,Float)] -- Lights
-> [Polyhedra] -- foreground geometry
-> [Point2]
-> [Point2] -- ^ screen polygon
-> Int -- ^ number of walls
-> IO ()
createLightMap pdata resDiv lightPoints fpics scPol nWalls = do
@@ -156,16 +133,16 @@ createLightMap pdata resDiv lightPoints fpics scPol nWalls = do
-- disable depth testing for blurring
{- |
Blur between two framebuffers.
Assumes no depth testing is done (depthFunc %= Just Always).
Assumes no depth testing is done
-}
pingPongBlur :: RenderData -> IO ()
pingPongBlur pdata = do
bindFramebuffer Framebuffer $= fst3 (_fbo3 pdata)
textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
bindFramebuffer Framebuffer $= fst (_fbo3 pdata)
textureBinding Texture2D $= Just (snd $ _fbo2 pdata)
drawShader (_bloomBlurShader pdata) 4
bindFramebuffer Framebuffer $= fst3 (_fbo2 pdata)
textureBinding Texture2D $= Just (snd3 $ _fbo3 pdata)
bindFramebuffer Framebuffer $= fst (_fbo2 pdata)
textureBinding Texture2D $= Just (snd $ _fbo3 pdata)
drawShader (_bloomBlurShader pdata) 4
-- assumes that vertices have already been sent to the shader