Refactor framebuffer update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
-- | For initialising framebuffers.
|
||||
module Framebuffer.Setup (
|
||||
setupTextureFramebuffer,
|
||||
newTextureFramebuffer,
|
||||
setupFramebufferGivenStencil,
|
||||
setupFramebuffer2GivenStencil,
|
||||
setupFramebuffer3GivenStencil,
|
||||
@@ -9,41 +9,23 @@ module Framebuffer.Setup (
|
||||
|
||||
import Shader.Data
|
||||
import Framebuffer.Check
|
||||
import Unsafe.Coerce
|
||||
import GLHelp
|
||||
import Graphics.GL.Core45
|
||||
|
||||
setupTextureFramebuffer ::
|
||||
GLsizei ->
|
||||
GLsizei ->
|
||||
IO (FBO, TO)
|
||||
{-# INLINE setupTextureFramebuffer #-}
|
||||
setupTextureFramebuffer x y = do
|
||||
--fboName <- genObjectName
|
||||
--bindFramebuffer Framebuffer $= fboName
|
||||
-- the framebuffer is not complete after this
|
||||
newTextureFramebuffer :: IO (FBO, TO)
|
||||
{-# INLINE newTextureFramebuffer #-}
|
||||
newTextureFramebuffer = do
|
||||
fboName <- mglCreate glCreateFramebuffers
|
||||
--fboTO <- genObjectName
|
||||
to <- mglCreate (glCreateTextures GL_TEXTURE_2D)
|
||||
--textureBinding Texture2D $= Just fboTO
|
||||
--glTexStorage2D GL_TEXTURE_2D 1 GL_RGBA8 x y
|
||||
glTextureStorage2D to 1 GL_RGBA8 x y
|
||||
glTextureParameteri to GL_TEXTURE_MIN_FILTER (unsafeCoerce GL_NEAREST)
|
||||
glTextureParameteri to GL_TEXTURE_MAG_FILTER (unsafeCoerce GL_NEAREST)
|
||||
--textureFilter Texture2D $= minMagFilter
|
||||
--framebufferTexture2D Framebuffer (ColorAttachment 0) Texture2D fboTO 0
|
||||
glNamedFramebufferTexture fboName GL_COLOR_ATTACHMENT0 to 0
|
||||
checkFBO $ FBO fboName
|
||||
return (FBO fboName, TO to)
|
||||
|
||||
-- the framebuffer is not complete after this
|
||||
setupShadowFramebuffer :: IO (FBO, (TO, TO))
|
||||
setupShadowFramebuffer = do
|
||||
--fboName <- genObjectName
|
||||
--bindFramebuffer Framebuffer $= fboName
|
||||
fboName <- mglCreate glCreateFramebuffers
|
||||
to1 <- mglCreate (glCreateTextures GL_TEXTURE_2D_ARRAY)
|
||||
to2 <- mglCreate (glCreateTextures GL_TEXTURE_2D_ARRAY)
|
||||
--textureBinding Texture2DArray $= Just toName
|
||||
--framebufferRenderbuffer Framebuffer DepthStencilAttachment Renderbuffer rboName
|
||||
return (FBO fboName, (TO to1,TO to2))
|
||||
|
||||
setupFramebufferGivenStencil ::
|
||||
|
||||
@@ -46,9 +46,7 @@ sizeFBOs cfig rdata = do
|
||||
(uncurry updateFBOTO (getWindowSize _graphics_downsize_resolution cfig) GL_LINEAR_MIPMAP_LINEAR GL_LINEAR GL_RGBA16F)
|
||||
rdata'''
|
||||
[fboHalf1, fboHalf2, fboHalf3]
|
||||
newShadowFBO <- uncurry (resizeShadowFBO (rdata ^. fboShadow))
|
||||
(getWindowSize _graphics_world_resolution cfig)
|
||||
return $ rdata4 & fboShadow .~ newShadowFBO
|
||||
resizeShadowFBO' cfig rdata4
|
||||
|
||||
resizeRBO ::
|
||||
GLuint -> -- RenderbufferObject
|
||||
@@ -113,13 +111,16 @@ updateFBOTO3 xsize ysize minfilt magfilt inFormat1 inFormat2 inFormat3 pdata tar
|
||||
newfbo2 <- resizeFBOTO3 (pdata ^# target) xsize ysize minfilt magfilt inFormat1 inFormat2 inFormat3
|
||||
return $ storing target newfbo2 pdata
|
||||
|
||||
resizeShadowFBO' :: Configuration -> RenderData -> IO RenderData
|
||||
resizeShadowFBO' cfig = fboShadow (uncurry resizeShadowFBO (getWindowSize _graphics_world_resolution cfig))
|
||||
|
||||
-- note we only really "change" the texture objects
|
||||
resizeShadowFBO ::
|
||||
Int ->
|
||||
Int ->
|
||||
(FBO, (TO, TO)) ->
|
||||
Int ->
|
||||
Int ->
|
||||
IO (FBO, (TO, TO))
|
||||
resizeShadowFBO (fbo, (oldto1, oldto2)) x y = do
|
||||
resizeShadowFBO x y (fbo, (oldto1, oldto2)) = do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo)
|
||||
mglDelete glDeleteTextures $ _unTO oldto1
|
||||
mglDelete glDeleteTextures $ _unTO oldto2
|
||||
|
||||
Reference in New Issue
Block a user