Worldstone
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
BaseApp.h
1 #pragma once
2 #include <SDL.h>
3 #include <atomic>
4 
5 #include "Inputs.h"
6 
7 class BaseApp
8 {
9 private:
10  std::atomic_bool stopRunning = ATOMIC_VAR_INIT(true);
11 
12  int init();
13 
14  void shutdown();
15 
16  void executeLoopOnce();
17 
18 protected:
19  SDL_Window* mainWindow = nullptr;
20  SDL_Cursor* systemCursors[SDL_NUM_SYSTEM_CURSORS] = {nullptr};
21  InputsManager inputsManager;
22 
23  int windowWidth = 1280;
24  int windowHeight = 720;
25 
26  virtual bool initAppThread();
27  virtual void shutdownAppThread();
28  // You are expected to call inputsManager.receiveAndProcessEvents() and bgfx::frame() in your
29  // loop
30  virtual void executeAppLoopOnce();
31  void requireExit() { stopRunning = true; }
32 
33 public:
34  BaseApp()
35  {
36  if (init()) requireExit();
37  }
38  virtual ~BaseApp() { shutdown(); }
39 
40  void run();
41  void runAppThread();
42 };
Definition: BaseApp.h:7