WVR_GetClippingPlaneBoundary

WVR_EXPORT void WVR_GetClippingPlaneBoundary(WVR_Eye eye, float * left, float * right, float * top, float * bottom)

Function to get the boundary of the clipping plane.

Returns the coordinate of the margin of clipping plane for the specified eye. The necessary information can be used to compose a custom matrix, though most contents should use WVR_GetProjection instead of this method, but sometimes a content needs to do something fancy with its projection and can use these values to compute one.

Parameters
  • eye -

    determines which eye the function should return for corresponding clipping plane.

  • left -

    coordinate for the left margin of the clipping plane.

  • right -

    coordinate for the right margin of the clipping plane.

  • top -

    coordinate for the top margin of the clipping plane.

  • bottom -

    coordinate for the bottom margin of the clipping plane.

How to use

Here is an example for the function:

#include <wvr/wvr_projection.h>

Matrix4 getCustomizedProjection(WVR_Eye nEye) {
    float l, r, t, b, f, n;
    WVR_GetClippingPlaneBoundary(nEye, &l, &r, &t, &b);
    f = 1.0f;
    n = 0.01f;
    float r_l = r-l;
    float t_b = b-t;
    float f_n = f-n;

    Matrix4 mat(
        2/r_l,    0,        0,        0,
        0,        2/t_b,    0,        0,
        0,        0,        -2/f_n,   0,
        r+l/-r_l, t+b/-t_b, f+n/-f_n, 1
    );

    int i = 0;
    return mat;
}