Implement translation rotation zoom using uniform buffers, improvement?

This commit is contained in:
jgk
2021-02-25 04:14:52 +01:00
parent 32bfab2e02
commit 37e26dcb07
6 changed files with 76 additions and 12 deletions
+2 -2
View File
@@ -72,8 +72,8 @@ worldPictures w
, smokeShadows
]
where
screenShift = scale zoomx zoomy . rotate (0 - (_cameraRot w) )
. uncurry translate ((0,0) -.- _cameraPos w)
screenShift = id--scale zoomx zoomy . rotate (0 - (_cameraRot w) )
-- . uncurry translate ((0,0) -.- _cameraPos w)
zoomx = 2 * _cameraZoom w / _windowX w
zoomy = 2 * _cameraZoom w / _windowY w
scaler = scale (2 / _windowX w) (2 / _windowY w)
+17 -3
View File
@@ -358,13 +358,27 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
clear [DepthBuffer]
-- draw layer 0
renderTree pdata rot zoom (tranx,trany) (winx,winy) (picToList 0 pic)
renderTree pdata rot zoom (tranx,trany) (winx,winy) (picToFTree 0 pic)
-- reset blend so that light map doesn't apply
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToList 1 pic
renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToFTree 1 pic
-- set drawing for on top
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToList 2 pic
renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToFTree 2 pic
-- reset uniforms (hacky for now)
forM_ [_basicShader pdata
,_textShader pdata
,_circShader pdata
,_arcShader pdata
,_fadeCircleShader pdata
,_backShader pdata
,_wallShadowShader pdata
] $ \shad -> do
currentProgram $= Just (fst shad)
uniform (snd shad !! 0) $= Vector2 (2::Float) 2
uniform (snd shad !! 1) $= (1::Float)
uniform (snd shad !! 2) $= (0::Float)
uniform (snd shad !! 3) $= Vector2 (0::Float) 0
bufferOffset :: Integral a => a -> Ptr b