Move pair to V2

This commit is contained in:
2025-11-14 02:13:03 +00:00
parent 292a1c3f42
commit bfd7aa619e
6 changed files with 27 additions and 27 deletions
+7 -7
View File
@@ -5,13 +5,13 @@ module Dodge.Base.Coordinate (
worldPosToResOffset,
) where
import Dodge.WindowSize
import Linear
import Dodge.Data.Config
import Control.Lens
import Dodge.Data.Camera
import Dodge.Data.Config
import Dodge.Data.Input
import Dodge.WindowSize
import Geometry
import Linear
{- | Transform world coordinates to scaled screen coordinates.
- These have to be scaled according to the size of the window to get actual screen positions.
@@ -25,14 +25,14 @@ worldPosToScreen cam =
. ((cam ^. camZoom) *^)
. (-.- (cam ^. camCenter))
-- gets the position from the bottom left in "world res" "pixels"
-- gets the position from the bottom left in world-resolution "pixels"
worldPosToResOffset :: Config -> Camera -> Point2 -> Point2
worldPosToResOffset cfig cam p = (worldPosToScreen cam p & each %~ f)
+ 0.5 *^ (uncurry V2 (getWindowSize _gr_world_res cfig::(Int,Int)) & each %~ fromIntegral)
worldPosToResOffset cfig cam p =
(worldPosToScreen cam p & each %~ f)
+ 0.5 *^ ((getWindowSize _gr_world_res cfig :: V2 Int) & each %~ fromIntegral)
where
f x = applyResFactorF (cfig ^. gr_world_res) x
-- | The mouse position in world coordinates.
mouseWorldPos :: Input -> Camera -> Point2
mouseWorldPos inp cam = screenToWorldPos cam (inp ^. mousePos)
+1 -1
View File
@@ -417,4 +417,4 @@ getDistortions cfig w
| otherwise = []
setViewport :: (Config -> ResFactor) -> Config -> IO ()
setViewport f = uncurry (glViewport 0 0) . getWindowSize f
setViewport f = uncurryV (glViewport 0 0) . getWindowSize f
+3 -2
View File
@@ -1,8 +1,9 @@
module Dodge.WindowSize (getWindowSize) where
import Dodge.Data.Config
import Linear
getWindowSize :: Integral a => (Config -> ResFactor) -> Config -> (a,a)
getWindowSize f cfig = (g _windowX, g _windowY)
getWindowSize :: Integral a => (Config -> ResFactor) -> Config -> V2 a
getWindowSize f cfig = V2 (g _windowX) (g _windowY)
where
g h = fromIntegral $ applyResFactor (f cfig) (h cfig)
+12 -16
View File
@@ -5,6 +5,7 @@
-}
module Framebuffer.Update (sizeFBOs) where
import Geometry.Data
import Control.Lens
import Control.Monad
import Data.Preload.Render
@@ -19,9 +20,8 @@ import Unsafe.Coerce
sizeFBOs :: Config -> RenderData -> IO RenderData
sizeFBOs cfig rdata =
uncurry (resizeRBO (_rboBaseBloom rdata)) (getWindowSize _gr_world_res cfig)
>> uncurry
updateFBOTO3
uncurryV (resizeRBO (_rboBaseBloom rdata)) (getWindowSize _gr_world_res cfig)
>> updateFBOTO3
(getWindowSize _gr_world_res cfig)
GL_NEAREST
GL_NEAREST
@@ -34,7 +34,7 @@ sizeFBOs cfig rdata =
rdata
fboBase
>>= flip
( uncurry
(
updateFBOTO3
(getWindowSize _gr_world_res cfig)
GL_NEAREST
@@ -69,8 +69,7 @@ sizeFBOs cfig rdata =
GL_RGBA16F
[fboHalf1, fboHalf2]
>>= flip
( uncurry
updateFBOTO2
( updateFBOTO2
(getWindowSize _gr_world_res cfig)
GL_NEAREST
GL_NEAREST
@@ -79,7 +78,7 @@ sizeFBOs cfig rdata =
)
fboWindow
where
updateFBOTO' f = uncurry updateFBOTO (getWindowSize f cfig)
updateFBOTO' f = updateFBOTO (getWindowSize f cfig)
foldUpdateFBOTO f minfilt magfilt form =
ffoldM (updateFBOTO' f minfilt magfilt form)
@@ -90,8 +89,7 @@ resizeRBO :: GLuint -> GLsizei -> GLsizei -> IO ()
resizeRBO rboName = glNamedRenderbufferStorage rboName GL_DEPTH24_STENCIL8
updateFBOTO ::
Int ->
Int ->
V2 Int ->
-- | minification filter
GLenum ->
-- | magnification filter
@@ -101,15 +99,14 @@ updateFBOTO ::
RenderData ->
ALens' RenderData (FBO, TO) ->
IO RenderData
updateFBOTO xsize ysize minfilt magfilt form pdata target = do
updateFBOTO (V2 xsize ysize) minfilt magfilt form pdata target = do
newfbo2 <- resizeFBOTO (pdata ^# target) xsize ysize minfilt magfilt form
return $ storing target newfbo2 pdata
-- note that the ordering of arguments is different to the other update
-- functions... this all needs rethinking
updateFBOTO2 ::
Int ->
Int ->
V2 Int ->
-- | minification filter
GLenum ->
-- | magnification filter
@@ -121,13 +118,12 @@ updateFBOTO2 ::
RenderData ->
ALens' RenderData (FBO, (TO, TO)) ->
IO RenderData
updateFBOTO2 xsize ysize minfilt magfilt form1 form2 pdata target = do
updateFBOTO2 (V2 xsize ysize) minfilt magfilt form1 form2 pdata target = do
newfbo2 <- resizeFBOTO2 (pdata ^# target) xsize ysize minfilt magfilt form1 form2
return $ storing target newfbo2 pdata
updateFBOTO3 ::
Int ->
Int ->
V2 Int ->
-- | minification filter
GLenum ->
-- | magnification filter
@@ -141,7 +137,7 @@ updateFBOTO3 ::
RenderData ->
ALens' RenderData (FBO, (TO, TO, TO)) ->
IO RenderData
updateFBOTO3 xsize ysize minfilt magfilt form1 form2 form3 pdata target = do
updateFBOTO3 (V2 xsize ysize) minfilt magfilt form1 form2 form3 pdata target = do
newfbo2 <- resizeFBOTO3 (pdata ^# target) xsize ysize minfilt magfilt form1 form2 form3
return $ storing target newfbo2 pdata
+2 -1
View File
@@ -5,6 +5,7 @@ module Preload.Update (
renderDataResizeUpdate,
) where
import Linear
import Control.Lens
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BSC
@@ -28,7 +29,7 @@ renderDataResizeUpdate cfig rdata = do
rdata' <- sizeFBOs cfig rdata
bbVert <- BS.readFile "shader/texture/bloomBlur.vert"
bbFrag <- BS.readFile "shader/texture/bloomBlur.frag"
let (xsize, ysize) = getWindowSize _gr_downsize_res cfig :: (Int, Int)
let V2 xsize ysize = getWindowSize _gr_downsize_res cfig :: V2 Int
(bh, bmid) = BS.breakSubstring "(" bbFrag
(_, btt) = BS.breakSubstring ")" bmid
bbFrag' = BS.append bh $ BS.append (BSC.pack $ '(' : show xsize ++ "," ++ show ysize) btt
+2
View File
@@ -162,6 +162,8 @@ renderShadows cam cfig shadrendertype nWalls nSils nCaps positiontexture normalt
-- note that the stencil shadows rely on the depth buffer
let d = rad * cam ^. camZoom
V2 x' y' = worldPosToResOffset cfig cam (V2 x y)
-- this is probably too strict, it will be possible for high up lights
-- to have some of their light cast high up cut off
glScissor (round (x'-d)) (round (y'-d)) (round $ 2 *d) (round $ 2* d)
glDepthFunc GL_LESS
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE