MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / g3_GetProjectionMatrix

Function g3_GetProjectionMatrix

renderer/HardwareSetup.cpp:59–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void g3_GetProjectionMatrix(float zoom, float *projMat) {
60 // get window size
61 int viewportWidth, viewportHeight;
62 rend_GetProjectionParameters(&viewportWidth, &viewportHeight);
63
64 // compute aspect ratio for this ViewPort
65 float screenAspect = rend_GetAspectRatio();
66 if (sAspect != 0.0f) {
67 // check for user override
68 screenAspect = screenAspect * 4.0f / 3.0f / sAspect;
69 }
70 float s = screenAspect * ((float)viewportWidth) / ((float)viewportHeight);
71
72 // setup the matrix
73 memset(projMat, 0, sizeof(float) * 16);
74
75 // calculate 1/tan(fov)
76 float oOT = 1.0f / zoom;
77
78 // fill in the matrix
79 projMat[0] = oOT;
80 projMat[5] = oOT * s;
81 projMat[10] = 1.0f;
82 projMat[11] = 1.0f;
83 projMat[14] = -1.0f;
84}
85
86// start the frame
87void g3_StartFrame(vector *view_pos, matrix *view_matrix, float zoom) {

Callers 1

g3_StartFrameFunction · 0.85

Calls 2

rend_GetAspectRatioFunction · 0.70

Tested by

no test coverage detected