| 57 | } |
| 58 | |
| 59 | void 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 |
| 87 | void g3_StartFrame(vector *view_pos, matrix *view_matrix, float zoom) { |
no test coverage detected