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

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.

主站蜘蛛池模板: 宜宾市| 宕昌县| 土默特右旗| 丰县| 黄梅县| 甘肃省| 兰溪市| 博兴县| 嵊州市| 浦北县| 仪陇县| 岑溪市| 沁阳市| 北安市| 同心县| 雷波县| 江都市| 张北县| 万盛区| 辰溪县| 龙海市| 晋中市| 横山县| 当阳市| 邢台市| 衡阳县| 治多县| 金溪县| 资源县| 深水埗区| 永丰县| 江北区| 泸西县| 鄂伦春自治旗| 隆昌县| 夏河县| 肃宁县| 伊金霍洛旗| 平和县| 新宁县| 阳谷县|