Engine.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef __ENGINE_H__
  2. #define __ENGINE_H__
  3. #include <SDL2/SDL.h>
  4. #include <imgui.h>
  5. #include <imgui_impl_sdl2.h>
  6. #include <imgui_impl_sdlrenderer2.h>
  7. #include <entt/entt.hpp>
  8. #include <sol/sol.hpp>
  9. #include "EngineConfig.h"
  10. #include "states/StateManager.h"
  11. #include <pybind11/embed.h>
  12. namespace py = pybind11;
  13. class Engine
  14. {
  15. public:
  16. Engine();
  17. ~Engine();
  18. void Run();
  19. // Getters / Setters
  20. SDL_Renderer* GetRenderer() const { return renderer; }
  21. SDL_Window* GetWindow() const { return window; }
  22. bool IsRunning() const { return isRunning; }
  23. void StopRunning() { isRunning = false; }
  24. // StateManager
  25. StateManager stateManager;
  26. // Safe State transition
  27. void RequestStateChange(std::unique_ptr<BaseState> newState);
  28. void RequestPopState();
  29. private:
  30. SDL_Window* window = nullptr;
  31. SDL_Renderer* renderer = nullptr;
  32. bool isRunning = true;
  33. SDL_Rect camera = { 0, 0, EngineConfig::DEFAULT_WINDOW_WIDTH, EngineConfig::DEFAULT_WINDOW_HEIGHT };
  34. // General functions
  35. void InitSDL();
  36. void InitImGui();
  37. void InitAudio();
  38. void HandleEvents();
  39. void Update(float dt);
  40. void Render();
  41. // Python support
  42. void InitPython();
  43. void ShutdownPython();
  44. void RunPythonScript(const std::string& filename);
  45. std::unique_ptr<py::scoped_interpreter> pythonInterpreter;
  46. // StateManager
  47. std::unique_ptr<BaseState> pendingNewState = nullptr;
  48. bool pendingPop = false;
  49. };
  50. #endif