Fix resize bug, resize RenderbufferObject of ping pong framebuffers
This commit is contained in:
@@ -12,7 +12,7 @@ import Data.Bifunctor
|
|||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import qualified Data.IntSet as IS
|
import qualified Data.IntSet as IS
|
||||||
zoneSize :: Float
|
zoneSize :: Float
|
||||||
zoneSize = 50
|
zoneSize = 25
|
||||||
--zoneSize = 100
|
--zoneSize = 100
|
||||||
|
|
||||||
floorHun :: Float -> Int
|
floorHun :: Float -> Int
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Control.Lens
|
|||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
|
|
||||||
targetYouLOS :: Creature -> World -> Maybe Creature
|
targetYouLOS :: Creature -> World -> Maybe Creature
|
||||||
|
{-# INLINE targetYouLOS #-}
|
||||||
targetYouLOS cr w
|
targetYouLOS cr w
|
||||||
| hasLOS (_crPos cr) (_crPos $ you w) w = Just $ you w
|
| hasLOS (_crPos cr) (_crPos $ you w) w = Just $ you w
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
|
|||||||
@@ -38,3 +38,5 @@ swarmCrit = defaultCreature
|
|||||||
, _crFaction = ColorFaction yellow
|
, _crFaction = ColorFaction yellow
|
||||||
, _crMeleeCooldown = Just 0
|
, _crMeleeCooldown = Just 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ roomTreex = do
|
|||||||
[[StartRoom]
|
[[StartRoom]
|
||||||
,[Corridor]
|
,[Corridor]
|
||||||
,[SpecificRoom . pure . pure . Right $ roomGlassOctogon 400
|
,[SpecificRoom . pure . pure . Right $ roomGlassOctogon 400
|
||||||
& rmPS %~ ([swarmPS 0 (x,y) 0 swarmCrit | x <- [-20,-19.5.. 20] , y <- [200,200.5..202] ]++)
|
& rmPS %~ ([swarmPS 0 (x,y) 0 swarmCrit | x <- [-20,-19.5.. 20] , y <- [200,201] ]++)
|
||||||
]
|
]
|
||||||
,[Corridor]
|
,[Corridor]
|
||||||
,[Corridor]
|
,[Corridor]
|
||||||
|
|||||||
+2
-1
@@ -23,6 +23,7 @@ import Control.Applicative
|
|||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Control.Foldl as F
|
import qualified Control.Foldl as F
|
||||||
|
import Data.Tuple.Extra
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.Bifunctor
|
import Data.Bifunctor
|
||||||
@@ -95,7 +96,7 @@ doDrawing pdata w = do
|
|||||||
-- we probably do not want to blend during this step
|
-- we probably do not want to blend during this step
|
||||||
blend $= Disabled
|
blend $= Disabled
|
||||||
depthFunc $= Just Always
|
depthFunc $= Just Always
|
||||||
textureBinding Texture2D $= Just (snd $ _fbo2 pdata)
|
textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
|
||||||
-- textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
-- textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||||
-- generateMipmap' Texture2D
|
-- generateMipmap' Texture2D
|
||||||
if _crHP (you w) > 0
|
if _crHP (you w) > 0
|
||||||
|
|||||||
+4
-13
@@ -31,8 +31,8 @@ data RenderData = RenderData
|
|||||||
, _spareFBO :: FramebufferObject
|
, _spareFBO :: FramebufferObject
|
||||||
, _fboTexture :: TextureObject
|
, _fboTexture :: TextureObject
|
||||||
, _fboRenderbufferObject :: RenderbufferObject
|
, _fboRenderbufferObject :: RenderbufferObject
|
||||||
, _fbo2 :: (FramebufferObject, TextureObject)
|
, _fbo2 :: (FramebufferObject, TextureObject, RenderbufferObject)
|
||||||
, _fbo3 :: (FramebufferObject, TextureObject)
|
, _fbo3 :: (FramebufferObject, TextureObject, RenderbufferObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''RenderData
|
makeLenses ''RenderData
|
||||||
@@ -47,7 +47,6 @@ preloadRender = do
|
|||||||
wlLightShad
|
wlLightShad
|
||||||
<- makeShader "lighting/wall" [vert,geom,frag] [(0,4)] Points pokeWPStrat
|
<- makeShader "lighting/wall" [vert,geom,frag] [(0,4)] Points pokeWPStrat
|
||||||
>>= addUniforms ["lightPos","perpMat","radLum"]
|
>>= addUniforms ["lightPos","perpMat","radLum"]
|
||||||
|
|
||||||
-- 2D draw shaders
|
-- 2D draw shaders
|
||||||
bslist <- makeShader "twoD/basic" [vert,frag] [(0,3),(1,4)] Triangles pokeTriStrat
|
bslist <- makeShader "twoD/basic" [vert,frag] [(0,3),(1,4)] Triangles pokeTriStrat
|
||||||
lslist <- makeShader "twoD/basic" [vert,frag] [(0,3),(1,4)] Lines pokeLineStrat
|
lslist <- makeShader "twoD/basic" [vert,frag] [(0,3),(1,4)] Lines pokeLineStrat
|
||||||
@@ -58,7 +57,6 @@ preloadRender = do
|
|||||||
cslist <- makeShader "twoD/character" [vert,geom,frag]
|
cslist <- makeShader "twoD/character" [vert,geom,frag]
|
||||||
[(0,3),(1,4),(2,3)] Points pokeCharStrat
|
[(0,3),(1,4),(2,3)] Points pokeCharStrat
|
||||||
>>= addTexture "data/texture/charMap.png"
|
>>= addTexture "data/texture/charMap.png"
|
||||||
|
|
||||||
-- texture shaders, no textures attached
|
-- texture shaders, no textures attached
|
||||||
fsShad <- makeShader "texture/simple" [vert,frag] [(0,2),(1,2)] TriangleStrip $ const
|
fsShad <- makeShader "texture/simple" [vert,frag] [(0,2),(1,2)] TriangleStrip $ const
|
||||||
[[[-1, 1],[0,1]]
|
[[[-1, 1],[0,1]]
|
||||||
@@ -81,12 +79,9 @@ preloadRender = do
|
|||||||
,[[ 1,-1],[1,0]]
|
,[[ 1,-1],[1,0]]
|
||||||
]
|
]
|
||||||
_ <- F.foldM (pokeShader grayscaleShad) [()] -- fix fullscreen vertex positions now
|
_ <- F.foldM (pokeShader grayscaleShad) [()] -- fix fullscreen vertex positions now
|
||||||
|
|
||||||
|
|
||||||
-- background shader
|
-- background shader
|
||||||
bgShad <- makeShader "background" [vert,geom,frag] [(0,4),(1,2)] Points pokeBGStrat
|
bgShad <- makeShader "background" [vert,geom,frag] [(0,4),(1,2)] Points pokeBGStrat
|
||||||
>>= addTexture "data/texture/smudgedDirt.png"
|
>>= addTexture "data/texture/smudgedDirt.png"
|
||||||
|
|
||||||
-- blank wallShader
|
-- blank wallShader
|
||||||
wlBlank <- makeShader "wall/blank" [vert,geom,frag] [(0,4),(1,4)] Points pokeWPColStrat
|
wlBlank <- makeShader "wall/blank" [vert,geom,frag] [(0,4),(1,4)] Points pokeWPColStrat
|
||||||
-- >>= addTexture "data/texture/grayscaleDirt.png"
|
-- >>= addTexture "data/texture/grayscaleDirt.png"
|
||||||
@@ -95,16 +90,12 @@ preloadRender = do
|
|||||||
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"
|
||||||
>>= addUniforms ["perpMat"]
|
>>= addUniforms ["perpMat"]
|
||||||
|
|
||||||
-- framebuffer for lighting
|
-- framebuffer for lighting
|
||||||
(fbo,fboTO,fboRBO) <- setupFramebufferWithStencil
|
(fbo,fboTO,fboRBO) <- setupFramebufferWithStencil
|
||||||
|
framebuf2 <- setupFramebufferWithStencil
|
||||||
framebuf2 <- setupFramebuffer
|
framebuf3 <- setupFramebufferWithStencil
|
||||||
framebuf3 <- setupFramebuffer
|
|
||||||
|
|
||||||
-- reset to default framebuffer, ready for drawing direct to screen
|
-- reset to default framebuffer, ready for drawing direct to screen
|
||||||
bindFramebuffer Framebuffer $= defaultFramebufferObject
|
bindFramebuffer Framebuffer $= defaultFramebufferObject
|
||||||
|
|
||||||
return $ RenderData
|
return $ RenderData
|
||||||
{ _pictureShaders = [bslist,lslist,cslist,aslist,eslist,bezierQuadShader]
|
{ _pictureShaders = [bslist,lslist,cslist,aslist,eslist,bezierQuadShader]
|
||||||
, _lightingFloorShader = lsShad
|
, _lightingFloorShader = lsShad
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import qualified Control.Foldl as F
|
|||||||
import Foreign hiding (rotate)
|
import Foreign hiding (rotate)
|
||||||
import Graphics.Rendering.OpenGL hiding (Line,translate,scale,imageHeight,imageWidth,Polygon,Color,T)
|
import Graphics.Rendering.OpenGL hiding (Line,translate,scale,imageHeight,imageWidth,Polygon,Color,T)
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
|
import Data.Tuple.Extra
|
||||||
import Data.Maybe (fromJust)
|
import Data.Maybe (fromJust)
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
@@ -145,7 +146,7 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat =
|
|||||||
-- disable depth testing for blurring
|
-- disable depth testing for blurring
|
||||||
depthFunc $= Just Always
|
depthFunc $= Just Always
|
||||||
-- draw the lightmap on a full size fbo
|
-- draw the lightmap on a full size fbo
|
||||||
bindFramebuffer Framebuffer $= fst (_fbo2 pdata)
|
bindFramebuffer Framebuffer $= fst3 (_fbo2 pdata)
|
||||||
colorMask $= Color4 Disabled Disabled Disabled Enabled
|
colorMask $= Color4 Disabled Disabled Disabled Enabled
|
||||||
bindShaderBuffers [_boxBlurShader pdata] [4]
|
bindShaderBuffers [_boxBlurShader pdata] [4]
|
||||||
textureBinding Texture2D $= Just (_fboTexture pdata)
|
textureBinding Texture2D $= Just (_fboTexture pdata)
|
||||||
@@ -169,14 +170,14 @@ Assumes no depth testing is done (depthFunc %= Just Always).
|
|||||||
-}
|
-}
|
||||||
pingPongBlur :: RenderData -> IO ()
|
pingPongBlur :: RenderData -> IO ()
|
||||||
pingPongBlur pdata = do
|
pingPongBlur pdata = do
|
||||||
bindFramebuffer Framebuffer $= fst (_fbo3 pdata)
|
bindFramebuffer Framebuffer $= fst3 (_fbo3 pdata)
|
||||||
textureBinding Texture2D $= Just (snd $ _fbo2 pdata)
|
textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
|
||||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||||
generateMipmap' Texture2D
|
generateMipmap' Texture2D
|
||||||
drawShader (_boxBlurShader pdata) 4
|
drawShader (_boxBlurShader pdata) 4
|
||||||
|
|
||||||
bindFramebuffer Framebuffer $= fst (_fbo2 pdata)
|
bindFramebuffer Framebuffer $= fst3 (_fbo2 pdata)
|
||||||
textureBinding Texture2D $= Just (snd $ _fbo3 pdata)
|
textureBinding Texture2D $= Just (snd3 $ _fbo3 pdata)
|
||||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||||
generateMipmap' Texture2D
|
generateMipmap' Texture2D
|
||||||
drawShader (_boxBlurShader pdata) 4
|
drawShader (_boxBlurShader pdata) 4
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ resizeSpareFBO xsize ysize xfull yfull pdata = do
|
|||||||
return pdata
|
return pdata
|
||||||
|
|
||||||
resizeTextureFBO
|
resizeTextureFBO
|
||||||
:: (FramebufferObject , TextureObject)
|
:: (FramebufferObject , TextureObject, RenderbufferObject)
|
||||||
-> Int
|
-> Int
|
||||||
-> Int
|
-> Int
|
||||||
-> IO ()
|
-> IO ()
|
||||||
resizeTextureFBO (fboName,fboTO) xsize ysize = do
|
resizeTextureFBO (fboName,fboTO,fboRBO) xsize ysize = do
|
||||||
let xsize' = fromIntegral xsize
|
let xsize' = fromIntegral xsize
|
||||||
ysize' = fromIntegral ysize
|
ysize' = fromIntegral ysize
|
||||||
bindFramebuffer Framebuffer $= fboName
|
bindFramebuffer Framebuffer $= fboName
|
||||||
@@ -55,5 +55,10 @@ resizeTextureFBO (fboName,fboTO) xsize ysize = do
|
|||||||
textureFilter Texture2D $= ((Linear',Just Linear') , Nearest)
|
textureFilter Texture2D $= ((Linear',Just Linear') , Nearest)
|
||||||
generateMipmap' Texture2D
|
generateMipmap' Texture2D
|
||||||
framebufferTexture2D Framebuffer (ColorAttachment 0) Texture2D fboTO 0
|
framebufferTexture2D Framebuffer (ColorAttachment 0) Texture2D fboTO 0
|
||||||
|
|
||||||
|
bindRenderbuffer Renderbuffer $= fboRBO
|
||||||
|
renderbufferStorage Renderbuffer Depth24Stencil8 (RenderbufferSize xsize' ysize')
|
||||||
|
framebufferRenderbuffer Framebuffer DepthStencilAttachment Renderbuffer fboRBO
|
||||||
|
|
||||||
fboStatus <- framebufferStatus Framebuffer
|
fboStatus <- framebufferStatus Framebuffer
|
||||||
putStrLn $ "after resize, framebuffer status:" ++ show fboStatus
|
putStrLn $ "after resize, framebuffer status:" ++ show fboStatus
|
||||||
|
|||||||
Reference in New Issue
Block a user