Refactor preloading/rendering/update
This commit is contained in:
+19
-27
@@ -1,52 +1,39 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Preload.Update (
|
||||
updatePreload,
|
||||
pdataResizeUpdate,
|
||||
) where
|
||||
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Data.Universe
|
||||
import Control.Lens
|
||||
import qualified Data.ByteString as BS
|
||||
import qualified Data.ByteString.Char8 as BSC
|
||||
import Data.Preload
|
||||
import Data.Preload.Render
|
||||
import Framebuffer.Update
|
||||
import Shader.Compile
|
||||
import Shader.Data
|
||||
|
||||
pdataResizeUpdate ::
|
||||
Configuration ->
|
||||
-- | Scaled width
|
||||
Int ->
|
||||
-- | Scaled height
|
||||
Int ->
|
||||
-- | Full width
|
||||
Int ->
|
||||
-- | Full height
|
||||
Int ->
|
||||
PreloadData ->
|
||||
IO PreloadData
|
||||
pdataResizeUpdate cfig xsize ysize xfull yfull pdata = do
|
||||
rd <- renderDataResizeUpdate cfig xsize ysize xfull yfull (_renderData pdata)
|
||||
return (pdata{_renderData = rd})
|
||||
updatePreload :: Universe -> IO Universe
|
||||
updatePreload u = do
|
||||
pdata <- pdataResizeUpdate (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 ->
|
||||
-- | Scaled width
|
||||
Int ->
|
||||
-- | Scaled height
|
||||
Int ->
|
||||
-- | Full width
|
||||
Int ->
|
||||
-- | Full height
|
||||
Int ->
|
||||
RenderData ->
|
||||
IO RenderData
|
||||
renderDataResizeUpdate cfig xsize ysize xfull yfull rdata = do
|
||||
renderDataResizeUpdate cfig rdata = do
|
||||
rdata' <- sizeFBOs cfig rdata
|
||||
bbVert <- BS.readFile "shader/texture/bloomBlur.vert"
|
||||
bbFrag <- BS.readFile "shader/texture/bloomBlur.frag"
|
||||
let (bh, bmid) = BS.breakSubstring "(" bbFrag
|
||||
let (xsize,ysize) = getWindowSize _graphics_downsize_resolution cfig :: (Int,Int)
|
||||
(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'
|
||||
@@ -57,3 +44,8 @@ renderDataResizeUpdate cfig xsize ysize xfull yfull 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)
|
||||
|
||||
Reference in New Issue
Block a user