Work on distortion shader

This commit is contained in:
2025-11-15 13:21:11 +00:00
parent 5dfc97a683
commit d436b853eb
8 changed files with 44 additions and 55 deletions
+1 -1
View File
@@ -10,5 +10,5 @@ testEvent :: World -> World
testEvent w = fromMaybe w $ do
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
let distR = 50
distortionBulge = RadialDistortion cpos (cpos + V2 distR 0) (cpos + V2 0 distR) 1.9
distortionBulge = RadialDistortion cpos (V2 distR 0) (cpos + V2 0 distR) 1.9
return $ w & cWorld . lWorld . distortions .~ [distortionBulge]
+6 -4
View File
@@ -25,7 +25,6 @@ import Graphics.GL.Core45
import MatrixHelper
import Render
import qualified SDL
import Shader
import Shader.Bind
import Shader.Data
import Shader.Poke
@@ -369,10 +368,13 @@ doDrawing' win pdata u = do
glDrawArrays GL_TRIANGLES 0 6
(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
pokeArray (pdata ^. barrelShader . _2 . vboPtr) [a, b, c, d, e, f]
withArray [a, b, c, d, e, f, g] $
glNamedBufferSubData (pdata ^. barrelShader . _2 . vboName) 0
(6 * fromIntegral (sizeOf (0 :: Float)))
glBindTextureUnit 1 $ pdata ^. fboBase . _2 . _1 . unTO
drawShader (fst $ _barrelShader pdata) 1
glUseProgram (pdata ^. barrelShader . _1)
glDrawArrays GL_TRIANGLES 0 6
glBindTextureUnit 0 $ pdata ^. fbo2 . _2 . unTO
glBindFramebuffer GL_FRAMEBUFFER 0
glUseProgram (pdata ^. fullscreenShader)