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

Function RenderTerrain

Descent3/terrainrender.cpp:1308–1434  ·  view source on GitHub ↗

left,top,right,bot are optional parameters. Omiting them (or setting them to -1) will render to the whole screen. Passing valid values will only render tiles visible in the specified window (though it won't clip those tiles to the window)

Source from the content-addressed store, hash-verified

1306// render to the whole screen. Passing valid values will only render tiles visible in the
1307// specified window (though it won't clip those tiles to the window)
1308void RenderTerrain(uint8_t from_mine, int left, int top, int right, int bot) {
1309 static int first = 1;
1310 if (first) {
1311 InitTerrainRenderSpeedups();
1312 first = 0;
1313 }
1314
1315 // Get the size of the current render window
1316 int render_width, render_height;
1317 rend_GetProjectionParameters(&render_width, &render_height);
1318 float w2 = ((float)render_width - 1) / 2.0f;
1319 float h2 = ((float)render_height - 1) / 2.0f;
1320
1321 // Set up vars for (psuedo-)clipping window
1322 if (left < 0) {
1323 Check_terrain_portal = 0;
1324 left = 0;
1325 } else {
1326 int w = right - left;
1327 int h = bot - top;
1328
1329 // If the portal takes up more than 50% the screen space then we don't check against it
1330 float threshold = (render_width * render_height) * 0.5f;
1331 if (w * h > threshold) {
1332 Check_terrain_portal = 0;
1333 } else {
1334 Check_terrain_portal = 1;
1335 }
1336 }
1337
1338 if (top < 0) {
1339 top = 0;
1340 }
1341 if ((right == -1) || right > render_width)
1342 right = render_width - 1;
1343 if ((bot == -1) || bot > render_height)
1344 bot = render_height - 1;
1345 Clip_scale_left = left;
1346 Clip_scale_right = right;
1347 Clip_scale_top = top;
1348 Clip_scale_bot = bot;
1349 if (!Terrain_sky.textured) {
1350 rend_FillRect(Terrain_sky.sky_color, left, top, right + 1, bot + 1);
1351 }
1352
1353 rend_SetFlatColor(Terrain_sky.sky_color);
1354 View_mode = GetFunctionMode();
1355
1356 // Set this so we don't do reentrant rendering between terrain/mine
1357 Terrain_from_mine = from_mine;
1358
1359#ifndef NEWEDITOR
1360 // See if we're supposed change the fog plane distance based on our framerate
1361 if (View_mode != EDITOR_MODE && ManageFramerate) {
1362 float fps = GetFPS();
1363 if (fps < MinAllowableFramerate) {
1364 if (Detail_settings.Terrain_render_distance > TERRAIN_SIZE) {
1365 Detail_settings.Terrain_render_distance -= (float)(TERRAIN_SIZE / 4);

Callers 5

RenderMethod · 0.85
OnLButtonDownMethod · 0.85
OnRButtonDownMethod · 0.85
GameRenderWorldFunction · 0.85
RenderMineFunction · 0.85

Calls 15

GetFunctionModeFunction · 0.85
GetFPSFunction · 0.85
g3_SetFarClipZFunction · 0.85
g3_GetViewPositionFunction · 0.85
g3_GetViewMatrixFunction · 0.85
GetVisibleTerrainFunction · 0.85
DrawSkyFunction · 0.85
DisplayTerrainListFunction · 0.85
RenderTerrainRoomsFunction · 0.85
RenderAllTerrainObjectsFunction · 0.85

Tested by

no test coverage detected