Cleanup
This commit is contained in:
+30
-34
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user