diff --git a/data/texture/charMapVertBig.png b/data/texture/charMapVertBig.png index d43dcb22b..4fb820394 100644 Binary files a/data/texture/charMapVertBig.png and b/data/texture/charMapVertBig.png differ diff --git a/shader/texture/bloomBlur.frag b/shader/texture/bloomBlur.frag index dd05ea52a..507bb2bbb 100644 --- a/shader/texture/bloomBlur.frag +++ b/shader/texture/bloomBlur.frag @@ -6,8 +6,9 @@ const vec2 winSize = vec2 (300.0,300.0); // this is so that the window size can be extracted and the shader recompiled on // the fly layout (binding = 0) uniform sampler2D screenTexture; -const float hOff = 3 / winSize.x; -const float vOff = 3 / winSize.y; +// the 1.5 maximises the blend, so to speak +const float hOff = 1.5 / winSize.x; +const float vOff = 1.5 / winSize.y; //const vec2 off[9] = vec2[] // ( vec2( hOff, vOff ) // , vec2( hOff, 0.0 ) diff --git a/src/Dodge/Config/Update.hs b/src/Dodge/Config/Update.hs index abe065d06..e322660eb 100644 --- a/src/Dodge/Config/Update.hs +++ b/src/Dodge/Config/Update.hs @@ -48,8 +48,4 @@ applyWorldConfig :: IO PreloadData applyWorldConfig cfig pdata = do setVol cfig - pdataResizeUpdate cfig (x `div` divRes) (y `div` divRes) x y pdata - where - x = round $ _windowX cfig - y = round $ _windowY cfig - divRes = resFactorNum $ _graphics_world_resolution cfig + renderData (pdataResizeUpdate cfig) pdata diff --git a/src/Dodge/Event.hs b/src/Dodge/Event.hs index 29fbc307d..f38da1df0 100644 --- a/src/Dodge/Event.hs +++ b/src/Dodge/Event.hs @@ -15,11 +15,12 @@ module Dodge.Event ( handleEvent, ) where +import Control.Monad import qualified Data.Text as T import Dodge.Concurrent import Dodge.Data.Universe import Dodge.Event.Input -import Dodge.PreloadData +import Preload.Update import LensHelp import SDL @@ -56,9 +57,7 @@ handleResizeEvent sev u = u & uvConfig . windowX .~ fromIntegral x & uvConfig . windowY .~ fromIntegral y - & uvIOEffects %~ sideEffectUpdatePreload divRes x y + -- & uvIOEffects %~ sideEffectUpdatePreload + & uvIOEffects %~ (updatePreload >=>) where - x = fromIntegral x' - y = fromIntegral y' - V2 x' y' = windowSizeChangedEventSize sev - divRes = resFactorNum $ u ^. uvConfig . graphics_world_resolution + V2 x y = windowSizeChangedEventSize sev diff --git a/src/Dodge/Menu.hs b/src/Dodge/Menu.hs index 976d27836..b8408eb00 100644 --- a/src/Dodge/Menu.hs +++ b/src/Dodge/Menu.hs @@ -16,7 +16,7 @@ import Dodge.Data.Universe import Dodge.Menu.Option import Dodge.Menu.OptionType import Dodge.Menu.PushPop -import Dodge.PreloadData +import Preload.Update import Dodge.Save import Dodge.SoundLogic import Dodge.StartNewGame @@ -182,11 +182,11 @@ graphicsMenu = titleOptionsMenu "OPTIONS:GRAPHICS" graphicsMenuOptions graphicsMenuOptions :: [MenuOption] graphicsMenuOptions = - [ makeEnumOption graphics_world_resolution "World resolution" (uvIOEffects .~ updateFramebufferSize) + [ makeEnumOption graphics_world_resolution "World resolution" (uvIOEffects .~ updatePreload) , makeEnumOption graphics_downsize_resolution "Downsize resolution" - (uvIOEffects .~ updateFramebufferSize) + (uvIOEffects .~ updatePreload) , makeEnumOption graphics_overlay_resolution "Overlay resolution" - (uvIOEffects .~ updateFramebufferSize) + (uvIOEffects .~ updatePreload) , makeEnumOption graphics_object_shadows "SHADOW DETAIL" id , makeEnumOption graphics_distortions "ENABLE DISTORTIONS" id , makeEnumOption graphics_bloom "ENABLE BLOOM" id diff --git a/src/Dodge/PreloadData.hs b/src/Dodge/PreloadData.hs deleted file mode 100644 index 92cc51bb1..000000000 --- a/src/Dodge/PreloadData.hs +++ /dev/null @@ -1,23 +0,0 @@ -module Dodge.PreloadData where - -import Control.Lens -import Dodge.Data.Universe -import Preload.Update - -sideEffectUpdatePreload :: Int -> Int -> Int -> (Universe -> IO Universe) -> Universe -> IO Universe -sideEffectUpdatePreload divRes x y f u = do - -- GL.viewport $= (GL.Position 0 0, GL.Size (fromIntegral x) (fromIntegral y)) - pdata <- pdataResizeUpdate (u ^. uvConfig) (x `div` divRes) (y `div` divRes) x y (_preloadData u) - f $ u & preloadData .~ pdata - -updatePreload :: Int -> Int -> Int -> Universe -> IO Universe -updatePreload divRes x y u = do - pdata <- pdataResizeUpdate (u ^. uvConfig) (x `div` divRes) (y `div` divRes) x y (_preloadData u) - return $ u & preloadData .~ pdata - -updateFramebufferSize :: Universe -> IO Universe -updateFramebufferSize u = updatePreload divRes x y u - where - (x, y) = (round $ _windowX cfig, round $ _windowY cfig) - cfig = _uvConfig u - divRes = resFactorNum $ u ^. uvConfig . graphics_world_resolution diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index 57e381cc5..69a369431 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -51,7 +51,6 @@ doDrawing' win pdata u = do wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig) worldres = resFactorNum $ cfig ^. graphics_world_resolution downres = resFactorNum $ cfig ^. graphics_downsize_resolution - overlayres = resFactorNum $ cfig ^. graphics_overlay_resolution (windowPoints, wallSPics, wallsToPoke) = wallsToDraw w lightPoints = lightsToRender cfig (w ^. cWorld . camPos) (w ^. cWorld . lWorld) viewFroms@(V2 vfx vfy) = w ^. cWorld . camPos . camViewFrom diff --git a/src/Preload/Update.hs b/src/Preload/Update.hs index 307a78fab..b253e0f1a 100644 --- a/src/Preload/Update.hs +++ b/src/Preload/Update.hs @@ -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)