opengl - Replicating GLM::perspective in code -


i'm having trouble understanding glm::perspective. know does, don't understand mechanism. know source code / procedure is?

it's open-source. @ the code:

template <typename valtype> glm_func_qualifier detail::tmat4x4<valtype, defaultp> perspective (     valtype const & fovy,     valtype const & aspect,     valtype const & znear,     valtype const & zfar ) {     assert(aspect != valtype(0));     assert(zfar != znear);  #ifdef glm_force_radians     valtype const rad = fovy; #else #   pragma message("glm: perspective function taking degrees parameter deprecated.     #define glm_force_radians before including glm headers remove message.")     valtype const rad = glm::radians(fovy); #endif      valtype tanhalffovy = tan(rad / valtype(2));      detail::tmat4x4<valtype, defaultp> result(valtype(0));     result[0][0] = valtype(1) / (aspect * tanhalffovy);     result[1][1] = valtype(1) / (tanhalffovy);     result[2][2] = - (zfar + znear) / (zfar - znear);     result[2][3] = - valtype(1);     result[3][2] = - (valtype(2) * zfar * znear) / (zfar - znear);     return result; } 

...which creates matrix per gluperspective() documentation.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -