SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Window.hpp
Go to the documentation of this file.
1#ifndef _WINDOW_HPP_
2#define _WINDOW_HPP_
3
4#include <Core/OSDef.hpp>
5#include <SDL3/SDL.h>
6#include <string>
7#include "SDL3/SDL_events.h"
8#include "SDL3/SDL_video.h"
9#include <backends/imgui_impl_sdl3.h>
10
11#define DEF_WIDTH 800
12#define DEF_HEIGHT 600
13
14namespace Sleak {
15
16/// SDL window wrapper: owns the native window and pumps SDL events into
17/// engine Events. Application owns exactly one.
18class ENGINE_API Window {
19public:
20 Window();
21 Window(int width, int height, std::string name);
22 ~Window();
23
24 Window(const Window&) = delete;
25 Window& operator=(const Window&) = delete;
26
27 /// Creates the SDL window and picks the graphics API flag for the active renderer.
28 bool InitializeWindow();
29 /// Pumps the SDL event queue, dispatching engine events (resize, input, close, ...).
30 void Update();
31 /// Marks the window for close; actual teardown happens in the destructor.
32 void Close();
33
34 inline bool ShouldClose() { return bShouldClose; }
35
36 inline SDL_Window* GetSDLWindow() {return SDLWindow;}
37 inline std::string GetWindowTitle() { return WindowName;}
38
39 void SetFullScreen(bool bEnable);
40 inline void ToggleFullScreen() { SetFullScreen(!bIsFullScreen); }
41 inline bool GetIsFullScreen() { return bIsFullScreen; }
42
43 void SetImGuiReady(bool ready) { m_imguiReady = ready; }
44
45 void SetRelativeMouseMode(bool enabled);
46
47 static int GetWidth() { return Width; }
48 static int GetHeight() { return Height; }
49
50private:
51 bool bIsInitialized = false;
52 bool bIsFullScreen = false;
53 bool bShouldClose = false;
54 bool m_imguiReady = false;
55 std::string WindowName;
56
57 SDL_Window* SDLWindow;
58 SDL_Event event;
59
60 static int Width;
61 static int Height;
62};
63
64
65}
66
67#endif
int width
int height
Window(const Window &)=delete
void SetFullScreen(bool bEnable)
Definition Window.cpp:184
void SetImGuiReady(bool ready)
Definition Window.hpp:43
static int GetHeight()
Definition Window.hpp:48
bool InitializeWindow()
Creates the SDL window and picks the graphics API flag for the active renderer.
Definition Window.cpp:35
SDL_Window * GetSDLWindow()
Definition Window.hpp:36
bool ShouldClose()
Definition Window.hpp:34
static int GetWidth()
Definition Window.hpp:47
void Update()
Pumps the SDL event queue, dispatching engine events (resize, input, close, ...).
Definition Window.cpp:86
bool GetIsFullScreen()
Definition Window.hpp:41
Window & operator=(const Window &)=delete
void ToggleFullScreen()
Definition Window.hpp:40
std::string GetWindowTitle()
Definition Window.hpp:37
void Close()
Marks the window for close; actual teardown happens in the destructor.
Definition Window.cpp:200
Root namespace for everything the engine exposes.
Definition Camera.hpp:10