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

Function g3_StartFrame

renderer/HardwareSetup.cpp:87–147  ·  view source on GitHub ↗

start the frame

Source from the content-addressed store, hash-verified

85
86// start the frame
87void 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

Callers 11

UpdateRobotViewMethod · 0.85
StartEditorFrameFunction · 0.85
UpdatePowerupViewMethod · 0.85
GameRenderWorldFunction · 0.85
GameDrawHudFunction · 0.85
OnDrawMethod · 0.85
SGSSnapshotFunction · 0.85
TCSSSCallbackFunction · 0.85
GetCockpitWindowCoordsFunction · 0.85
DrawSmallViewsFunction · 0.85
TCAMCallbackFunction · 0.85

Calls 8

g3_GetViewPortMatrixFunction · 0.85
g3_GetProjectionMatrixFunction · 0.85
g3_GetModelViewMatrixFunction · 0.85
g3_UpdateFullTransformFunction · 0.85
InitFreePointsFunction · 0.85
g3_ResetFarClipZFunction · 0.85
rend_GetAspectRatioFunction · 0.70

Tested by

no test coverage detected