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