Move pair to V2
This commit is contained in:
@@ -5,13 +5,13 @@ module Dodge.Base.Coordinate (
|
|||||||
worldPosToResOffset,
|
worldPosToResOffset,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.WindowSize
|
|
||||||
import Linear
|
|
||||||
import Dodge.Data.Config
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Data.Camera
|
import Dodge.Data.Camera
|
||||||
|
import Dodge.Data.Config
|
||||||
import Dodge.Data.Input
|
import Dodge.Data.Input
|
||||||
|
import Dodge.WindowSize
|
||||||
import Geometry
|
import Geometry
|
||||||
|
import Linear
|
||||||
|
|
||||||
{- | Transform world coordinates to scaled screen coordinates.
|
{- | Transform world coordinates to scaled screen coordinates.
|
||||||
- These have to be scaled according to the size of the window to get actual screen positions.
|
- 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 ^. camZoom) *^)
|
||||||
. (-.- (cam ^. camCenter))
|
. (-.- (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 :: Config -> Camera -> Point2 -> Point2
|
||||||
worldPosToResOffset cfig cam p = (worldPosToScreen cam p & each %~ f)
|
worldPosToResOffset cfig cam p =
|
||||||
+ 0.5 *^ (uncurry V2 (getWindowSize _gr_world_res cfig::(Int,Int)) & each %~ fromIntegral)
|
(worldPosToScreen cam p & each %~ f)
|
||||||
|
+ 0.5 *^ ((getWindowSize _gr_world_res cfig :: V2 Int) & each %~ fromIntegral)
|
||||||
where
|
where
|
||||||
f x = applyResFactorF (cfig ^. gr_world_res) x
|
f x = applyResFactorF (cfig ^. gr_world_res) x
|
||||||
|
|
||||||
|
|
||||||
-- | The mouse position in world coordinates.
|
-- | The mouse position in world coordinates.
|
||||||
mouseWorldPos :: Input -> Camera -> Point2
|
mouseWorldPos :: Input -> Camera -> Point2
|
||||||
mouseWorldPos inp cam = screenToWorldPos cam (inp ^. mousePos)
|
mouseWorldPos inp cam = screenToWorldPos cam (inp ^. mousePos)
|
||||||
|
|||||||
+1
-1
@@ -417,4 +417,4 @@ getDistortions cfig w
|
|||||||
| otherwise = []
|
| otherwise = []
|
||||||
|
|
||||||
setViewport :: (Config -> ResFactor) -> Config -> IO ()
|
setViewport :: (Config -> ResFactor) -> Config -> IO ()
|
||||||
setViewport f = uncurry (glViewport 0 0) . getWindowSize f
|
setViewport f = uncurryV (glViewport 0 0) . getWindowSize f
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
module Dodge.WindowSize (getWindowSize) where
|
module Dodge.WindowSize (getWindowSize) where
|
||||||
|
|
||||||
import Dodge.Data.Config
|
import Dodge.Data.Config
|
||||||
|
import Linear
|
||||||
|
|
||||||
getWindowSize :: Integral a => (Config -> ResFactor) -> Config -> (a,a)
|
getWindowSize :: Integral a => (Config -> ResFactor) -> Config -> V2 a
|
||||||
getWindowSize f cfig = (g _windowX, g _windowY)
|
getWindowSize f cfig = V2 (g _windowX) (g _windowY)
|
||||||
where
|
where
|
||||||
g h = fromIntegral $ applyResFactor (f cfig) (h cfig)
|
g h = fromIntegral $ applyResFactor (f cfig) (h cfig)
|
||||||
|
|||||||
+12
-16
@@ -5,6 +5,7 @@
|
|||||||
-}
|
-}
|
||||||
module Framebuffer.Update (sizeFBOs) where
|
module Framebuffer.Update (sizeFBOs) where
|
||||||
|
|
||||||
|
import Geometry.Data
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Preload.Render
|
import Data.Preload.Render
|
||||||
@@ -19,9 +20,8 @@ import Unsafe.Coerce
|
|||||||
|
|
||||||
sizeFBOs :: Config -> RenderData -> IO RenderData
|
sizeFBOs :: Config -> RenderData -> IO RenderData
|
||||||
sizeFBOs cfig rdata =
|
sizeFBOs cfig rdata =
|
||||||
uncurry (resizeRBO (_rboBaseBloom rdata)) (getWindowSize _gr_world_res cfig)
|
uncurryV (resizeRBO (_rboBaseBloom rdata)) (getWindowSize _gr_world_res cfig)
|
||||||
>> uncurry
|
>> updateFBOTO3
|
||||||
updateFBOTO3
|
|
||||||
(getWindowSize _gr_world_res cfig)
|
(getWindowSize _gr_world_res cfig)
|
||||||
GL_NEAREST
|
GL_NEAREST
|
||||||
GL_NEAREST
|
GL_NEAREST
|
||||||
@@ -34,7 +34,7 @@ sizeFBOs cfig rdata =
|
|||||||
rdata
|
rdata
|
||||||
fboBase
|
fboBase
|
||||||
>>= flip
|
>>= flip
|
||||||
( uncurry
|
(
|
||||||
updateFBOTO3
|
updateFBOTO3
|
||||||
(getWindowSize _gr_world_res cfig)
|
(getWindowSize _gr_world_res cfig)
|
||||||
GL_NEAREST
|
GL_NEAREST
|
||||||
@@ -69,8 +69,7 @@ sizeFBOs cfig rdata =
|
|||||||
GL_RGBA16F
|
GL_RGBA16F
|
||||||
[fboHalf1, fboHalf2]
|
[fboHalf1, fboHalf2]
|
||||||
>>= flip
|
>>= flip
|
||||||
( uncurry
|
( updateFBOTO2
|
||||||
updateFBOTO2
|
|
||||||
(getWindowSize _gr_world_res cfig)
|
(getWindowSize _gr_world_res cfig)
|
||||||
GL_NEAREST
|
GL_NEAREST
|
||||||
GL_NEAREST
|
GL_NEAREST
|
||||||
@@ -79,7 +78,7 @@ sizeFBOs cfig rdata =
|
|||||||
)
|
)
|
||||||
fboWindow
|
fboWindow
|
||||||
where
|
where
|
||||||
updateFBOTO' f = uncurry updateFBOTO (getWindowSize f cfig)
|
updateFBOTO' f = updateFBOTO (getWindowSize f cfig)
|
||||||
foldUpdateFBOTO f minfilt magfilt form =
|
foldUpdateFBOTO f minfilt magfilt form =
|
||||||
ffoldM (updateFBOTO' 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
|
resizeRBO rboName = glNamedRenderbufferStorage rboName GL_DEPTH24_STENCIL8
|
||||||
|
|
||||||
updateFBOTO ::
|
updateFBOTO ::
|
||||||
Int ->
|
V2 Int ->
|
||||||
Int ->
|
|
||||||
-- | minification filter
|
-- | minification filter
|
||||||
GLenum ->
|
GLenum ->
|
||||||
-- | magnification filter
|
-- | magnification filter
|
||||||
@@ -101,15 +99,14 @@ updateFBOTO ::
|
|||||||
RenderData ->
|
RenderData ->
|
||||||
ALens' RenderData (FBO, TO) ->
|
ALens' RenderData (FBO, TO) ->
|
||||||
IO RenderData
|
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
|
newfbo2 <- resizeFBOTO (pdata ^# target) xsize ysize minfilt magfilt form
|
||||||
return $ storing target newfbo2 pdata
|
return $ storing target newfbo2 pdata
|
||||||
|
|
||||||
-- note that the ordering of arguments is different to the other update
|
-- note that the ordering of arguments is different to the other update
|
||||||
-- functions... this all needs rethinking
|
-- functions... this all needs rethinking
|
||||||
updateFBOTO2 ::
|
updateFBOTO2 ::
|
||||||
Int ->
|
V2 Int ->
|
||||||
Int ->
|
|
||||||
-- | minification filter
|
-- | minification filter
|
||||||
GLenum ->
|
GLenum ->
|
||||||
-- | magnification filter
|
-- | magnification filter
|
||||||
@@ -121,13 +118,12 @@ updateFBOTO2 ::
|
|||||||
RenderData ->
|
RenderData ->
|
||||||
ALens' RenderData (FBO, (TO, TO)) ->
|
ALens' RenderData (FBO, (TO, TO)) ->
|
||||||
IO RenderData
|
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
|
newfbo2 <- resizeFBOTO2 (pdata ^# target) xsize ysize minfilt magfilt form1 form2
|
||||||
return $ storing target newfbo2 pdata
|
return $ storing target newfbo2 pdata
|
||||||
|
|
||||||
updateFBOTO3 ::
|
updateFBOTO3 ::
|
||||||
Int ->
|
V2 Int ->
|
||||||
Int ->
|
|
||||||
-- | minification filter
|
-- | minification filter
|
||||||
GLenum ->
|
GLenum ->
|
||||||
-- | magnification filter
|
-- | magnification filter
|
||||||
@@ -141,7 +137,7 @@ updateFBOTO3 ::
|
|||||||
RenderData ->
|
RenderData ->
|
||||||
ALens' RenderData (FBO, (TO, TO, TO)) ->
|
ALens' RenderData (FBO, (TO, TO, TO)) ->
|
||||||
IO RenderData
|
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
|
newfbo2 <- resizeFBOTO3 (pdata ^# target) xsize ysize minfilt magfilt form1 form2 form3
|
||||||
return $ storing target newfbo2 pdata
|
return $ storing target newfbo2 pdata
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module Preload.Update (
|
|||||||
renderDataResizeUpdate,
|
renderDataResizeUpdate,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Linear
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
import qualified Data.ByteString.Char8 as BSC
|
import qualified Data.ByteString.Char8 as BSC
|
||||||
@@ -28,7 +29,7 @@ renderDataResizeUpdate cfig rdata = do
|
|||||||
rdata' <- sizeFBOs cfig rdata
|
rdata' <- sizeFBOs cfig rdata
|
||||||
bbVert <- BS.readFile "shader/texture/bloomBlur.vert"
|
bbVert <- BS.readFile "shader/texture/bloomBlur.vert"
|
||||||
bbFrag <- BS.readFile "shader/texture/bloomBlur.frag"
|
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
|
(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
|
||||||
|
|||||||
@@ -162,6 +162,8 @@ renderShadows cam cfig shadrendertype nWalls nSils nCaps positiontexture normalt
|
|||||||
-- note that the stencil shadows rely on the depth buffer
|
-- note that the stencil shadows rely on the depth buffer
|
||||||
let d = rad * cam ^. camZoom
|
let d = rad * cam ^. camZoom
|
||||||
V2 x' y' = worldPosToResOffset cfig cam (V2 x y)
|
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)
|
glScissor (round (x'-d)) (round (y'-d)) (round $ 2 *d) (round $ 2* d)
|
||||||
glDepthFunc GL_LESS
|
glDepthFunc GL_LESS
|
||||||
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
|
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user