Remove glTexImage

This commit is contained in:
jgk
2021-07-18 21:31:50 +02:00
parent 9407c7af2a
commit 595cb6e9a8
6 changed files with 39 additions and 88 deletions
+11 -35
View File
@@ -1,6 +1,6 @@
{-# LANGUAGE NoMonomorphismRestriction #-}
module Preload.Update
( resizeSpareFBO
( sizeFBOs
)
where
import Data.Preload
@@ -8,32 +8,23 @@ import Data.Preload.Render
import Graphics.Rendering.OpenGL
import Graphics.GL.Core43
import Foreign
--import Foreign
import Control.Lens
import Control.Monad
resizeSpareFBO
sizeFBOs
:: Int -- ^ Lightmap width
-> Int -- ^ Lightmap height
-> Int -- ^ Full width
-> Int -- ^ Full height
-> PreloadData a
-> IO (PreloadData a)
resizeSpareFBO xsize ysize xfull yfull pdata = do
-- I am unsure how much of this needs to be bound...
sizeFBOs xsize ysize xfull yfull pdata = do
let rdata = _renderData pdata
--resizeFBOTO (_fbo3 rdata) xfull yfull
resizeRBO (_rboBaseBloom rdata) xfull yfull
--resizeFBOTO (_fboBase rdata) xfull yfull
--resizeFBOTO (_fboBloom rdata) xfull yfull
--resizeFBOTO (_fboColor rdata) xfull yfull
resizeRBO (_rboLighting rdata) xsize ysize
--resizeFBOTO (_fboLighting rdata) xsize ysize
pdata' <- foldM (resizeFBOTO'' xfull yfull) pdata [fbo2, fbo3, fboBase, fboBloom, fboColor]
resizeFBOTO'' xsize ysize pdata' fboLighting
--foldM (resizeFBOTO'' xsize ysize) pdata [fbo2, fbo3, fboBase, fboBloom, fboColor]
--resizeFBOTO (_fboLighting rdata) xsize ysize
--return $ pdata & renderData . fbo2 .~ newfbo2
pdata' <- foldM (updateFBOTO xfull yfull) pdata [fbo2, fbo3, fboBase, fboBloom, fboColor]
updateFBOTO xsize ysize pdata' fboLighting
resizeRBO
:: RenderbufferObject
@@ -46,22 +37,22 @@ resizeRBO rboName xsize ysize = do
bindRenderbuffer Renderbuffer $= rboName
renderbufferStorage Renderbuffer Depth24Stencil8 (RenderbufferSize xsize' ysize')
resizeFBOTO''
updateFBOTO
:: Int
-> Int
-> PreloadData a
-> ALens' RenderData (FramebufferObject, TextureObject)
-> IO (PreloadData a)
resizeFBOTO'' xsize ysize pdata target = do
newfbo2 <- resizeFBOTO' (pdata ^# renderData . target) xsize ysize
updateFBOTO xsize ysize pdata target = do
newfbo2 <- resizeFBOTO (pdata ^# renderData . target) xsize ysize
return $ storing (renderData . target) newfbo2 pdata
resizeFBOTO'
resizeFBOTO
:: (FramebufferObject , TextureObject)
-> Int
-> Int
-> IO (FramebufferObject, TextureObject)
resizeFBOTO' (fboName,toOld) xsize ysize = do
resizeFBOTO (fboName,toOld) xsize ysize = do
bindFramebuffer Framebuffer $= fboName
let xsize' = fromIntegral xsize
ysize' = fromIntegral ysize
@@ -78,18 +69,3 @@ resizeFBOTO' (fboName,toOld) xsize ysize = do
minMagFilter :: ((TextureFilter, Maybe TextureFilter),TextureFilter)
minMagFilter = ((Nearest,Nothing),Nearest)
resizeFBOTO
:: (FramebufferObject , TextureObject)
-> Int
-> Int
-> IO ()
resizeFBOTO (fboName,fboTO) xsize ysize = do
let xsize' = fromIntegral xsize
ysize' = fromIntegral ysize
bindFramebuffer Framebuffer $= fboName
textureBinding Texture2D $= Just fboTO
texImage2D Texture2D NoProxy 0 RGBA8 (TextureSize2D xsize' ysize') 0 (PixelData RGBA UnsignedByte nullPtr)
framebufferTexture2D Framebuffer (ColorAttachment 0) Texture2D fboTO 0
fboStatus <- framebufferStatus Framebuffer
putStrLn $ "after resize, framebuffer status:" ++ show fboStatus