From e20cc593fc7573138f34a52c3d1e1fd255485cae Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 9 Nov 2025 11:31:29 +0000 Subject: [PATCH] Cleanup --- src/Dodge/PrWdLsLs.hs | 2 +- src/Dodge/Wall/Create.hs | 4 +-- src/Framebuffer/Check.hs | 2 +- src/Framebuffer/Update.hs | 64 ++++++++++++++++++--------------------- 4 files changed, 34 insertions(+), 38 deletions(-) diff --git a/src/Dodge/PrWdLsLs.hs b/src/Dodge/PrWdLsLs.hs index 8bebd94f8..f4958eb48 100644 --- a/src/Dodge/PrWdLsLs.hs +++ b/src/Dodge/PrWdLsLs.hs @@ -1,4 +1,4 @@ -module Dodge.PrWdLsLs where +module Dodge.PrWdLsLs (doPrWdLsLs) where import Control.Lens import Dodge.Data.World diff --git a/src/Dodge/Wall/Create.hs b/src/Dodge/Wall/Create.hs index ae97cef93..5a2640383 100644 --- a/src/Dodge/Wall/Create.hs +++ b/src/Dodge/Wall/Create.hs @@ -12,5 +12,5 @@ createWall wl w = & insertWallInZones newwl ) where - newwl = wl{_wlID = wlid} - wlid = IM.newKey $ w ^. cWorld . lWorld . walls --_walls (_cWorld w) + newwl = wl & wlID .~ wlid + wlid = IM.newKey $ w ^. cWorld . lWorld . walls diff --git a/src/Framebuffer/Check.hs b/src/Framebuffer/Check.hs index 4d3ec3655..3558365f4 100644 --- a/src/Framebuffer/Check.hs +++ b/src/Framebuffer/Check.hs @@ -1,4 +1,4 @@ -module Framebuffer.Check where +module Framebuffer.Check (checkFBO) where import Shader.Data import Graphics.GL.Core45 diff --git a/src/Framebuffer/Update.hs b/src/Framebuffer/Update.hs index 63ae6ce4b..311e265b1 100644 --- a/src/Framebuffer/Update.hs +++ b/src/Framebuffer/Update.hs @@ -56,17 +56,17 @@ sizeFBOs cfig rdata = GL_LINEAR GL_RGBA16F [fboHalf1, fboHalf2] - >>= uncurry updateFBOTO2 + >>= flip (uncurry updateFBOTO2 (getWindowSize _gr_world_res cfig) GL_NEAREST GL_NEAREST GL_RGBA8 - GL_RGBA16F + GL_RGBA16F) fboWindow where updateFBOTO' f = uncurry updateFBOTO (getWindowSize f cfig) - foldUpdateFBOTO f minfilt magfilt format = - ffoldM ( updateFBOTO' f minfilt magfilt format) + foldUpdateFBOTO f minfilt magfilt form = + ffoldM (updateFBOTO' f minfilt magfilt form) ffoldM :: (Foldable t, Monad m) => (a1 -> a2 -> m a1) -> t a2 -> a1 -> m a1 ffoldM f = flip $ foldM f @@ -86,8 +86,8 @@ updateFBOTO :: RenderData -> ALens' RenderData (FBO, TO) -> IO RenderData -updateFBOTO xsize ysize minfilt magfilt inFormat pdata target = do - newfbo2 <- resizeFBOTO (pdata ^# target) xsize ysize minfilt magfilt inFormat +updateFBOTO xsize ysize minfilt magfilt form pdata target = do + newfbo2 <- resizeFBOTO (pdata ^# target) xsize ysize minfilt magfilt form return $ storing target newfbo2 pdata -- note that the ordering of arguments is different to the other update @@ -103,11 +103,11 @@ updateFBOTO2 :: GLenum -> -- | internal color format texture2 GLenum -> - ALens' RenderData (FBO, (TO, TO)) -> RenderData -> + ALens' RenderData (FBO, (TO, TO)) -> IO RenderData -updateFBOTO2 xsize ysize minfilt magfilt inFormat1 inFormat2 target pdata = do - newfbo2 <- resizeFBOTO2 (pdata ^# target) xsize ysize minfilt magfilt inFormat1 inFormat2 +updateFBOTO2 xsize ysize minfilt magfilt form1 form2 pdata target = do + newfbo2 <- resizeFBOTO2 (pdata ^# target) xsize ysize minfilt magfilt form1 form2 return $ storing target newfbo2 pdata updateFBOTO3 :: @@ -126,8 +126,8 @@ updateFBOTO3 :: RenderData -> ALens' RenderData (FBO, (TO, TO, TO)) -> IO RenderData -updateFBOTO3 xsize ysize minfilt magfilt inFormat1 inFormat2 inFormat3 pdata target = do - newfbo2 <- resizeFBOTO3 (pdata ^# target) xsize ysize minfilt magfilt inFormat1 inFormat2 inFormat3 +updateFBOTO3 xsize ysize minfilt magfilt form1 form2 form3 pdata target = do + newfbo2 <- resizeFBOTO3 (pdata ^# target) xsize ysize minfilt magfilt form1 form2 form3 return $ storing target newfbo2 pdata resizeFBOTO2 :: @@ -143,14 +143,14 @@ resizeFBOTO2 :: -- | internal color format2 GLenum -> 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) - mglDelete glDeleteTextures $ _unTO toOld1 - mglDelete glDeleteTextures $ _unTO toOld2 - to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt inFormat1 - to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt inFormat2 - withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1] $ \ptr -> - glNamedFramebufferDrawBuffers (_unFBO fbo) 2 ptr + mglDelete glDeleteTextures $ _unTO told1 + mglDelete glDeleteTextures $ _unTO told2 + to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt form1 + to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt form2 + withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1] $ + glNamedFramebufferDrawBuffers (_unFBO fbo) 2 checkFBO fbo return (fbo, (TO to1, TO to2)) @@ -169,14 +169,14 @@ resizeFBOTO3 :: -- | internal color format3 GLenum -> 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) - mglDelete glDeleteTextures $ _unTO toOld1 - mglDelete glDeleteTextures $ _unTO toOld2 + mglDelete glDeleteTextures $ _unTO told1 + mglDelete glDeleteTextures $ _unTO told2 mglDelete glDeleteTextures $ _unTO told3 - to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt inFormat1 - to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt inFormat2 - to3 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT2 xsize ysize minfilt magfilt inform3 + to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt form1 + to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt form2 + to3 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT2 xsize ysize minfilt magfilt form3 withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $ \ptr -> glNamedFramebufferDrawBuffers (_unFBO fbo) 3 ptr checkFBO fbo @@ -193,25 +193,21 @@ resizeFBOTO :: -- | internal color format GLenum -> 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) 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 return (fbo, TO to1) -initializeTexture2D :: FBO -> GLenum -> Int -> Int -> GLenum -> GLenum -> GLenum -> IO GLuint -initializeTexture2D fbo attachpoint x y minfilt magfilt informat = do +initializeTexture2D + :: FBO -> GLenum -> Int -> Int -> GLenum -> GLenum -> GLenum -> IO GLuint +initializeTexture2D fbo attachpoint x y minfilt magfilt form = do let xsize' = fromIntegral x ysize' = fromIntegral y 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_MAG_FILTER (unsafeCoerce magfilt) glNamedFramebufferTexture (_unFBO fbo) attachpoint to1 0 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)