Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp
Show All 16 Lines | |||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "MessageHandler.h" | #include "MessageHandler.h" | ||||
#include "../GameLoop.h" | #include "../GameLoop.h" | ||||
#include "../CommandProc.h" | #include "../CommandProc.h" | ||||
#include "../ActorViewer.h" | #include "../ActorViewer.h" | ||||
#include "../View.h" | #include "../View.h" | ||||
#include "../InputProcessor.h" | |||||
#include "graphics/GameView.h" | #include "graphics/GameView.h" | ||||
#include "graphics/ObjectManager.h" | #include "graphics/ObjectManager.h" | ||||
#include "gui/GUIManager.h" | |||||
#include "lib/external_libraries/libsdl.h" | #include "lib/external_libraries/libsdl.h" | ||||
#include "lib/ogl.h" | #include "lib/ogl.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "ps/CConsole.h" | #include "ps/CConsole.h" | ||||
#include "ps/Game.h" | #include "ps/Game.h" | ||||
#include "ps/VideoMode.h" | #include "ps/VideoMode.h" | ||||
#include "ps/GameSetup/Config.h" | #include "ps/GameSetup/Config.h" | ||||
#include "ps/GameSetup/GameSetup.h" | #include "ps/GameSetup/GameSetup.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
static InputProcessor g_Input; | |||||
// This keeps track of the last in-game user input. | |||||
// It is used to throttle FPS to save CPU & GPU. | |||||
static double last_user_activity; | |||||
namespace AtlasMessage { | namespace AtlasMessage { | ||||
// see comment in GameLoop.cpp about ah_display_error before using INIT_HAVE_DISPLAY_ERROR | // see comment in GameLoop.cpp about ah_display_error before using INIT_HAVE_DISPLAY_ERROR | ||||
const int g_InitFlags = INIT_HAVE_VMODE|INIT_NO_GUI; | const int g_InitFlags = INIT_HAVE_VMODE|INIT_NO_GUI; | ||||
MESSAGEHANDLER(Init) | MESSAGEHANDLER(Init) | ||||
{ | { | ||||
UNUSED2(msg); | UNUSED2(msg); | ||||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | MESSAGEHANDLER(ResizeScreen) | ||||
CVideoMode::UpdateRenderer(msg->width, msg->height); | CVideoMode::UpdateRenderer(msg->width, msg->height); | ||||
#if OS_MACOSX | #if OS_MACOSX | ||||
// OS X seems to require this to update the GL canvas | // OS X seems to require this to update the GL canvas | ||||
Atlas_GLSetCurrent(const_cast<void*>(g_AtlasGameLoop->glCanvas)); | Atlas_GLSetCurrent(const_cast<void*>(g_AtlasGameLoop->glCanvas)); | ||||
#endif | #endif | ||||
} | } | ||||
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(); | |||||
} | |||||
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// | ||||
MESSAGEHANDLER(RenderStyle) | MESSAGEHANDLER(RenderStyle) | ||||
{ | { | ||||
g_Renderer.SetTerrainRenderMode(msg->wireframe ? EDGED_FACES : SOLID); | g_Renderer.SetTerrainRenderMode(msg->wireframe ? EDGED_FACES : SOLID); | ||||
g_Renderer.SetWaterRenderMode(msg->wireframe ? EDGED_FACES : SOLID); | g_Renderer.SetWaterRenderMode(msg->wireframe ? EDGED_FACES : SOLID); | ||||
g_Renderer.SetModelRenderMode(msg->wireframe ? EDGED_FACES : SOLID); | g_Renderer.SetModelRenderMode(msg->wireframe ? EDGED_FACES : SOLID); | ||||
} | } | ||||
} | } |
Wildfire Games · Phabricator