Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
AppContext.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5 Copyright 2013-2020 Petr Ohlidal
6
7 For more information, see http://www.rigsofrods.org/
8
9 Rigs of Rods is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 3, as
11 published by the Free Software Foundation.
12
13 Rigs of Rods is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20*/
21
26
27#pragma once
28
29#include "Application.h"
30#include "ForceFeedback.h"
31
32#include <Bites/OgreWindowEventUtilities.h>
33#include <Ogre.h>
34#include <OIS.h>
35
36namespace RoR {
37
40
43class AppContext: public OgreBites::WindowEventListener,
44 public OIS::MouseListener,
45 public OIS::KeyListener,
46 public OIS::JoyStickListener
47{
48public:
49 // Startup (in order)
50 void SetUpThreads();
51 bool SetUpProgramPaths();
52 void SetUpLogging();
53 bool SetUpResourcesDir();
54 bool SetUpRendering();
56 bool SetUpInput();
58
59 // Rendering
60 Ogre::RenderWindow* CreateCustomRenderWindow(std::string const& name, int width, int height);
61 void CaptureScreenshot();
62 void ActivateFullscreen(bool val);
63
64 // Profiling
65 void PrepareProfiler();
66
67 // Getters
68 Ogre::Root* GetOgreRoot() { return m_ogre_root; }
69 Ogre::Viewport* GetViewport() { return m_viewport; }
70 Ogre::RenderWindow* GetRenderWindow() { return m_render_window; }
72 std::thread::id GetMainThreadID() { return m_mainthread_id; }
73
74private:
75 // OgreBites::WindowEventListener
76 virtual void windowResized(Ogre::RenderWindow* rw) override;
77 virtual void windowFocusChange(Ogre::RenderWindow* rw) override;
78
79 // OIS::MouseListener
80 virtual bool mouseMoved(const OIS::MouseEvent& arg) override;
81 virtual bool mousePressed(const OIS::MouseEvent& arg, OIS::MouseButtonID id) override;
82 virtual bool mouseReleased(const OIS::MouseEvent& arg, OIS::MouseButtonID id) override;
83
84 // OIS::KeyListener
85 virtual bool keyPressed(const OIS::KeyEvent& arg) override;
86 virtual bool keyReleased(const OIS::KeyEvent& arg) override;
87
88 // OIS::JoyStickListener
89 virtual bool buttonPressed(const OIS::JoyStickEvent& arg, int button) override;
90 virtual bool buttonReleased(const OIS::JoyStickEvent& arg, int button) override;
91 virtual bool axisMoved(const OIS::JoyStickEvent& arg, int axis) override;
92 virtual bool sliderMoved(const OIS::JoyStickEvent& arg, int) override;
93 virtual bool povMoved(const OIS::JoyStickEvent& arg, int) override;
94
95 // Rendering and window management
96 void SetRenderWindowIcon(Ogre::RenderWindow* rw);
97
98 // Variables
99
100 Ogre::Root* m_ogre_root = nullptr;
101 Ogre::RenderWindow* m_render_window = nullptr;
102 Ogre::Viewport* m_viewport = nullptr;
103 bool m_windowed_fix = false;
104 bool m_profiler_enabled = false;
105
108
110
111 std::thread::id m_mainthread_id;
112};
113
115
116} // namespace RoR
Central state/object manager and communications hub.
Central setup and event handler for input/windowing/rendering.
Definition AppContext.h:47
Ogre::Root * GetOgreRoot()
Definition AppContext.h:68
RoR::ForceFeedback m_force_feedback
Definition AppContext.h:109
bool SetUpConfigSkeleton()
virtual bool buttonPressed(const OIS::JoyStickEvent &arg, int button) override
void SetUpObsoleteConfMarker()
Ogre::Viewport * GetViewport()
Definition AppContext.h:69
std::thread::id GetMainThreadID()
Definition AppContext.h:72
virtual bool mouseMoved(const OIS::MouseEvent &arg) override
Ogre::RenderWindow * CreateCustomRenderWindow(std::string const &name, int width, int height)
Ogre::RenderWindow * GetRenderWindow()
Definition AppContext.h:70
bool SetUpProgramPaths()
bool m_windowed_fix
Workaround OGRE glitch when switching from fullscreen.
Definition AppContext.h:103
virtual bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id) override
bool SetUpResourcesDir()
virtual bool sliderMoved(const OIS::JoyStickEvent &arg, int) override
Ogre::Viewport * m_viewport
Definition AppContext.h:102
RoR::ForceFeedback & GetForceFeedback()
Definition AppContext.h:71
virtual bool povMoved(const OIS::JoyStickEvent &arg, int) override
virtual bool buttonReleased(const OIS::JoyStickEvent &arg, int button) override
virtual bool axisMoved(const OIS::JoyStickEvent &arg, int axis) override
virtual bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id) override
int m_prev_screenshot_index
Definition AppContext.h:107
void SetRenderWindowIcon(Ogre::RenderWindow *rw)
virtual void windowFocusChange(Ogre::RenderWindow *rw) override
void CaptureScreenshot()
virtual bool keyPressed(const OIS::KeyEvent &arg) override
bool m_profiler_enabled
Last known state, to workaround OGRE v14.5.2 bug.
Definition AppContext.h:104
Ogre::RenderWindow * m_render_window
Definition AppContext.h:101
virtual bool keyReleased(const OIS::KeyEvent &arg) override
std::thread::id m_mainthread_id
Definition AppContext.h:111
Ogre::Root * m_ogre_root
Definition AppContext.h:100
std::time_t m_prev_screenshot_time
Definition AppContext.h:106
void ActivateFullscreen(bool val)
virtual void windowResized(Ogre::RenderWindow *rw) override