Skip to content

Commit

Permalink
Revert "Android: Pause rendering while the app is paused (luanti-org#…
Browse files Browse the repository at this point in the history
…14058)"

This reverts commit 00d9d96.
  • Loading branch information
grorp committed Jan 18, 2024
1 parent a8cf10b commit c892b04
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 68 deletions.
63 changes: 29 additions & 34 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4108,6 +4108,31 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
*/
client->getParticleManager()->step(dtime);

/*
Fog
*/
if (m_cache_enable_fog) {
driver->setFog(
sky->getBgColor(),
video::EFT_FOG_LINEAR,
runData.fog_range * sky->getFogStart(),
runData.fog_range * 1.0,
0.01,
false, // pixel fog
true // range fog
);
} else {
driver->setFog(
sky->getBgColor(),
video::EFT_FOG_LINEAR,
100000 * BS,
110000 * BS,
0.01f,
false, // pixel fog
false // range fog
);
}

/*
Damage camera tilt
*/
Expand Down Expand Up @@ -4207,8 +4232,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
/*
==================== Drawing begins ====================
*/
if (RenderingEngine::shouldRender())
drawScene(graph, stats);
drawScene(graph, stats);
/*
==================== End scene ====================
*/
Expand Down Expand Up @@ -4288,39 +4312,10 @@ void Game::updateShadows()

void Game::drawScene(ProfilerGraph *graph, RunStats *stats)
{
const video::SColor bg_color = this->sky->getBgColor();
const video::SColor sky_color = this->sky->getSkyColor();
const video::SColor skycolor = this->sky->getSkyColor();

/*
Fog
*/
if (this->m_cache_enable_fog) {
this->driver->setFog(
bg_color,
video::EFT_FOG_LINEAR,
this->runData.fog_range * this->sky->getFogStart(),
this->runData.fog_range * 1.0f,
0.01f,
false, // pixel fog
true // range fog
);
} else {
this->driver->setFog(
bg_color,
video::EFT_FOG_LINEAR,
100000 * BS,
110000 * BS,
0.01f,
false, // pixel fog
false // range fog
);
}

/*
Drawing
*/
TimeTaker tt_draw("Draw scene", nullptr, PRECISION_MICRO);
this->driver->beginScene(true, true, sky_color);
this->driver->beginScene(true, true, skycolor);

const LocalPlayer *player = this->client->getEnv().getLocalPlayer();
bool draw_wield_tool = (this->m_game_ui->m_flags.show_hud &&
Expand All @@ -4333,7 +4328,7 @@ void Game::drawScene(ProfilerGraph *graph, RunStats *stats)
if (this->isNoCrosshairAllowed())
draw_crosshair = false;
#endif
this->m_rendering_engine->draw_scene(sky_color, this->m_game_ui->m_flags.show_hud,
this->m_rendering_engine->draw_scene(skycolor, this->m_game_ui->m_flags.show_hud,
this->m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair);

/*
Expand Down
11 changes: 0 additions & 11 deletions src/client/renderingengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,6 @@ class RenderingEngine
const irr::core::dimension2d<u32> initial_screen_size,
const bool initial_window_maximized);

static bool shouldRender()
{
// On Android, pause rendering while the app is in background (generally not visible).
// Don't do this on desktop because windows can be partially visible.
#ifdef __ANDROID__
return get_raw_device()->isWindowActive();
#else
return true;
#endif
};

private:
v2u32 _getWindowSize() const;

Expand Down
45 changes: 22 additions & 23 deletions src/gui/guiEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,35 +265,34 @@ void GUIEngine::run()
f32 dtime = 0.0f;

while (m_rendering_engine->run() && (!m_startgame) && (!m_kill)) {
if (RenderingEngine::shouldRender()) {
// check if we need to update the "upper left corner"-text
if (text_height != g_fontengine->getTextHeight()) {
updateTopLeftTextSize();
text_height = g_fontengine->getTextHeight();
}

driver->beginScene(true, true, RenderingEngine::MENU_SKY_COLOR);
//check if we need to update the "upper left corner"-text
if (text_height != g_fontengine->getTextHeight()) {
updateTopLeftTextSize();
text_height = g_fontengine->getTextHeight();
}

if (m_clouds_enabled)
{
cloudPreProcess();
drawOverlay(driver);
}
else
drawBackground(driver);
driver->beginScene(true, true, RenderingEngine::MENU_SKY_COLOR);

if (m_clouds_enabled)
{
cloudPreProcess();
drawOverlay(driver);
}
else
drawBackground(driver);

drawFooter(driver);
drawFooter(driver);

m_rendering_engine->get_gui_env()->drawAll();
m_rendering_engine->get_gui_env()->drawAll();

// The header *must* be drawn after the menu because it uses
// GUIFormspecMenu::getAbsoluteRect().
// The header *can* be drawn after the menu because it never intersects
// the menu.
drawHeader(driver);
// The header *must* be drawn after the menu because it uses
// GUIFormspecMenu::getAbsoluteRect().
// The header *can* be drawn after the menu because it never intersects
// the menu.
drawHeader(driver);

driver->endScene();
}
driver->endScene();

IrrlichtDevice *device = m_rendering_engine->get_raw_device();

Expand Down

0 comments on commit c892b04

Please sign in to comment.