This commit is contained in:
2025-11-09 11:31:29 +00:00
parent e9ffeeaea7
commit e20cc593fc
4 changed files with 34 additions and 38 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
module Dodge.PrWdLsLs where module Dodge.PrWdLsLs (doPrWdLsLs) where
import Control.Lens import Control.Lens
import Dodge.Data.World import Dodge.Data.World
+2 -2
View File
@@ -12,5 +12,5 @@ createWall wl w =
& insertWallInZones newwl & insertWallInZones newwl
) )
where where
newwl = wl{_wlID = wlid} newwl = wl & wlID .~ wlid
wlid = IM.newKey $ w ^. cWorld . lWorld . walls --_walls (_cWorld w) wlid = IM.newKey $ w ^. cWorld . lWorld . walls
+1 -1
View File
@@ -1,4 +1,4 @@
module Framebuffer.Check where module Framebuffer.Check (checkFBO) where
import Shader.Data import Shader.Data
import Graphics.GL.Core45 import Graphics.GL.Core45
+30 -34
View File
@@ -56,17 +56,17 @@ sizeFBOs cfig rdata =
GL_LINEAR GL_LINEAR
GL_RGBA16F GL_RGBA16F
[fboHalf1, fboHalf2] [fboHalf1, fboHalf2]
>>= uncurry updateFBOTO2 >>= flip (uncurry updateFBOTO2
(getWindowSize _gr_world_res cfig) (getWindowSize _gr_world_res cfig)
GL_NEAREST GL_NEAREST
GL_NEAREST GL_NEAREST
GL_RGBA8 GL_RGBA8
GL_RGBA16F GL_RGBA16F)
fboWindow fboWindow
where where
updateFBOTO' f = uncurry updateFBOTO (getWindowSize f cfig) updateFBOTO' f = uncurry updateFBOTO (getWindowSize f cfig)
foldUpdateFBOTO f minfilt magfilt format = foldUpdateFBOTO f minfilt magfilt form =
ffoldM ( updateFBOTO' f minfilt magfilt format) ffoldM (updateFBOTO' f minfilt magfilt form)
ffoldM :: (Foldable t, Monad m) => (a1 -> a2 -> m a1) -> t a2 -> a1 -> m a1 ffoldM :: (Foldable t, Monad m) => (a1 -> a2 -> m a1) -> t a2 -> a1 -> m a1
ffoldM f = flip $ foldM f ffoldM f = flip $ foldM f
@@ -86,8 +86,8 @@ updateFBOTO ::
RenderData -> RenderData ->
ALens' RenderData (FBO, TO) -> ALens' RenderData (FBO, TO) ->
IO RenderData IO RenderData
updateFBOTO xsize ysize minfilt magfilt inFormat pdata target = do updateFBOTO xsize ysize minfilt magfilt form pdata target = do
newfbo2 <- resizeFBOTO (pdata ^# target) xsize ysize minfilt magfilt inFormat newfbo2 <- resizeFBOTO (pdata ^# target) xsize ysize minfilt magfilt form
return $ storing target newfbo2 pdata return $ storing target newfbo2 pdata
-- note that the ordering of arguments is different to the other update -- note that the ordering of arguments is different to the other update
@@ -103,11 +103,11 @@ updateFBOTO2 ::
GLenum -> GLenum ->
-- | internal color format texture2 -- | internal color format texture2
GLenum -> GLenum ->
ALens' RenderData (FBO, (TO, TO)) ->
RenderData -> RenderData ->
ALens' RenderData (FBO, (TO, TO)) ->
IO RenderData IO RenderData
updateFBOTO2 xsize ysize minfilt magfilt inFormat1 inFormat2 target pdata = do updateFBOTO2 xsize ysize minfilt magfilt form1 form2 pdata target = do
newfbo2 <- resizeFBOTO2 (pdata ^# target) xsize ysize minfilt magfilt inFormat1 inFormat2 newfbo2 <- resizeFBOTO2 (pdata ^# target) xsize ysize minfilt magfilt form1 form2
return $ storing target newfbo2 pdata return $ storing target newfbo2 pdata
updateFBOTO3 :: updateFBOTO3 ::
@@ -126,8 +126,8 @@ updateFBOTO3 ::
RenderData -> RenderData ->
ALens' RenderData (FBO, (TO, TO, TO)) -> ALens' RenderData (FBO, (TO, TO, TO)) ->
IO RenderData IO RenderData
updateFBOTO3 xsize ysize minfilt magfilt inFormat1 inFormat2 inFormat3 pdata target = do updateFBOTO3 xsize ysize minfilt magfilt form1 form2 form3 pdata target = do
newfbo2 <- resizeFBOTO3 (pdata ^# target) xsize ysize minfilt magfilt inFormat1 inFormat2 inFormat3 newfbo2 <- resizeFBOTO3 (pdata ^# target) xsize ysize minfilt magfilt form1 form2 form3
return $ storing target newfbo2 pdata return $ storing target newfbo2 pdata
resizeFBOTO2 :: resizeFBOTO2 ::
@@ -143,14 +143,14 @@ resizeFBOTO2 ::
-- | internal color format2 -- | internal color format2
GLenum -> GLenum ->
IO (FBO, (TO, TO)) IO (FBO, (TO, TO))
resizeFBOTO2 (fbo, (toOld1, toOld2)) xsize ysize minfilt magfilt inFormat1 inFormat2 = do resizeFBOTO2 (fbo, (told1, told2)) xsize ysize minfilt magfilt form1 form2 = do
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo) glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo)
mglDelete glDeleteTextures $ _unTO toOld1 mglDelete glDeleteTextures $ _unTO told1
mglDelete glDeleteTextures $ _unTO toOld2 mglDelete glDeleteTextures $ _unTO told2
to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt inFormat1 to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt form1
to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt inFormat2 to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt form2
withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1] $ \ptr -> withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1] $
glNamedFramebufferDrawBuffers (_unFBO fbo) 2 ptr glNamedFramebufferDrawBuffers (_unFBO fbo) 2
checkFBO fbo checkFBO fbo
return (fbo, (TO to1, TO to2)) return (fbo, (TO to1, TO to2))
@@ -169,14 +169,14 @@ resizeFBOTO3 ::
-- | internal color format3 -- | internal color format3
GLenum -> GLenum ->
IO (FBO, (TO, TO, TO)) IO (FBO, (TO, TO, TO))
resizeFBOTO3 (fbo, (toOld1, toOld2, told3)) xsize ysize minfilt magfilt inFormat1 inFormat2 inform3 = do resizeFBOTO3 (fbo, (told1, told2, told3)) xsize ysize minfilt magfilt form1 form2 form3 = do
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo) glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo)
mglDelete glDeleteTextures $ _unTO toOld1 mglDelete glDeleteTextures $ _unTO told1
mglDelete glDeleteTextures $ _unTO toOld2 mglDelete glDeleteTextures $ _unTO told2
mglDelete glDeleteTextures $ _unTO told3 mglDelete glDeleteTextures $ _unTO told3
to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt inFormat1 to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt form1
to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt inFormat2 to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt form2
to3 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT2 xsize ysize minfilt magfilt inform3 to3 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT2 xsize ysize minfilt magfilt form3
withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $ \ptr -> withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $ \ptr ->
glNamedFramebufferDrawBuffers (_unFBO fbo) 3 ptr glNamedFramebufferDrawBuffers (_unFBO fbo) 3 ptr
checkFBO fbo checkFBO fbo
@@ -193,25 +193,21 @@ resizeFBOTO ::
-- | internal color format -- | internal color format
GLenum -> GLenum ->
IO (FBO, TO) IO (FBO, TO)
resizeFBOTO (fbo, oldto) xsize ysize minfilt magfilt inFormat = do resizeFBOTO (fbo, oldto) xsize ysize minfilt magfilt form = do
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo) glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo)
mglDelete glDeleteTextures $ _unTO oldto mglDelete glDeleteTextures $ _unTO oldto
to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt inFormat to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt form
checkFBO fbo checkFBO fbo
return (fbo, TO to1) return (fbo, TO to1)
initializeTexture2D :: FBO -> GLenum -> Int -> Int -> GLenum -> GLenum -> GLenum -> IO GLuint initializeTexture2D
initializeTexture2D fbo attachpoint x y minfilt magfilt informat = do :: FBO -> GLenum -> Int -> Int -> GLenum -> GLenum -> GLenum -> IO GLuint
initializeTexture2D fbo attachpoint x y minfilt magfilt form = do
let xsize' = fromIntegral x let xsize' = fromIntegral x
ysize' = fromIntegral y ysize' = fromIntegral y
to1 <- mglCreate (glCreateTextures GL_TEXTURE_2D) to1 <- mglCreate (glCreateTextures GL_TEXTURE_2D)
glTextureStorage2D to1 1 informat xsize' ysize' glTextureStorage2D to1 1 form xsize' ysize'
glTextureParameteri to1 GL_TEXTURE_MIN_FILTER (unsafeCoerce minfilt) glTextureParameteri to1 GL_TEXTURE_MIN_FILTER (unsafeCoerce minfilt)
glTextureParameteri to1 GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt) glTextureParameteri to1 GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt)
glNamedFramebufferTexture (_unFBO fbo) attachpoint to1 0 glNamedFramebufferTexture (_unFBO fbo) attachpoint to1 0
return to1 return to1
--getWindowSize :: Integral a => (Config -> ResFactor) -> Config -> (a, a)
--getWindowSize f cfig = (g _windowX, g _windowY)
-- where
-- g h = fromIntegral $ h cfig `div` resFactorNum (f cfig)