BARE2D
App.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
5 #include "BAREErrors.hpp"
6 #include "ScreenList.hpp"
7 #include "Timer.hpp"
8 
9 namespace BARE2D
10 {
11  class InputManager;
12  class Window;
13 
14  /**
15  * @class App
16  * @file App.h
17  * @brief The App class embodies the entire application. It controls the GL settings, the window, the screens, input, FPS - in whole, the entire overarching input-output cycle.
18  */
19  class App
20  {
21  public:
22  App();
23  ~App();
24 
25  /**
26  * @brief Runs the program! Starts the update-draw loop.
27  */
28  void run();
29 
30  /**
31  * @brief Returns the screen list, where the program can add more screens, set entry points, etc.
32  */
34 
35  /**
36  * @return Returns a pointer to the window, so that the client can change its size, title, etc.
37  */
38  Window* getWindow();
39 
40  /**
41  * @return The input manager pointer.
42  */
44 
45  private:
46  bool m_isGameRunning = false;
47  bool m_isInited = false;
48 
49  std::unique_ptr<ScreenList> m_screenList;
50 
52 
53  Timer* m_timer = nullptr;
54 
55  Window* m_window = nullptr;
56 
57  /**
58  * @brief Initializes the applet and engine. Creates a window, held within this App. Only for internal use.
59  */
60  void init();
61 
62  /**
63  * @brief Updates input, output, etc. Only for internal use.
64  */
65  void update(double dt);
66 
67  /**
68  * @brief Draws the current screen, based on that screen's drawing protocol.
69  */
70  void draw();
71 
72  /**
73  * @brief Updates any input, and throws it down the pipeline!
74  */
75  void updateInput();
76 
77  /**
78  * @brief Polls inputs from SDL and updates the inputmanager as appropriate.
79  */
80  void pollSDLInput();
81 
82  /**
83  * @brief Calls the screen's exit function, and then cleans this class up for destruction.
84  */
85  void exitApp();
86  };
87 
88 }
89 
BARE2D::App::m_isInited
bool m_isInited
Definition: App.hpp:47
BARE2D::App::m_screenList
std::unique_ptr< ScreenList > m_screenList
Definition: App.hpp:49
BARE2D
Definition: App.cpp:13
BARE2D::App::getScreenList
ScreenList * getScreenList()
Returns the screen list, where the program can add more screens, set entry points,...
Definition: App.cpp:68
BARE2D::App::run
void run()
Runs the program! Starts the update-draw loop.
Definition: App.cpp:29
BARE2D::App::update
void update(double dt)
Updates input, output, etc. Only for internal use.
Definition: App.cpp:109
BARE2D::App::updateInput
void updateInput()
Updates any input, and throws it down the pipeline!
Definition: App.cpp:139
BARE2D::App::init
void init()
Initializes the applet and engine. Creates a window, held within this App. Only for internal use.
Definition: App.cpp:80
BARE2D::App::m_timer
Timer * m_timer
Definition: App.hpp:53
BARE2D::App::draw
void draw()
Draws the current screen, based on that screen's drawing protocol.
Definition: App.cpp:130
BARE2D::App::m_isGameRunning
bool m_isGameRunning
Definition: App.hpp:46
ScreenList.hpp
BARE2D::App
Definition: App.hpp:19
BARE2D::App::~App
~App()
Definition: App.cpp:19
BAREErrors.hpp
BARE2D::Timer
Not only does the timer keep track of the current time and delta-times, it can do all the "fancy" cal...
Definition: Timer.hpp:11
BARE2D::App::pollSDLInput
void pollSDLInput()
Polls inputs from SDL and updates the inputmanager as appropriate.
Definition: App.cpp:145
BARE2D::App::getInputManager
InputManager * getInputManager()
Definition: App.cpp:76
BARE2D::Window
It's a graphical window, holds the contexts for GL and SDL.
Definition: Window.hpp:13
BARE2D::App::App
App()
Definition: App.cpp:15
BARE2D::App::getWindow
Window * getWindow()
Definition: App.cpp:72
BARE2D::ScreenList
Holds and connects all of the screens used in the program in a list. Keeps track of the previous scre...
Definition: ScreenList.hpp:13
BARE2D::App::m_inputManager
InputManager * m_inputManager
Definition: App.hpp:51
BARE2D::InputManager
This is the input manager. It does what you expect! Nearly completely copied from GLEngine,...
Definition: InputManager.hpp:12
BARE2D::App::m_window
Window * m_window
Definition: App.hpp:55
Timer.hpp
BARE2D::App::exitApp
void exitApp()
Calls the screen's exit function, and then cleans this class up for destruction.
Definition: App.cpp:179