Commit before implementing downscaled resolution

This commit is contained in:
jgk
2021-08-19 19:50:44 +02:00
parent bc236671f2
commit 8e3bf3b19f
7 changed files with 15 additions and 124 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ import Dodge.Data.SoundOrigin
import Dodge.Config.Data
import Sound
import Data.Preload
import Preload.Update
import Framebuffer.Update
import Data.Aeson (encodeFile)
--import Control.Monad (when)
+1 -1
View File
@@ -23,7 +23,7 @@ import Dodge.SoundLogic
import Dodge.Inventory
import Dodge.Config.Data
--import Geometry
import Preload.Update
import Framebuffer.Update
import qualified IntMapHelp as IM
import Control.Lens
+1 -1
View File
@@ -10,7 +10,7 @@ import Dodge.SoundLogic
import Dodge.Config.Data
import Dodge.Config.Update
import Dodge.Layout
import Preload.Update
import Framebuffer.Update
import Dodge.Debug.Terminal
import Data.Maybe
+1 -1
View File
@@ -115,7 +115,7 @@ doDrawing pdata w = do
colorMask $= Color4 Enabled Enabled Enabled Enabled
clearColor $= Color4 0 0 0 0
blend $= Disabled
--blend $= Disabled
depthMask $= Disabled
depthFunc $= Just Always
+4 -46
View File
@@ -11,10 +11,11 @@ import Shader.Compile
import Shader.AuxAddition
import Shader.Parameters
import Shader.Bind
import Framebuffer.Setup
import Data.Preload.Render
import Graphics.Rendering.OpenGL hiding (Point,translate,scale,imageHeight)
import Graphics.GL.Core43
--import Graphics.GL.Core43
--import Control.Lens
import Control.Monad
import Foreign
@@ -100,7 +101,7 @@ preloadRender = do
rboLightingName <- genObjectName
bindRenderbuffer Renderbuffer $= rboLightingName
renderbufferStorage Renderbuffer Depth24Stencil8 (RenderbufferSize 800 600)
fboLightingName <- newFramebufferGivenStencilAlpha rboLightingName
fboLightingName <- newFramebufferGivenStencil rboLightingName
rboBaseBloomName <- genObjectName
bindRenderbuffer Renderbuffer $= rboBaseBloomName
@@ -156,6 +157,7 @@ preloadRender = do
, _rboBaseBloom = rboBaseBloomName
, _matUBO = theUBO
}
--------------------end preloadRender
cornerList :: [[Float]]
cornerList =
[[-1, 1,0,1]
@@ -170,51 +172,7 @@ cornerListNoCoord =
,[-1,-1]
,[ 1,-1]
]
--------------------end preloadRender
newFramebufferGivenStencil
:: RenderbufferObject
-> IO (FramebufferObject, TextureObject)
newFramebufferGivenStencil rboName = do
fboName <- genObjectName
bindFramebuffer Framebuffer $= fboName
toName <- genObjectName
framebufferRenderbuffer Framebuffer DepthStencilAttachment Renderbuffer rboName
fboStatus <- framebufferStatus Framebuffer
print fboStatus
return (fboName,toName)
newFramebufferGivenStencilAlpha
:: RenderbufferObject
-> IO (FramebufferObject, TextureObject)
newFramebufferGivenStencilAlpha rboName = do
fboName <- genObjectName
bindFramebuffer Framebuffer $= fboName
toName <- genObjectName
framebufferRenderbuffer Framebuffer DepthStencilAttachment Renderbuffer rboName
fboStatus <- framebufferStatus Framebuffer
print fboStatus
return (fboName,toName)
setupTextureFramebuffer
:: GLsizei
-> GLsizei
-> IO (FramebufferObject, TextureObject)
setupTextureFramebuffer x y = do
fboName <- genObjectName
bindFramebuffer Framebuffer $= fboName
fboTO <- genObjectName
textureBinding Texture2D $= Just fboTO
glTexStorage2D GL_TEXTURE_2D 1 GL_RGBA8 x y
textureFilter Texture2D $= minMagFilter
framebufferTexture2D Framebuffer (ColorAttachment 0) Texture2D fboTO 0
fboStatus <- framebufferStatus Framebuffer
print fboStatus
return (fboName, fboTO)
minMagFilter :: ((TextureFilter, Maybe TextureFilter),TextureFilter)
minMagFilter = ((Nearest,Nothing),Nearest)
cleanUpRenderPreload :: RenderData -> IO ()
cleanUpRenderPreload pd = do
-71
View File
@@ -1,71 +0,0 @@
{-# LANGUAGE NoMonomorphismRestriction #-}
module Preload.Update
( sizeFBOs
)
where
import Data.Preload
import Data.Preload.Render
import Graphics.Rendering.OpenGL
import Graphics.GL.Core43
--import Foreign
import Control.Lens
import Control.Monad
sizeFBOs
:: Int -- ^ Lightmap width
-> Int -- ^ Lightmap height
-> Int -- ^ Full width
-> Int -- ^ Full height
-> PreloadData a
-> IO (PreloadData a)
sizeFBOs xsize ysize xfull yfull pdata = do
let rdata = _renderData pdata
resizeRBO (_rboBaseBloom rdata) xfull yfull
resizeRBO (_rboLighting rdata) xsize ysize
pdata' <- foldM (updateFBOTO xfull yfull) pdata [fbo2, fbo3, fboBase, fboBloom, fboColor]
updateFBOTO xsize ysize pdata' fboLighting
resizeRBO
:: RenderbufferObject
-> Int
-> Int
-> IO ()
resizeRBO rboName xsize ysize = do
let xsize' = fromIntegral xsize
ysize' = fromIntegral ysize
bindRenderbuffer Renderbuffer $= rboName
renderbufferStorage Renderbuffer Depth24Stencil8 (RenderbufferSize xsize' ysize')
updateFBOTO
:: Int
-> Int
-> PreloadData a
-> ALens' RenderData (FramebufferObject, TextureObject)
-> IO (PreloadData a)
updateFBOTO xsize ysize pdata target = do
newfbo2 <- resizeFBOTO (pdata ^# renderData . target) xsize ysize
return $ storing (renderData . target) newfbo2 pdata
resizeFBOTO
:: (FramebufferObject , TextureObject)
-> Int
-> Int
-> IO (FramebufferObject, TextureObject)
resizeFBOTO (fboName,toOld) xsize ysize = do
bindFramebuffer Framebuffer $= fboName
let xsize' = fromIntegral xsize
ysize' = fromIntegral ysize
deleteObjectName toOld
toName <- genObjectName
textureBinding Texture2D $= Just toName
glTexStorage2D GL_TEXTURE_2D 1 GL_RGBA8 xsize' ysize'
textureFilter Texture2D $= minMagFilter
framebufferTexture2D Framebuffer (ColorAttachment 0) Texture2D toName 0
fboStatus <- framebufferStatus Framebuffer
putStrLn $ "after resize, framebuffer status:" ++ show fboStatus
return (fboName, toName)
minMagFilter :: ((TextureFilter, Maybe TextureFilter),TextureFilter)
minMagFilter = ((Nearest,Nothing),Nearest)
+7 -3
View File
@@ -38,12 +38,16 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
clear [ColorBuffer,DepthBuffer]
--colorMask $= Color4 Disabled Disabled Disabled Disabled
cullFace $= Just Back
-- draw walls from your point of view in order to set z buffer
-- draw wall surfaces from your point of view in order to set z buffer
drawShader (_lightingWallShader pdata) nWalls
-- draw foreground elements to set z buffer
-- draw foreground elements from your point of view to set z buffer
drawShader (_lightingSurfaceShader pdata) nsurfVs
-- draw wall occlusions from your point of view
drawShader (_lightingOccludeShader pdata) nWalls
--hypothesis: the above three draw calls only work because the
--uniform was set to your position, that being the last light source in the list
--if this hypothesis is correct, then the code is brittle and should be changed
-- for each of the lights:
-- stencil out the walls from this light's point of view
-- draw fading lightmap circles on the floor