26 lines
996 B
Haskell
26 lines
996 B
Haskell
module Dodge.PreloadData where
|
|
|
|
--import qualified Graphics.Rendering.OpenGL as GL
|
|
import Control.Lens
|
|
import Dodge.Data.Universe
|
|
import Preload.Update
|
|
--import SDL
|
|
|
|
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 (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 (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_resolution_factor
|