2025-05-21 03:29:47 -07:00
|
|
|
/* Copyright (C) 2025 Wildfire Games.
|
2023-12-02 16:30:12 -08:00
|
|
|
* This file is part of 0 A.D.
|
2009-06-20 09:13:29 -07:00
|
|
|
*
|
2023-12-02 16:30:12 -08:00
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
2009-06-20 09:13:29 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
2023-12-02 16:30:12 -08:00
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
2009-06-20 09:13:29 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-12-02 16:30:12 -08:00
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
2009-06-20 09:13:29 -07:00
|
|
|
*/
|
|
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
|
|
#include "MessageHandler.h"
|
|
|
|
|
|
Remove the Engine threading when using Atlas
MacOS requires some UI-related API calls to happen on the main thread.
There are several SDL functions that call UI-things, and those were,
since #500 / 08b4d96cf2, in a separate thread.
This crashes on Catalina, instead of simply warning (see #5470).
It is not the first time we had such issues, as originally the Engine
was on the main thread and AtlasUI on a separate thread.
That didn't work on MacOS, so the threading was inverted in #500 /
08b4d96cf2, with AtlasUI on the main thread and the Engine in another
thread.
Unfortunately, this still wasn't enough.
This formally unthreads the engine, running it on a wxTimer, to avoid
these issues.
Future work should focus on:
- Further decoupling the simulation from the engine itself, as what
Atlas really needs is a threaded simulation, not a threaded engine.
- Making the simulation itself more threaded
- Making it possible to do tasks asynchronously under Atlas.
Refs #500
Fixes #5470
Differential Revision: https://code.wildfiregames.com/D2752
This was SVN commit r24361.
2020-12-10 01:42:58 -08:00
|
|
|
#include "gui/GUIManager.h"
|
2025-08-08 12:04:43 -07:00
|
|
|
#include "lib/debug.h"
|
2012-01-12 15:32:27 -08:00
|
|
|
#include "lib/external_libraries/libsdl.h"
|
2025-08-08 12:04:43 -07:00
|
|
|
#include "lib/input.h"
|
|
|
|
|
#include "lib/sysdep/os.h"
|
Remove the Engine threading when using Atlas
MacOS requires some UI-related API calls to happen on the main thread.
There are several SDL functions that call UI-things, and those were,
since #500 / 08b4d96cf2, in a separate thread.
This crashes on Catalina, instead of simply warning (see #5470).
It is not the first time we had such issues, as originally the Engine
was on the main thread and AtlasUI on a separate thread.
That didn't work on MacOS, so the threading was inverted in #500 /
08b4d96cf2, with AtlasUI on the main thread and the Engine in another
thread.
Unfortunately, this still wasn't enough.
This formally unthreads the engine, running it on a wxTimer, to avoid
these issues.
Future work should focus on:
- Further decoupling the simulation from the engine itself, as what
Atlas really needs is a threaded simulation, not a threaded engine.
- Making the simulation itself more threaded
- Making it possible to do tasks asynchronously under Atlas.
Refs #500
Fixes #5470
Differential Revision: https://code.wildfiregames.com/D2752
This was SVN commit r24361.
2020-12-10 01:42:58 -08:00
|
|
|
#include "lib/timer.h"
|
2021-12-24 00:02:27 -08:00
|
|
|
#include "ps/CLogger.h"
|
2025-08-08 12:04:43 -07:00
|
|
|
#include "ps/CStr.h"
|
2021-05-15 10:27:01 -07:00
|
|
|
#include "ps/Filesystem.h"
|
2006-04-23 16:14:18 -07:00
|
|
|
#include "ps/GameSetup/Config.h"
|
|
|
|
|
#include "ps/GameSetup/GameSetup.h"
|
2025-08-08 12:04:43 -07:00
|
|
|
#include "ps/Profile.h"
|
|
|
|
|
#include "ps/VideoMode.h"
|
2006-09-22 10:43:00 -07:00
|
|
|
#include "renderer/Renderer.h"
|
2022-01-04 05:29:01 -08:00
|
|
|
#include "renderer/SceneRenderer.h"
|
2025-08-08 12:04:43 -07:00
|
|
|
#include "renderer/backend/IDevice.h"
|
2024-06-27 12:09:30 -07:00
|
|
|
#include "scriptinterface/ScriptInterface.h"
|
2025-08-08 12:04:43 -07:00
|
|
|
#include "tools/atlas/GameInterface/ActorViewer.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/CommandProc.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/GameLoop.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/InputProcessor.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/Messages.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/Shareable.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/SharedTypes.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/View.h"
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2025-08-08 12:04:43 -07:00
|
|
|
#include <SDL.h>
|
|
|
|
|
#include <SDL_error.h>
|
|
|
|
|
#include <SDL_video.h>
|
|
|
|
|
#include <memory>
|
2023-11-23 12:42:18 -08:00
|
|
|
#include <optional>
|
2025-08-08 12:04:43 -07:00
|
|
|
#include <vector>
|
2023-11-23 12:42:18 -08:00
|
|
|
|
2021-06-06 08:31:55 -07:00
|
|
|
#if OS_WIN
|
|
|
|
|
// We don't include wutil header directly to prevent including Windows headers.
|
|
|
|
|
extern void wutil_SetAppWindow(void* hwnd);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace AtlasMessage
|
|
|
|
|
{
|
2023-11-23 12:42:18 -08:00
|
|
|
namespace
|
|
|
|
|
{
|
2021-06-06 08:31:55 -07:00
|
|
|
InputProcessor g_Input;
|
Remove the Engine threading when using Atlas
MacOS requires some UI-related API calls to happen on the main thread.
There are several SDL functions that call UI-things, and those were,
since #500 / 08b4d96cf2, in a separate thread.
This crashes on Catalina, instead of simply warning (see #5470).
It is not the first time we had such issues, as originally the Engine
was on the main thread and AtlasUI on a separate thread.
That didn't work on MacOS, so the threading was inverted in #500 /
08b4d96cf2, with AtlasUI on the main thread and the Engine in another
thread.
Unfortunately, this still wasn't enough.
This formally unthreads the engine, running it on a wxTimer, to avoid
these issues.
Future work should focus on:
- Further decoupling the simulation from the engine itself, as what
Atlas really needs is a threaded simulation, not a threaded engine.
- Making the simulation itself more threaded
- Making it possible to do tasks asynchronously under Atlas.
Refs #500
Fixes #5470
Differential Revision: https://code.wildfiregames.com/D2752
This was SVN commit r24361.
2020-12-10 01:42:58 -08:00
|
|
|
|
|
|
|
|
// This keeps track of the last in-game user input.
|
|
|
|
|
// It is used to throttle FPS to save CPU & GPU.
|
2021-06-06 08:31:55 -07:00
|
|
|
double last_user_activity;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2013-08-20 14:07:42 -07:00
|
|
|
// see comment in GameLoop.cpp about ah_display_error before using INIT_HAVE_DISPLAY_ERROR
|
2021-11-29 10:21:49 -08:00
|
|
|
const int g_InitFlags = INIT_HAVE_VMODE | INIT_NO_GUI;
|
2006-09-02 14:20:25 -07:00
|
|
|
|
2023-11-23 12:42:18 -08:00
|
|
|
// This isn't used directly. When it's emplaced and when it's reset it does mutate `g_Logger`.
|
|
|
|
|
std::optional<FileLogger> g_FileLogger;
|
2024-06-27 12:09:30 -07:00
|
|
|
|
|
|
|
|
std::optional<ScriptInterface> g_ScriptInterface;
|
2023-11-23 12:42:18 -08:00
|
|
|
}
|
|
|
|
|
|
2006-06-02 22:08:32 -07:00
|
|
|
MESSAGEHANDLER(Init)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
2010-10-21 16:44:54 -07:00
|
|
|
g_Quickstart = true;
|
|
|
|
|
|
2023-11-23 12:42:18 -08:00
|
|
|
InitVfs(g_AtlasGameLoop->args);
|
|
|
|
|
g_FileLogger.emplace();
|
|
|
|
|
|
2014-08-25 09:02:40 -07:00
|
|
|
// Mount mods if there are any specified as command line parameters
|
2021-11-29 10:21:49 -08:00
|
|
|
if (!Init(g_AtlasGameLoop->args, g_InitFlags | INIT_MODS| INIT_MODS_PUBLIC))
|
2014-08-25 09:02:40 -07:00
|
|
|
{
|
|
|
|
|
// There are no mods specified on the command line,
|
|
|
|
|
// but there are in the config file, so mount those.
|
2024-03-24 05:45:27 -07:00
|
|
|
ShutdownConfigAndSubsequent();
|
2014-08-25 09:02:40 -07:00
|
|
|
ENSURE(Init(g_AtlasGameLoop->args, g_InitFlags));
|
|
|
|
|
}
|
2010-10-21 16:44:54 -07:00
|
|
|
|
|
|
|
|
// Initialise some graphics state for Atlas.
|
|
|
|
|
// (This must be done after Init loads the config DB,
|
|
|
|
|
// but before the UI constructs its GL canvases.)
|
|
|
|
|
g_VideoMode.InitNonSDL();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-06 08:31:55 -07:00
|
|
|
MESSAGEHANDLER(InitAppWindow)
|
|
|
|
|
{
|
|
|
|
|
#if OS_WIN
|
|
|
|
|
wutil_SetAppWindow(msg->handle);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-19 21:46:24 -08:00
|
|
|
MESSAGEHANDLER(InitSDL)
|
2010-10-21 16:44:54 -07:00
|
|
|
{
|
2007-01-03 07:45:13 -08:00
|
|
|
// When using GLX (Linux), SDL has to load the GL library to find
|
|
|
|
|
// glXGetProcAddressARB before it can load any extensions.
|
|
|
|
|
// When running in Atlas, we skip the SDL video initialisation code
|
|
|
|
|
// which loads the library, and so SDL_GL_GetProcAddress fails (in
|
|
|
|
|
// ogl.cpp importExtensionFunctions).
|
|
|
|
|
// So, make sure it's loaded:
|
|
|
|
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
2021-12-24 00:02:27 -08:00
|
|
|
// wxWidgets doesn't use a proper approach to dynamically load functions and
|
|
|
|
|
// doesn't provide GetProcAddr-like function. Technically we need to call
|
|
|
|
|
// SDL_GL_LoadLibrary inside GL device creation, but that might lead to a
|
|
|
|
|
// crash on Windows because of a wrong order of initialization between SDL
|
|
|
|
|
// and wxWidgets context management. So leave the call as is while it works.
|
|
|
|
|
// Refs:
|
|
|
|
|
// http://trac.wxwidgets.org/ticket/9213
|
|
|
|
|
// http://trac.wxwidgets.org/ticket/9215
|
|
|
|
|
if (SDL_GL_LoadLibrary(nullptr) && g_Logger)
|
|
|
|
|
LOGERROR("SDL failed to load GL library: '%s'", SDL_GetError());
|
2015-02-19 21:46:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MESSAGEHANDLER(InitGraphics)
|
|
|
|
|
{
|
2021-12-14 22:43:41 -08:00
|
|
|
g_VideoMode.CreateBackendDevice(false);
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2022-12-28 22:53:06 -08:00
|
|
|
g_VideoMode.GetBackendDevice()->OnWindowResize(g_xres, g_yres);
|
|
|
|
|
|
2024-06-27 12:09:30 -07:00
|
|
|
g_ScriptInterface.emplace("Engine", "GUIManager", *g_ScriptContext);
|
|
|
|
|
InitGraphics(g_AtlasGameLoop->args, g_InitFlags, {}, *g_ScriptContext, *g_ScriptInterface);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-06-02 22:08:32 -07:00
|
|
|
MESSAGEHANDLER(Shutdown)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
|
|
|
|
// Empty the CommandProc, to get rid of its references to entities before
|
|
|
|
|
// we kill the EntityManager
|
|
|
|
|
GetCommandProc().Destroy();
|
|
|
|
|
|
2012-03-03 15:48:04 -08:00
|
|
|
AtlasView::DestroyViews();
|
|
|
|
|
g_AtlasGameLoop->view = AtlasView::GetView_None();
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2024-03-24 05:45:27 -07:00
|
|
|
ShutdownNetworkAndUI();
|
2024-06-27 12:09:30 -07:00
|
|
|
g_ScriptInterface.reset();
|
2024-03-24 05:45:27 -07:00
|
|
|
ShutdownConfigAndSubsequent();
|
2023-11-23 12:42:18 -08:00
|
|
|
g_FileLogger.reset();
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QUERYHANDLER(Exit)
|
|
|
|
|
{
|
2012-03-03 15:48:04 -08:00
|
|
|
g_AtlasGameLoop->running = false;
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-06-02 22:08:32 -07:00
|
|
|
MESSAGEHANDLER(RenderEnable)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
2017-04-17 01:59:12 -07:00
|
|
|
g_AtlasGameLoop->view->SetEnabled(false);
|
2012-03-03 15:48:04 -08:00
|
|
|
g_AtlasGameLoop->view = AtlasView::GetView(msg->view);
|
2017-04-17 01:59:12 -07:00
|
|
|
g_AtlasGameLoop->view->SetEnabled(true);
|
2006-09-25 18:44:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MESSAGEHANDLER(SetViewParamB)
|
|
|
|
|
{
|
2012-03-03 15:48:04 -08:00
|
|
|
AtlasView* view = AtlasView::GetView(msg->view);
|
2006-09-25 18:44:20 -07:00
|
|
|
view->SetParam(*msg->name, msg->value);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-10 03:53:39 -08:00
|
|
|
MESSAGEHANDLER(SetViewParamI)
|
2011-12-09 21:11:25 -08:00
|
|
|
{
|
2012-03-03 15:48:04 -08:00
|
|
|
AtlasView* view = AtlasView::GetView(msg->view);
|
2011-12-09 21:11:25 -08:00
|
|
|
view->SetParam(*msg->name, msg->value);
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-25 18:44:20 -07:00
|
|
|
MESSAGEHANDLER(SetViewParamC)
|
|
|
|
|
{
|
2012-03-03 15:48:04 -08:00
|
|
|
AtlasView* view = AtlasView::GetView(msg->view);
|
2006-09-25 18:44:20 -07:00
|
|
|
view->SetParam(*msg->name, msg->value);
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
|
|
|
}
|
|
|
|
|
|
2010-05-27 16:31:03 -07:00
|
|
|
MESSAGEHANDLER(SetViewParamS)
|
|
|
|
|
{
|
2012-03-03 15:48:04 -08:00
|
|
|
AtlasView* view = AtlasView::GetView(msg->view);
|
2010-05-27 16:31:03 -07:00
|
|
|
view->SetParam(*msg->name, *msg->value);
|
|
|
|
|
}
|
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
|
|
|
MESSAGEHANDLER(SetActorViewer)
|
|
|
|
|
{
|
2006-09-22 10:43:00 -07:00
|
|
|
if (msg->flushcache)
|
|
|
|
|
{
|
|
|
|
|
// TODO EXTREME DANGER: this'll break horribly if any units remain
|
|
|
|
|
// in existence and use their actors after we've deleted all the actors.
|
|
|
|
|
// (The actor viewer currently only has one unit at a time, so it's
|
|
|
|
|
// alright.)
|
|
|
|
|
// Should replace this with proper actor hot-loading system, or something.
|
|
|
|
|
|
2019-06-03 13:19:53 -07:00
|
|
|
AtlasView::GetView_Actor()->GetActorViewer().SetActor(L"", "", -1);
|
2012-03-03 15:48:04 -08:00
|
|
|
AtlasView::GetView_Actor()->GetActorViewer().UnloadObjects();
|
2007-12-20 12:21:45 -08:00
|
|
|
// vfs_reload_changed_files();
|
2006-09-22 10:43:00 -07:00
|
|
|
}
|
2012-03-03 15:48:04 -08:00
|
|
|
AtlasView::GetView_Actor()->SetSpeedMultiplier(msg->speed);
|
2012-04-16 18:26:24 -07:00
|
|
|
AtlasView::GetView_Actor()->GetActorViewer().SetActor(*msg->id, *msg->animation, msg->playerID);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2007-01-02 10:11:00 -08:00
|
|
|
MESSAGEHANDLER(SetCanvas)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
2011-11-13 04:57:34 -08:00
|
|
|
// Need to set the canvas size before possibly doing any rendering,
|
|
|
|
|
// else we'll get GL errors when trying to render to 0x0
|
|
|
|
|
CVideoMode::UpdateRenderer(msg->width, msg->height);
|
|
|
|
|
|
2012-03-03 15:48:04 -08:00
|
|
|
g_AtlasGameLoop->glCanvas = msg->canvas;
|
|
|
|
|
Atlas_GLSetCurrent(const_cast<void*>(g_AtlasGameLoop->glCanvas));
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGEHANDLER(ResizeScreen)
|
|
|
|
|
{
|
2010-06-03 12:07:59 -07:00
|
|
|
CVideoMode::UpdateRenderer(msg->width, msg->height);
|
2011-08-28 14:10:45 -07:00
|
|
|
|
|
|
|
|
#if OS_MACOSX
|
|
|
|
|
// OS X seems to require this to update the GL canvas
|
2012-03-03 15:48:04 -08:00
|
|
|
Atlas_GLSetCurrent(const_cast<void*>(g_AtlasGameLoop->glCanvas));
|
2011-08-28 14:10:45 -07:00
|
|
|
#endif
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
Remove the Engine threading when using Atlas
MacOS requires some UI-related API calls to happen on the main thread.
There are several SDL functions that call UI-things, and those were,
since #500 / 08b4d96cf2, in a separate thread.
This crashes on Catalina, instead of simply warning (see #5470).
It is not the first time we had such issues, as originally the Engine
was on the main thread and AtlasUI on a separate thread.
That didn't work on MacOS, so the threading was inverted in #500 /
08b4d96cf2, with AtlasUI on the main thread and the Engine in another
thread.
Unfortunately, this still wasn't enough.
This formally unthreads the engine, running it on a wxTimer, to avoid
these issues.
Future work should focus on:
- Further decoupling the simulation from the engine itself, as what
Atlas really needs is a threaded simulation, not a threaded engine.
- Making the simulation itself more threaded
- Making it possible to do tasks asynchronously under Atlas.
Refs #500
Fixes #5470
Differential Revision: https://code.wildfiregames.com/D2752
This was SVN commit r24361.
2020-12-10 01:42:58 -08:00
|
|
|
QUERYHANDLER(RenderLoop)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
const double time = timer_Time();
|
|
|
|
|
static double last_time = time;
|
|
|
|
|
const double realFrameLength = time-last_time;
|
|
|
|
|
last_time = time;
|
|
|
|
|
ENSURE(realFrameLength >= 0.0);
|
|
|
|
|
// TODO: filter out big jumps, e.g. when having done a lot of slow
|
|
|
|
|
// processing in the last frame
|
|
|
|
|
g_AtlasGameLoop->realFrameLength = realFrameLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (g_Input.ProcessInput(g_AtlasGameLoop))
|
|
|
|
|
last_user_activity = timer_Time();
|
|
|
|
|
|
|
|
|
|
msg->timeSinceActivity = timer_Time() - last_user_activity;
|
|
|
|
|
|
|
|
|
|
ReloadChangedFiles();
|
|
|
|
|
|
|
|
|
|
RendererIncrementalLoad();
|
|
|
|
|
|
|
|
|
|
// Pump SDL events (e.g. hotkeys)
|
|
|
|
|
SDL_Event_ ev;
|
|
|
|
|
while (in_poll_priority_event(&ev))
|
|
|
|
|
in_dispatch_event(&ev);
|
|
|
|
|
|
|
|
|
|
if (g_GUI)
|
|
|
|
|
g_GUI->TickObjects();
|
|
|
|
|
|
|
|
|
|
g_AtlasGameLoop->view->Update(g_AtlasGameLoop->realFrameLength);
|
|
|
|
|
|
|
|
|
|
g_AtlasGameLoop->view->Render();
|
|
|
|
|
|
|
|
|
|
if (CProfileManager::IsInitialised())
|
|
|
|
|
g_Profiler.Frame();
|
|
|
|
|
|
|
|
|
|
msg->wantHighFPS = g_AtlasGameLoop->view->WantsHighFramerate();
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
MESSAGEHANDLER(RenderStyle)
|
|
|
|
|
{
|
2022-01-04 05:29:01 -08:00
|
|
|
g_Renderer.GetSceneRenderer().SetTerrainRenderMode(msg->wireframe ? EDGED_FACES : SOLID);
|
|
|
|
|
g_Renderer.GetSceneRenderer().SetWaterRenderMode(msg->wireframe ? EDGED_FACES : SOLID);
|
|
|
|
|
g_Renderer.GetSceneRenderer().SetModelRenderMode(msg->wireframe ? EDGED_FACES : SOLID);
|
|
|
|
|
g_Renderer.GetSceneRenderer().SetOverlayRenderMode(msg->wireframe ? EDGED_FACES : SOLID);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
2021-06-06 08:31:55 -07:00
|
|
|
} // namespace AtlasMessage
|