Cleanup
This commit is contained in:
+49
-79
@@ -5,7 +5,6 @@
|
||||
-}
|
||||
module Framebuffer.Update (sizeFBOs) where
|
||||
|
||||
import Geometry.Data
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Preload.Render
|
||||
@@ -14,6 +13,7 @@ import Dodge.WindowSize
|
||||
import Foreign.Marshal.Array
|
||||
import Framebuffer.Check
|
||||
import GLHelp
|
||||
import Geometry.Data
|
||||
import Graphics.GL.Core45
|
||||
import Shader.Data
|
||||
import Unsafe.Coerce
|
||||
@@ -21,21 +21,22 @@ import Unsafe.Coerce
|
||||
sizeFBOs :: Config -> RenderData -> IO RenderData
|
||||
sizeFBOs cfig rdata =
|
||||
uncurryV (resizeRBO (_rboBaseBloom rdata)) (getWindowSize _gr_world_res cfig)
|
||||
>> fboBase (resizeFBOTO3'
|
||||
(getWindowSize _gr_world_res cfig)
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_RGB16F -- RGBAF not sure if the alpha is necessary here
|
||||
GL_RGB16F -- could possibly recover using depth in a clever way
|
||||
-- but probably not, because the projection matrix is
|
||||
-- not always on-center
|
||||
GL_RGBA8_SNORM)
|
||||
>> fboBase
|
||||
( resizeFBOTO3'
|
||||
(getWindowSize _gr_world_res cfig)
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_RGB16F -- RGBAF not sure if the alpha is necessary here
|
||||
GL_RGB16F -- could possibly recover using depth in a clever way
|
||||
-- but probably not, because the projection matrix is
|
||||
-- not always on-center
|
||||
GL_RGBA8_SNORM
|
||||
)
|
||||
rdata
|
||||
>>= flip
|
||||
(
|
||||
updateFBOTO3
|
||||
>>= fboCloud
|
||||
( resizeFBOTO3
|
||||
(getWindowSize _gr_world_res cfig)
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
@@ -43,42 +44,42 @@ sizeFBOs cfig rdata =
|
||||
GL_RGBA16F
|
||||
GL_RGBA16F
|
||||
)
|
||||
fboCloud
|
||||
>>= foldUpdateFBOTO
|
||||
_gr_world_res
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_RGBA8
|
||||
[fboLighting]
|
||||
>>= fboBloom (resizeFBOTO'
|
||||
(getWindowSize _gr_world_res cfig)
|
||||
3
|
||||
GL_LINEAR_MIPMAP_LINEAR
|
||||
GL_LINEAR
|
||||
GL_RGBA16F
|
||||
-- [fboBloom] -- fboPos probably doesn't need the alpha channel
|
||||
>>= fboBloom
|
||||
( resizeFBOTO'
|
||||
(getWindowSize _gr_world_res cfig)
|
||||
5
|
||||
GL_LINEAR_MIPMAP_LINEAR
|
||||
GL_LINEAR
|
||||
GL_RGBA16F
|
||||
-- [fboBloom] -- fboPos probably doesn't need the alpha channel
|
||||
)
|
||||
>>= fboPos
|
||||
( resizeFBOTO
|
||||
(getWindowSize _gr_world_res cfig)
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_RGBA16F -- possibly doesn't need the alpha channel...
|
||||
)
|
||||
>>= foldUpdateFBOTO
|
||||
_gr_world_res
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_RGBA16F
|
||||
[fboPos] -- fboPos probably doesn't need the alpha channel
|
||||
>>= foldUpdateFBOTO
|
||||
_gr_downsize_res
|
||||
GL_LINEAR_MIPMAP_LINEAR
|
||||
GL_LINEAR
|
||||
GL_RGBA16F
|
||||
[fboHalf1, fboHalf2]
|
||||
>>= flip
|
||||
( updateFBOTO2
|
||||
>>= fboWindow
|
||||
( resizeFBOTO2
|
||||
(getWindowSize _gr_world_res cfig)
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_RGBA8
|
||||
GL_RGBA8
|
||||
)
|
||||
fboWindow
|
||||
where
|
||||
updateFBOTO' f = updateFBOTO (getWindowSize f cfig)
|
||||
foldUpdateFBOTO f minfilt magfilt form =
|
||||
@@ -102,49 +103,10 @@ updateFBOTO ::
|
||||
ALens' RenderData (FBO, TO) ->
|
||||
IO RenderData
|
||||
updateFBOTO wsize minfilt magfilt form pdata target = do
|
||||
newfbo2 <- resizeFBOTO (pdata ^# target) wsize minfilt magfilt form
|
||||
return $ storing target newfbo2 pdata
|
||||
|
||||
-- note that the ordering of arguments is different to the other update
|
||||
-- functions... this all needs rethinking
|
||||
updateFBOTO2 ::
|
||||
V2 Int ->
|
||||
-- | minification filter
|
||||
GLenum ->
|
||||
-- | magnification filter
|
||||
GLenum ->
|
||||
-- | internal color format texture1
|
||||
GLenum ->
|
||||
-- | internal color format texture2
|
||||
GLenum ->
|
||||
RenderData ->
|
||||
ALens' RenderData (FBO, (TO, TO)) ->
|
||||
IO RenderData
|
||||
updateFBOTO2 wsize minfilt magfilt form1 form2 pdata target = do
|
||||
newfbo2 <- resizeFBOTO2 (pdata ^# target) wsize minfilt magfilt form1 form2
|
||||
return $ storing target newfbo2 pdata
|
||||
|
||||
updateFBOTO3 ::
|
||||
V2 Int ->
|
||||
-- | minification filter
|
||||
GLenum ->
|
||||
-- | magnification filter
|
||||
GLenum ->
|
||||
-- | internal color format texture1
|
||||
GLenum ->
|
||||
-- | internal color format texture2
|
||||
GLenum ->
|
||||
-- | internal color format texture3
|
||||
GLenum ->
|
||||
RenderData ->
|
||||
ALens' RenderData (FBO, (TO, TO, TO)) ->
|
||||
IO RenderData
|
||||
updateFBOTO3 wsize minfilt magfilt form1 form2 form3 pdata target = do
|
||||
newfbo2 <- resizeFBOTO3 (pdata ^# target) wsize minfilt magfilt form1 form2 form3
|
||||
newfbo2 <- resizeFBOTO wsize minfilt magfilt form (pdata ^# target)
|
||||
return $ storing target newfbo2 pdata
|
||||
|
||||
resizeFBOTO2 ::
|
||||
(FBO, (TO, TO)) ->
|
||||
V2 Int ->
|
||||
-- | minification filter
|
||||
GLenum ->
|
||||
@@ -154,8 +116,9 @@ resizeFBOTO2 ::
|
||||
GLenum ->
|
||||
-- | internal color format2
|
||||
GLenum ->
|
||||
(FBO, (TO, TO)) ->
|
||||
IO (FBO, (TO, TO))
|
||||
resizeFBOTO2 (fbo, (told1, told2)) wsize minfilt magfilt form1 form2 = do
|
||||
resizeFBOTO2 wsize minfilt magfilt form1 form2 (fbo, (told1, told2)) = do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo)
|
||||
mglDelete glDeleteTextures $ _unTO told1
|
||||
mglDelete glDeleteTextures $ _unTO told2
|
||||
@@ -167,7 +130,6 @@ resizeFBOTO2 (fbo, (told1, told2)) wsize minfilt magfilt form1 form2 = do
|
||||
return (fbo, (TO to1, TO to2))
|
||||
|
||||
resizeFBOTO3 ::
|
||||
(FBO, (TO, TO, TO)) ->
|
||||
V2 Int ->
|
||||
-- | minification filter
|
||||
GLenum ->
|
||||
@@ -179,8 +141,9 @@ resizeFBOTO3 ::
|
||||
GLenum ->
|
||||
-- | internal color format3
|
||||
GLenum ->
|
||||
(FBO, (TO, TO, TO)) ->
|
||||
IO (FBO, (TO, TO, TO))
|
||||
resizeFBOTO3 (fbo, (told1, told2, told3)) wsize minfilt magfilt form1 form2 form3 = do
|
||||
resizeFBOTO3 wsize minfilt magfilt form1 form2 form3 (fbo, (told1, told2, told3)) = do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo)
|
||||
mglDelete glDeleteTextures $ _unTO told1
|
||||
mglDelete glDeleteTextures $ _unTO told2
|
||||
@@ -225,7 +188,6 @@ resizeFBOTO3' wsize min1 mag1 minfilt magfilt form1 form2 form3 (fbo, (told1, to
|
||||
return (fbo, (TO to1, TO to2, TO to3))
|
||||
|
||||
resizeFBOTO ::
|
||||
(FBO, TO) ->
|
||||
V2 Int ->
|
||||
-- | minification filter
|
||||
GLenum ->
|
||||
@@ -233,8 +195,9 @@ resizeFBOTO ::
|
||||
GLenum ->
|
||||
-- | internal color format
|
||||
GLenum ->
|
||||
(FBO, TO) ->
|
||||
IO (FBO, TO)
|
||||
resizeFBOTO (fbo, oldto) wsize minfilt magfilt form = do
|
||||
resizeFBOTO wsize minfilt magfilt form (fbo, oldto) = do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo)
|
||||
mglDelete glDeleteTextures $ _unTO oldto
|
||||
to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 wsize 1 minfilt magfilt form
|
||||
@@ -259,8 +222,15 @@ resizeFBOTO' wsize nlevels minfilt magfilt form (fbo, oldto) = do
|
||||
checkFBO fbo
|
||||
return (fbo, TO to1)
|
||||
|
||||
initializeTexture2D :: FBO -> GLenum -> V2 Int -> Int
|
||||
-> GLenum -> GLenum -> GLenum -> IO GLuint
|
||||
initializeTexture2D ::
|
||||
FBO ->
|
||||
GLenum ->
|
||||
V2 Int ->
|
||||
Int ->
|
||||
GLenum ->
|
||||
GLenum ->
|
||||
GLenum ->
|
||||
IO GLuint
|
||||
initializeTexture2D fbo attachpoint (V2 x y) nlevels minfilt magfilt form = do
|
||||
let xsize' = fromIntegral x
|
||||
ysize' = fromIntegral y
|
||||
|
||||
Reference in New Issue
Block a user