This commit is contained in:
2023-03-24 12:06:54 +00:00
parent d524a14da4
commit bd9f32875e
7 changed files with 21 additions and 36 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

+8 -9
View File
@@ -1,17 +1,16 @@
{-# LANGUAGE TemplateHaskell #-}
module Data.Preload
where
import Data.Preload.Render
import Sound.Data
import Music
module Data.Preload where
import Control.Lens
import Data.Preload.Render
import Music
import Sound.Data
data PreloadData = PreloadData
{ _renderData :: RenderData
, _soundData :: SoundData
, _musicData :: MusicData
{ _renderData :: RenderData
, _soundData :: SoundData
, _musicData :: MusicData
}
| DummyPdata
makeLenses ''PreloadData
+1 -1
View File
@@ -48,4 +48,4 @@ applyWorldConfig ::
IO PreloadData
applyWorldConfig cfig pdata = do
setVol cfig
renderData (pdataResizeUpdate cfig) pdata
renderData (renderDataResizeUpdate cfig) pdata
+1 -5
View File
@@ -6,6 +6,7 @@ module Dodge.Render (
--import qualified Data.Vector as V
import Dodge.WindowSize
import Control.Lens
import Control.Monad
import qualified Control.Monad.Parallel as MP
@@ -374,10 +375,5 @@ getDistortions cfig w
setViewportSize :: Int -> Int -> IO ()
setViewportSize x y = glViewport 0 0 (fromIntegral x) (fromIntegral y)
getWindowSize :: Integral a => (Configuration -> ResFactor) -> Configuration -> (a,a)
getWindowSize f cfig = (g _windowX,g _windowY)
where
g h = fromIntegral $ round (h cfig) `div` resFactorNum (f cfig)
setViewportType :: (Configuration -> ResFactor) -> Configuration -> IO ()
setViewportType f = uncurry (glViewport 0 0) . getWindowSize f
+3 -5
View File
@@ -2,9 +2,7 @@ module Dodge.WindowSize where
import Dodge.Data.Config
getWindowSize :: Configuration -> (Int, Int)
getWindowSize cfig = (x `div` divRes,y `div` divRes)
getWindowSize :: Integral a => (Configuration -> ResFactor) -> Configuration -> (a,a)
getWindowSize f cfig = (g _windowX,g _windowY)
where
x = round $ _windowX cfig
y = round $ _windowY cfig
divRes = resFactorNum $ _graphics_world_resolution cfig
g h = fromIntegral $ round (h cfig) `div` resFactorNum (f cfig)
+5 -13
View File
@@ -2,9 +2,10 @@
module Preload.Update (
updatePreload,
pdataResizeUpdate,
renderDataResizeUpdate,
) where
import Dodge.WindowSize
import Dodge.Data.Universe
import Control.Lens
import qualified Data.ByteString as BS
@@ -14,16 +15,13 @@ import Framebuffer.Update
import Shader.Compile
import Shader.Data
-- i don't like this being here pulling in the dodge universe dependency, but
-- splitting it out would be overkill
updatePreload :: Universe -> IO Universe
updatePreload u = do
pdata <- pdataResizeUpdate (u ^. uvConfig) (u ^?! preloadData . renderData)
pdata <- renderDataResizeUpdate (u ^. uvConfig) (u ^. preloadData . renderData)
return $ u & preloadData . renderData .~ pdata
pdataResizeUpdate :: Configuration -> RenderData -> IO RenderData
pdataResizeUpdate cfig pdata = do
rd <- renderDataResizeUpdate cfig pdata
return rd
renderDataResizeUpdate ::
Configuration ->
RenderData ->
@@ -36,7 +34,6 @@ renderDataResizeUpdate cfig rdata = do
(bh, bmid) = BS.breakSubstring "(" bbFrag
(_, btt) = BS.breakSubstring ")" bmid
bbFrag' = BS.append bh $ BS.append (BSC.pack $ '(' : show xsize ++ "," ++ show ysize) btt
--BSC.putStrLn bbFrag'
bbShad <-
makeByteStringShaderUsingVAO
"bloomBlur"
@@ -44,8 +41,3 @@ renderDataResizeUpdate cfig rdata = do
pmTriangleStrip
(rdata ^. screenTextureVAO)
return (rdata'{_bloomBlurShader = bbShad})
getWindowSize :: Integral a => (Configuration -> ResFactor) -> Configuration -> (a,a)
getWindowSize f cfig = (g _windowX,g _windowY)
where
g h = fromIntegral $ round (h cfig) `div` resFactorNum (f cfig)
+3 -3
View File
@@ -240,7 +240,7 @@ instanceLightMap ::
IO ()
instanceLightMap cfig nWalls nSils nCaps toPos tanormals lightPoints pdata = do
let lcapShad = _shadowCapShader pdata
(xsize, ysize) = getWindowSize cfig
(xsize, ysize) = getWindowSize _graphics_world_resolution cfig
withArray (lightsToArray lightPoints) $ \ptr ->
glNamedBufferSubData (pdata ^. lightsUBO) 0 620 ptr
forM_ [0 .. 19] $ \i ->
@@ -257,8 +257,8 @@ instanceLightMap cfig nWalls nSils nCaps toPos tanormals lightPoints pdata = do
0
0
i
(fromIntegral xsize)
(fromIntegral ysize)
xsize
ysize
1
glBindFramebuffer GL_FRAMEBUFFER $ pdata ^. fboShadow . _1 . unFBO
glDepthMask GL_FALSE