CSharpGL.glm.perspective C# (CSharp) Method

perspective() public static method

Creates a perspective transformation matrix.
public static perspective ( float fovy, float aspect, float zNear, float zFar ) : CSharpGL.mat4
fovy float The field of view angle, in radians.
aspect float The aspect ratio.
zNear float The near depth clipping plane.
zFar float The far depth clipping plane.
return CSharpGL.mat4
        public static mat4 perspective(float fovy, float aspect, float zNear, float zFar)
        {
            float tangent = (float)Math.Tan(fovy / 2.0f);
            float height = zNear * tangent;
            float width = height * aspect;

            float left = -width, right = width, bottom = -height, top = height, near = zNear, far = zFar;

            mat4 result = frustum(left, right, bottom, top, near, far);

            return result;
        }