SleakEngine
0.1.0
C++23 multi-backend game engine
Toggle main menu visibility
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
14
namespace
Sleak
{
15
16
/// SDL window wrapper: owns the native window and pumps SDL events into
17
/// engine Events. Application owns exactly one.
18
class
ENGINE_API
Window
{
19
public
:
20
/// Constructs a window with the default size and no title.
21
Window
();
22
/// Constructs a window with the given size and title.
23
Window
(
int
width
,
int
height
, std::string name);
24
/// Destroys the SDL window and shuts down SDL.
25
~Window
();
26
27
Window
(
const
Window
&) =
delete
;
28
Window
&
operator=
(
const
Window
&) =
delete
;
29
30
/// Creates the SDL window and picks the graphics API flag for the active
31
/// renderer.
32
bool
InitializeWindow
();
33
/// Pumps the SDL event queue, dispatching engine events (resize, input, close,
34
/// ...).
35
void
Update
();
36
/// Marks the window for close; actual teardown happens in the destructor.
37
void
Close
();
38
39
/// True once the window has received a close request.
40
inline
bool
ShouldClose
() {
return
bShouldClose; }
41
42
/// Returns the underlying SDL window handle.
43
inline
SDL_Window*
GetSDLWindow
() {
return
SDLWindow; }
44
/// Returns the window title.
45
inline
std::string
GetWindowTitle
() {
return
WindowName; }
46
47
/// Enables or disables fullscreen mode.
48
void
SetFullScreen(
bool
bEnable);
49
/// Flips between fullscreen and windowed mode.
50
inline
void
ToggleFullScreen
() {
SetFullScreen
(!bIsFullScreen); }
51
/// True if the window is currently fullscreen.
52
inline
bool
GetIsFullScreen
() {
return
bIsFullScreen; }
53
54
/// Marks whether ImGui is ready to receive SDL events.
55
void
SetImGuiReady
(
bool
ready) { m_imguiReady = ready; }
56
57
/// Enables or disables relative (locked, delta-only) mouse mode.
58
void
SetRelativeMouseMode(
bool
enabled);
59
60
/// Returns the current window width in pixels.
61
static
int
GetWidth
() {
return
Width; }
62
/// Returns the current window height in pixels.
63
static
int
GetHeight
() {
return
Height; }
64
65
private
:
66
bool
bIsInitialized =
false
;
67
bool
bIsFullScreen =
false
;
68
bool
bShouldClose =
false
;
69
bool
m_imguiReady =
false
;
70
std::string WindowName;
71
72
SDL_Window* SDLWindow =
nullptr
;
73
SDL_Event event;
74
75
static
int
Width;
76
static
int
Height;
77
};
78
79
80
}
81
82
#endif
width
int width
Definition
Application.cpp:40
height
int height
Definition
Application.cpp:41
OSDef.hpp
Sleak::Window::Window
Window(const Window &)=delete
Sleak::Window::SetFullScreen
void SetFullScreen(bool bEnable)
Enables or disables fullscreen mode.
Definition
Window.cpp:185
Sleak::Window::SetImGuiReady
void SetImGuiReady(bool ready)
Marks whether ImGui is ready to receive SDL events.
Definition
Window.hpp:55
Sleak::Window::GetHeight
static int GetHeight()
Returns the current window height in pixels.
Definition
Window.hpp:63
Sleak::Window::InitializeWindow
bool InitializeWindow()
Definition
Window.cpp:35
Sleak::Window::Window
Window()
Constructs a window with the default size and no title.
Definition
Window.cpp:17
Sleak::Window::GetSDLWindow
SDL_Window * GetSDLWindow()
Returns the underlying SDL window handle.
Definition
Window.hpp:43
Sleak::Window::ShouldClose
bool ShouldClose()
True once the window has received a close request.
Definition
Window.hpp:40
Sleak::Window::GetWidth
static int GetWidth()
Returns the current window width in pixels.
Definition
Window.hpp:61
Sleak::Window::Update
void Update()
Definition
Window.cpp:87
Sleak::Window::GetIsFullScreen
bool GetIsFullScreen()
True if the window is currently fullscreen.
Definition
Window.hpp:52
Sleak::Window::operator=
Window & operator=(const Window &)=delete
Sleak::Window::ToggleFullScreen
void ToggleFullScreen()
Flips between fullscreen and windowed mode.
Definition
Window.hpp:50
Sleak::Window::GetWindowTitle
std::string GetWindowTitle()
Returns the window title.
Definition
Window.hpp:45
Sleak::Window::Close
void Close()
Marks the window for close; actual teardown happens in the destructor.
Definition
Window.cpp:200
Sleak
Root namespace for everything the engine exposes.
Definition
Camera.hpp:10
include
private
Core
Window.hpp
Generated on
for SleakEngine by
1.18.0