123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 |
- namespace glm
- {
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> ortho(T left, T right, T bottom, T top)
- {
- mat<4, 4, T, defaultp> Result(static_cast<T>(1));
- Result[0][0] = static_cast<T>(2) / (right - left);
- Result[1][1] = static_cast<T>(2) / (top - bottom);
- Result[2][2] = - static_cast<T>(1);
- Result[3][0] = - (right + left) / (right - left);
- Result[3][1] = - (top + bottom) / (top - bottom);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH_ZO(T left, T right, T bottom, T top, T zNear, T zFar)
- {
- mat<4, 4, T, defaultp> Result(1);
- Result[0][0] = static_cast<T>(2) / (right - left);
- Result[1][1] = static_cast<T>(2) / (top - bottom);
- Result[2][2] = static_cast<T>(1) / (zFar - zNear);
- Result[3][0] = - (right + left) / (right - left);
- Result[3][1] = - (top + bottom) / (top - bottom);
- Result[3][2] = - zNear / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH_NO(T left, T right, T bottom, T top, T zNear, T zFar)
- {
- mat<4, 4, T, defaultp> Result(1);
- Result[0][0] = static_cast<T>(2) / (right - left);
- Result[1][1] = static_cast<T>(2) / (top - bottom);
- Result[2][2] = static_cast<T>(2) / (zFar - zNear);
- Result[3][0] = - (right + left) / (right - left);
- Result[3][1] = - (top + bottom) / (top - bottom);
- Result[3][2] = - (zFar + zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH_ZO(T left, T right, T bottom, T top, T zNear, T zFar)
- {
- mat<4, 4, T, defaultp> Result(1);
- Result[0][0] = static_cast<T>(2) / (right - left);
- Result[1][1] = static_cast<T>(2) / (top - bottom);
- Result[2][2] = - static_cast<T>(1) / (zFar - zNear);
- Result[3][0] = - (right + left) / (right - left);
- Result[3][1] = - (top + bottom) / (top - bottom);
- Result[3][2] = - zNear / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH_NO(T left, T right, T bottom, T top, T zNear, T zFar)
- {
- mat<4, 4, T, defaultp> Result(1);
- Result[0][0] = static_cast<T>(2) / (right - left);
- Result[1][1] = static_cast<T>(2) / (top - bottom);
- Result[2][2] = - static_cast<T>(2) / (zFar - zNear);
- Result[3][0] = - (right + left) / (right - left);
- Result[3][1] = - (top + bottom) / (top - bottom);
- Result[3][2] = - (zFar + zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoZO(T left, T right, T bottom, T top, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
- return orthoLH_ZO(left, right, bottom, top, zNear, zFar);
- # else
- return orthoRH_ZO(left, right, bottom, top, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoNO(T left, T right, T bottom, T top, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
- return orthoLH_NO(left, right, bottom, top, zNear, zFar);
- # else
- return orthoRH_NO(left, right, bottom, top, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH(T left, T right, T bottom, T top, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
- return orthoLH_ZO(left, right, bottom, top, zNear, zFar);
- # else
- return orthoLH_NO(left, right, bottom, top, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH(T left, T right, T bottom, T top, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
- return orthoRH_ZO(left, right, bottom, top, zNear, zFar);
- # else
- return orthoRH_NO(left, right, bottom, top, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> ortho(T left, T right, T bottom, T top, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO
- return orthoLH_ZO(left, right, bottom, top, zNear, zFar);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO
- return orthoLH_NO(left, right, bottom, top, zNear, zFar);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO
- return orthoRH_ZO(left, right, bottom, top, zNear, zFar);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO
- return orthoRH_NO(left, right, bottom, top, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH_ZO(T left, T right, T bottom, T top, T nearVal, T farVal)
- {
- mat<4, 4, T, defaultp> Result(0);
- Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
- Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
- Result[2][0] = (right + left) / (right - left);
- Result[2][1] = (top + bottom) / (top - bottom);
- Result[2][2] = farVal / (farVal - nearVal);
- Result[2][3] = static_cast<T>(1);
- Result[3][2] = -(farVal * nearVal) / (farVal - nearVal);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH_NO(T left, T right, T bottom, T top, T nearVal, T farVal)
- {
- mat<4, 4, T, defaultp> Result(0);
- Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
- Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
- Result[2][0] = (right + left) / (right - left);
- Result[2][1] = (top + bottom) / (top - bottom);
- Result[2][2] = (farVal + nearVal) / (farVal - nearVal);
- Result[2][3] = static_cast<T>(1);
- Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH_ZO(T left, T right, T bottom, T top, T nearVal, T farVal)
- {
- mat<4, 4, T, defaultp> Result(0);
- Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
- Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
- Result[2][0] = (right + left) / (right - left);
- Result[2][1] = (top + bottom) / (top - bottom);
- Result[2][2] = farVal / (nearVal - farVal);
- Result[2][3] = static_cast<T>(-1);
- Result[3][2] = -(farVal * nearVal) / (farVal - nearVal);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH_NO(T left, T right, T bottom, T top, T nearVal, T farVal)
- {
- mat<4, 4, T, defaultp> Result(0);
- Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
- Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
- Result[2][0] = (right + left) / (right - left);
- Result[2][1] = (top + bottom) / (top - bottom);
- Result[2][2] = - (farVal + nearVal) / (farVal - nearVal);
- Result[2][3] = static_cast<T>(-1);
- Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumZO(T left, T right, T bottom, T top, T nearVal, T farVal)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
- return frustumLH_ZO(left, right, bottom, top, nearVal, farVal);
- # else
- return frustumRH_ZO(left, right, bottom, top, nearVal, farVal);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumNO(T left, T right, T bottom, T top, T nearVal, T farVal)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
- return frustumLH_NO(left, right, bottom, top, nearVal, farVal);
- # else
- return frustumRH_NO(left, right, bottom, top, nearVal, farVal);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH(T left, T right, T bottom, T top, T nearVal, T farVal)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
- return frustumLH_ZO(left, right, bottom, top, nearVal, farVal);
- # else
- return frustumLH_NO(left, right, bottom, top, nearVal, farVal);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH(T left, T right, T bottom, T top, T nearVal, T farVal)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
- return frustumRH_ZO(left, right, bottom, top, nearVal, farVal);
- # else
- return frustumRH_NO(left, right, bottom, top, nearVal, farVal);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustum(T left, T right, T bottom, T top, T nearVal, T farVal)
- {
- # if GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO
- return frustumLH_ZO(left, right, bottom, top, nearVal, farVal);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO
- return frustumLH_NO(left, right, bottom, top, nearVal, farVal);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO
- return frustumRH_ZO(left, right, bottom, top, nearVal, farVal);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO
- return frustumRH_NO(left, right, bottom, top, nearVal, farVal);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH_ZO(T fovy, T aspect, T zNear, T zFar)
- {
- assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
- T const tanHalfFovy = tan(fovy / static_cast<T>(2));
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
- Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
- Result[2][2] = zFar / (zNear - zFar);
- Result[2][3] = - static_cast<T>(1);
- Result[3][2] = -(zFar * zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH_NO(T fovy, T aspect, T zNear, T zFar)
- {
- assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
- T const tanHalfFovy = tan(fovy / static_cast<T>(2));
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
- Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
- Result[2][2] = - (zFar + zNear) / (zFar - zNear);
- Result[2][3] = - static_cast<T>(1);
- Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH_ZO(T fovy, T aspect, T zNear, T zFar)
- {
- assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
- T const tanHalfFovy = tan(fovy / static_cast<T>(2));
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
- Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
- Result[2][2] = zFar / (zFar - zNear);
- Result[2][3] = static_cast<T>(1);
- Result[3][2] = -(zFar * zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH_NO(T fovy, T aspect, T zNear, T zFar)
- {
- assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
- T const tanHalfFovy = tan(fovy / static_cast<T>(2));
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
- Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
- Result[2][2] = (zFar + zNear) / (zFar - zNear);
- Result[2][3] = static_cast<T>(1);
- Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveZO(T fovy, T aspect, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
- return perspectiveLH_ZO(fovy, aspect, zNear, zFar);
- # else
- return perspectiveRH_ZO(fovy, aspect, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveNO(T fovy, T aspect, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
- return perspectiveLH_NO(fovy, aspect, zNear, zFar);
- # else
- return perspectiveRH_NO(fovy, aspect, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH(T fovy, T aspect, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
- return perspectiveLH_ZO(fovy, aspect, zNear, zFar);
- # else
- return perspectiveLH_NO(fovy, aspect, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH(T fovy, T aspect, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
- return perspectiveRH_ZO(fovy, aspect, zNear, zFar);
- # else
- return perspectiveRH_NO(fovy, aspect, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspective(T fovy, T aspect, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO
- return perspectiveLH_ZO(fovy, aspect, zNear, zFar);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO
- return perspectiveLH_NO(fovy, aspect, zNear, zFar);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO
- return perspectiveRH_ZO(fovy, aspect, zNear, zFar);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO
- return perspectiveRH_NO(fovy, aspect, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH_ZO(T fov, T width, T height, T zNear, T zFar)
- {
- assert(width > static_cast<T>(0));
- assert(height > static_cast<T>(0));
- assert(fov > static_cast<T>(0));
- T const rad = fov;
- T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
- T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = w;
- Result[1][1] = h;
- Result[2][2] = zFar / (zNear - zFar);
- Result[2][3] = - static_cast<T>(1);
- Result[3][2] = -(zFar * zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH_NO(T fov, T width, T height, T zNear, T zFar)
- {
- assert(width > static_cast<T>(0));
- assert(height > static_cast<T>(0));
- assert(fov > static_cast<T>(0));
- T const rad = fov;
- T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
- T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = w;
- Result[1][1] = h;
- Result[2][2] = - (zFar + zNear) / (zFar - zNear);
- Result[2][3] = - static_cast<T>(1);
- Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH_ZO(T fov, T width, T height, T zNear, T zFar)
- {
- assert(width > static_cast<T>(0));
- assert(height > static_cast<T>(0));
- assert(fov > static_cast<T>(0));
- T const rad = fov;
- T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
- T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = w;
- Result[1][1] = h;
- Result[2][2] = zFar / (zFar - zNear);
- Result[2][3] = static_cast<T>(1);
- Result[3][2] = -(zFar * zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH_NO(T fov, T width, T height, T zNear, T zFar)
- {
- assert(width > static_cast<T>(0));
- assert(height > static_cast<T>(0));
- assert(fov > static_cast<T>(0));
- T const rad = fov;
- T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
- T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = w;
- Result[1][1] = h;
- Result[2][2] = (zFar + zNear) / (zFar - zNear);
- Result[2][3] = static_cast<T>(1);
- Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovZO(T fov, T width, T height, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
- return perspectiveFovLH_ZO(fov, width, height, zNear, zFar);
- # else
- return perspectiveFovRH_ZO(fov, width, height, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovNO(T fov, T width, T height, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
- return perspectiveFovLH_NO(fov, width, height, zNear, zFar);
- # else
- return perspectiveFovRH_NO(fov, width, height, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH(T fov, T width, T height, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
- return perspectiveFovLH_ZO(fov, width, height, zNear, zFar);
- # else
- return perspectiveFovLH_NO(fov, width, height, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH(T fov, T width, T height, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
- return perspectiveFovRH_ZO(fov, width, height, zNear, zFar);
- # else
- return perspectiveFovRH_NO(fov, width, height, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFov(T fov, T width, T height, T zNear, T zFar)
- {
- # if GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO
- return perspectiveFovLH_ZO(fov, width, height, zNear, zFar);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO
- return perspectiveFovLH_NO(fov, width, height, zNear, zFar);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO
- return perspectiveFovRH_ZO(fov, width, height, zNear, zFar);
- # elif GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO
- return perspectiveFovRH_NO(fov, width, height, zNear, zFar);
- # endif
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveRH(T fovy, T aspect, T zNear)
- {
- T const range = tan(fovy / static_cast<T>(2)) * zNear;
- T const left = -range * aspect;
- T const right = range * aspect;
- T const bottom = -range;
- T const top = range;
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
- Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
- Result[2][2] = - static_cast<T>(1);
- Result[2][3] = - static_cast<T>(1);
- Result[3][2] = - static_cast<T>(2) * zNear;
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveLH(T fovy, T aspect, T zNear)
- {
- T const range = tan(fovy / static_cast<T>(2)) * zNear;
- T const left = -range * aspect;
- T const right = range * aspect;
- T const bottom = -range;
- T const top = range;
- mat<4, 4, T, defaultp> Result(T(0));
- Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
- Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
- Result[2][2] = static_cast<T>(1);
- Result[2][3] = static_cast<T>(1);
- Result[3][2] = - static_cast<T>(2) * zNear;
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspective(T fovy, T aspect, T zNear)
- {
- # if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
- return infinitePerspectiveLH(fovy, aspect, zNear);
- # else
- return infinitePerspectiveRH(fovy, aspect, zNear);
- # endif
- }
- // Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear, T ep)
- {
- T const range = tan(fovy / static_cast<T>(2)) * zNear;
- T const left = -range * aspect;
- T const right = range * aspect;
- T const bottom = -range;
- T const top = range;
- mat<4, 4, T, defaultp> Result(static_cast<T>(0));
- Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
- Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
- Result[2][2] = ep - static_cast<T>(1);
- Result[2][3] = static_cast<T>(-1);
- Result[3][2] = (ep - static_cast<T>(2)) * zNear;
- return Result;
- }
- template<typename T>
- GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear)
- {
- return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon<T>());
- }
- }//namespace glm
|