Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
Loading...
Searching...
No Matches
definitions.hpp
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include "../../core/definitions.hpp"
4//#include "../../core/node/node.hpp"
5
6class Node;
7class Camera;
8class Graphics;
9class Engine;
10
19
20enum class WindowFlags
21{
22 FULLSCREEN = 0x0000000000000001,
23 OCCLUDED = 0x0000000000000004,
24 HIDDEN = 0x0000000000000008,
25 BORDERLESS = 0x0000000000000010,
26 RESIZABLE = 0x0000000000000020,
27 MINIMIZED = 0x0000000000000040,
28 MAXIMIZED = 0x0000000000000080,
29 INPUT_GRABBED = 0x0000000000000100,
30 INPUT_FOCUS = 0x0000000000000200,
31 MOUSE_FOCUS = 0x0000000000000400,
32 MODAL = 0x0000000000001000,
33 HIGH_DPI = 0x0000000000002000,
34 MOUSE_CAPTURE = 0x0000000000004000,
35 ALWAYS_ON_TOP = 0x0000000000010000,
36 UTILITY = 0x0000000000020000,
37 TOOLTIP = 0x0000000000040000,
38 POPUP_MENU = 0x0000000000080000,
39 KEYBOARD_GRABBED = 0x0000000000100000,
40 FILL_DOCUMENT = 0x0000000000200000, // Emscripten only
41 TRANSPARENT = 0x0000000040000000
42};
43
63class Window : public std::enable_shared_from_this<Window>
64{
65public:
67 ~Window();
68
69 std::string title;
74 std::unique_ptr<Node> root;
76 int id = 0; // this is set when appending the window to the Engine service.
77
79
80 void exit();
81 void initialize();
82 void render(Graphics &graphics, Engine *engine);
83 void physicsUpdate();
84 void update(float deltaTime);
85
86 SDL_Window *window = nullptr;
87 SDL_Renderer *renderer = nullptr;
88 void setActiveCamera(Camera *camera);
89 Camera *getActiveCamera() const;
90
91 template <class Archive>
92 void save(Archive &ar) const
93 {
94 ar(CEREAL_NVP(title), CEREAL_NVP(flags), CEREAL_NVP(presentation), CEREAL_NVP(dimensions), CEREAL_NVP(fullscreen), CEREAL_NVP(id), CEREAL_NVP(root));
95 }
96
97 template <class Archive>
98 void load(Archive &ar); // Implemented in definitions.hpp
99
100private:
101 Camera *activeCamera = nullptr;
102 void preRender() const;
103 void postRender() const;
104};
Definition components.hpp:427
Definition definitions.hpp:41
static const Color BLACK
Definition definitions.hpp:59
Definition engine.hpp:35
Definition graphics.hpp:26
Definition node.hpp:31
Definition definitions.hpp:64
Color clearColor
Definition definitions.hpp:73
void render(Graphics &graphics, Engine *engine)
Definition definitions.cpp:75
void physicsUpdate()
Definition definitions.cpp:98
void exit()
Definition definitions.cpp:87
~Window()
Definition definitions.cpp:47
Rect dimensions
Definition definitions.hpp:72
SDL_Renderer * renderer
Definition definitions.hpp:87
std::unique_ptr< Node > root
Definition definitions.hpp:74
void load(Archive &ar)
Definition definitions.cpp:124
void setActiveCamera(Camera *camera)
Definition definitions.cpp:109
void resetLogicalPresentation()
Definition definitions.cpp:102
RenderLogicalPresentation presentation
Definition definitions.hpp:71
void save(Archive &ar) const
Definition definitions.hpp:92
Camera * getActiveCamera() const
Definition definitions.cpp:118
void initialize()
Definition definitions.cpp:93
void update(float deltaTime)
Definition definitions.cpp:71
bool fullscreen
Definition definitions.hpp:75
std::string title
Definition definitions.hpp:69
WindowFlags flags
Definition definitions.hpp:70
SDL_Window * window
Definition definitions.hpp:86
RenderLogicalPresentation
Definition definitions.hpp:12
WindowFlags
Definition definitions.hpp:21
Definition definitions.hpp:294