官术网_书友最值得收藏!

Orthographic

An orthographic projection has no perspective to it. An orthographic projection maps linearly to NDC space. Orthographic projections are often used for two-dimensional games. It's often used to achieve an isometric perspective.

Implement the ortho function in mat4.cpp. Don't forget to add the function declaration to mat4.h:

mat4 ortho(float l, float r, float b, float t,

           float n, float f) {

    if (l == r || t == b || n == f) {

        return mat4(); // Error

    }

    return mat4(

        2.0f / (r - l), 0, 0, 0,

        0, 2.0f / (t - b), 0, 0,

        0, 0, -2.0f / (f - n), 0,

        -((r+l)/(r-l)),-((t+b)/(t-b)),-((f+n)/(f-n)), 1

    );

}

Orthographic view projections are generally useful for displaying UI or other two-dimensional elements.

主站蜘蛛池模板: 东乡县| 昭平县| 资阳市| 新安县| 奉新县| 黎川县| 新蔡县| 镇雄县| 巧家县| 永德县| 聂拉木县| 本溪| 垦利县| 惠来县| 石渠县| 桂东县| 钟山县| 汝州市| 华蓥市| 许昌县| 南乐县| 云和县| 康保县| 高台县| 随州市| 绥宁县| 武义县| 芷江| 石渠县| 乌兰察布市| 景谷| 水城县| 辽阳县| 麻江县| 石楼县| 芦山县| 南宫市| 韶山市| 石泉县| 朝阳县| 襄樊市|