module FWGL.Utils (
screenScale,
perspective4,
perspectiveView
) where
import FRP.Yampa
import FWGL.Input
import FWGL.Graphics.Custom
import FWGL.Vector
screenScale :: SF (Input a) M3
screenScale = size >>^ \(x, y) -> scaleMat3 (V2 (2 / fromIntegral x)
(2 / fromIntegral y))
perspective4 :: Float
-> Float
-> Float
-> SF (Input a) M4
perspective4 f n fov =
size >>^ \(w, h) -> perspectiveMat4 f n fov
(fromIntegral w / fromIntegral h)
perspectiveView :: Float
-> Float
-> Float
-> SF (Input a, M4) M4
perspectiveView far near fov =
perspective4 far near fov *** identity
>>^ \(perspMat, viewMat) -> mul4 viewMat perspMat