start the frame
| 85 | |
| 86 | // start the frame |
| 87 | void g3_StartFrame(vector *view_pos, matrix *view_matrix, float zoom) { |
| 88 | // initialize the viewport transform |
| 89 | g3_GetViewPortMatrix((float *)gTransformViewPort); |
| 90 | g3_GetProjectionMatrix(zoom, (float *)gTransformProjection); |
| 91 | g3_GetModelViewMatrix(view_pos, view_matrix, (float *)gTransformModelView); |
| 92 | g3_UpdateFullTransform(); |
| 93 | |
| 94 | // get window size |
| 95 | rend_GetProjectionParameters(&Window_width, &Window_height); |
| 96 | |
| 97 | // Set vars for projection |
| 98 | Window_w2 = ((float)Window_width) * 0.5f; |
| 99 | Window_h2 = ((float)Window_height) * 0.5f; |
| 100 | |
| 101 | // Compute aspect ratio for this window |
| 102 | float screen_aspect = rend_GetAspectRatio(); |
| 103 | if (sAspect != 0.0f) { |
| 104 | // check for user override |
| 105 | screen_aspect = screen_aspect * 4.0f / 3.0f / sAspect; |
| 106 | } |
| 107 | float s = screen_aspect * (float)Window_height / (float)Window_width; |
| 108 | |
| 109 | if (s <= 0.0f) // JEFF: Should this have been 1.0f? |
| 110 | { |
| 111 | // scale x |
| 112 | Matrix_scale.x = s; |
| 113 | Matrix_scale.y = 1.0f; |
| 114 | } else { |
| 115 | Matrix_scale.y = 1.0f / s; |
| 116 | Matrix_scale.x = 1.0f; |
| 117 | } |
| 118 | |
| 119 | Matrix_scale.z = 1.0f; |
| 120 | |
| 121 | // Set the view variables |
| 122 | View_position = *view_pos; |
| 123 | View_zoom = zoom; |
| 124 | Unscaled_matrix = *view_matrix; |
| 125 | |
| 126 | // Compute matrix scale for zoom and aspect ratio |
| 127 | if (View_zoom <= 1.0f) { |
| 128 | // zoom in by scaling z |
| 129 | Matrix_scale.z = Matrix_scale.z * View_zoom; |
| 130 | } else { |
| 131 | // zoom out by scaling x and y |
| 132 | float oOZ = 1.0f / View_zoom; |
| 133 | Matrix_scale.x = Matrix_scale.x * oOZ; |
| 134 | Matrix_scale.y = Matrix_scale.y * oOZ; |
| 135 | } |
| 136 | |
| 137 | // Scale the matrix elements |
| 138 | View_matrix.rvec = Unscaled_matrix.rvec * Matrix_scale.x; |
| 139 | View_matrix.uvec = Unscaled_matrix.uvec * Matrix_scale.y; |
| 140 | View_matrix.fvec = Unscaled_matrix.fvec * Matrix_scale.z; |
| 141 | |
| 142 | // Reset the list of free points |
| 143 | InitFreePoints(); |
| 144 |
no test coverage detected