Work on distortions
This commit is contained in:
@@ -7,7 +7,10 @@ import Geometry
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
|
||||
data Distortion = RadialDistortion Point2 Point2 Point2 Point2 Int
|
||||
data Distortion = RadialDistortion
|
||||
Point2 Point2 Point2
|
||||
Point2 Point2 Point2
|
||||
Int
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
deriveJSON defaultOptions ''Distortion
|
||||
|
||||
@@ -5,6 +5,6 @@ import Dodge.Data.Distortion
|
||||
|
||||
updateDistortion :: Distortion -> Maybe Distortion
|
||||
updateDistortion = \case
|
||||
RadialDistortion a b c d t
|
||||
| t > 0 -> Just $ RadialDistortion a b c d $ t-1
|
||||
RadialDistortion a b c d e f t
|
||||
| t > 0 -> Just $ RadialDistortion a b c d e f $ t-1
|
||||
| otherwise -> Nothing
|
||||
|
||||
+13
-5
@@ -1,15 +1,23 @@
|
||||
module Dodge.Event.Test (testEvent) where
|
||||
|
||||
--import Dodge.Creature.State
|
||||
import Dodge.Data.World
|
||||
import Linear
|
||||
import LensHelp
|
||||
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
import LensHelp
|
||||
import Linear
|
||||
|
||||
testEvent :: World -> World
|
||||
testEvent w = fromMaybe w $ do
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
|
||||
let distR = 50
|
||||
distortionBulge = RadialDistortion cpos (V2 (0.5*distR) (-0.5*distR)) (V2 0 distR)
|
||||
(V2 (0.5* distR) 0) 20
|
||||
distortionBulge =
|
||||
RadialDistortion
|
||||
cpos
|
||||
(V2 distR 0)
|
||||
(V2 0 distR)
|
||||
(V2 2 0)
|
||||
(V2 0 0.5)
|
||||
(V2 0 0)
|
||||
20
|
||||
return $ w & cWorld . lWorld . distortions .~ [distortionBulge]
|
||||
|
||||
+5
-4
@@ -366,12 +366,13 @@ doDrawing' win pdata u = do
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
glUseProgram (pdata ^. fullscreenShader)
|
||||
glDrawArrays GL_TRIANGLES 0 6
|
||||
(RadialDistortion (V2 a b) (V2 c d) (V2 e f) (V2 g h) _:_) -> do
|
||||
--(RadialDistortion (V2 a b) (V2 c d) (V2 e f) (V2 g h) _:_) -> do
|
||||
(RadialDistortion a b c d e f _:_) -> do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fbo2 . _1 . unFBO)
|
||||
pokeArray (pdata ^. barrelShader . _2 . vboPtr) [a, b, c, d, e, f, g, h]
|
||||
withArray [a, b, c, d, e, f, g] $
|
||||
-- pokeArray (pdata ^. barrelShader . _2 . vboPtr) [a, b, c, d, e, f, g, h]
|
||||
withArray [a, b, c, d, e, f] $
|
||||
glNamedBufferSubData (pdata ^. barrelShader . _2 . vboName) 0
|
||||
(6 * fromIntegral (sizeOf (0 :: Float)))
|
||||
(12 * fromIntegral (sizeOf (0 :: Float)))
|
||||
glBindTextureUnit 1 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||
glUseProgram (pdata ^. barrelShader . _1)
|
||||
glDrawArrays GL_TRIANGLES 0 6
|
||||
|
||||
Reference in New Issue
Block a user