Work on distortion shaders
This commit is contained in:
+14
-15
@@ -330,6 +330,7 @@ doDrawing' win pdata u = do
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
|
||||
-- bind base buffer for drawing clouds and bloom
|
||||
--
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO)
|
||||
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
@@ -358,26 +359,24 @@ doDrawing' win pdata u = do
|
||||
setViewport (const FullRes) cfig
|
||||
glDepthFunc GL_ALWAYS
|
||||
glBlendFunc GL_ONE GL_ZERO
|
||||
-- perform any radial distortion
|
||||
-- perform distortions
|
||||
-- this is hideous
|
||||
case (getDistortions cfig w, cfig ^. gr_distortions) of
|
||||
(rds, x) | null rds || not x -> do
|
||||
case getDistortions cfig w of
|
||||
[] -> do
|
||||
glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
glUseProgram (pdata ^. fullscreenShader)
|
||||
glDrawArrays GL_TRIANGLES 0 6
|
||||
(rds, _) -> do
|
||||
let bindDrawDist :: Distortion -> IO ()
|
||||
bindDrawDist (RadialDistortion (V2 a b) (V2 c d) (V2 e f) g) = do
|
||||
pokeArray (shadVBOptr $ _barrelShader pdata) [a, b, c, d, e, f, g]
|
||||
bufferPokedVBO (snd $ _barrelShader pdata) 1
|
||||
drawShader (fst $ _barrelShader pdata) 1
|
||||
fboList =
|
||||
take (length rds - 1) (concat (repeat [fst $ _fbo2 pdata, fst $ _fbo3 pdata]))
|
||||
++ [FBO 0]
|
||||
toList = (pdata ^. fboBase . _2 . _1) : concat (repeat [snd $ _fbo2 pdata, snd $ _fbo3 pdata])
|
||||
bindings = zipWith (>>) (map bindFBO fboList) (map (glBindTextureUnit 1 . _unTO) toList)
|
||||
zipWithM_ (>>) bindings $ map bindDrawDist rds
|
||||
(RadialDistortion (V2 a b) (V2 c d) (V2 e f) g:_) -> do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fbo2 . _1 . unFBO)
|
||||
pokeArray (shadVBOptr $ _barrelShader pdata) [a, b, c, d, e, f, g]
|
||||
bufferPokedVBO (snd $ _barrelShader pdata) 1
|
||||
glBindTextureUnit 1 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||
drawShader (fst $ _barrelShader pdata) 1
|
||||
glBindTextureUnit 0 $ pdata ^. fbo2 . _2 . unTO
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
glUseProgram (pdata ^. fullscreenShader)
|
||||
glDrawArrays GL_TRIANGLES 0 6
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
-- draw the overlay
|
||||
--glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboOverlay ._1 . unFBO)
|
||||
|
||||
Reference in New Issue
Block a user