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 ::
|
||||
|
||||
Reference in New Issue
Block a user