Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
sdl_window.hpp
Go to the documentation of this file.
1
8
9
#pragma once
10
#include "
base_window.hpp
"
11
#include "window_events.hpp"
12
13
#include <SDL3/SDL.h>
14
#include <glm/vec2.hpp>
15
#include <memory>
16
#include <toast/events/listener.hpp>
17
#include <
toast/log.hpp
>
18
19
namespace
toast {
20
21
class
SDLWindow :
public
IBaseWindow {
22
public
:
23
SDLWindow(
const
char
* title,
unsigned
width = 1080,
unsigned
height = 720, uint64_t flags = 0);
24
25
~SDLWindow()
override
=
default
;
26
27
// Lifetime
28
[[nodiscard]]
29
auto
shouldClose()
const
->
bool
override
;
30
[[nodiscard]]
31
auto
nativeHandle()
const
->
void
*
override
;
32
33
void
pollEvents()
override
;
34
void
swapFramebuffers()
override
;
35
36
private
:
37
void
applyMouseLock(
bool
locked);
38
39
struct
{
40
// do not confuse SDL_Window with SDLWindow, they are not the same
41
std::unique_ptr<SDL_Window,
decltype
(&SDL_DestroyWindow)> sdl_window = {
nullptr
, SDL_DestroyWindow};
42
event::Listener
event_listener;
43
bool
should_close =
false
;
44
bool
cursor_locked =
false
;
45
glm::vec2 virtual_mouse_position {0.0f};
46
} m;
47
};
48
49
}
base_window.hpp
Interface for the Window class.
event::Listener
manages the lifetime, subscription, and unsubscription of callbacks
Definition
listener.hpp:39
log.hpp
Public logging interface for the engine.
engine
src
toast
window
sdl_window.hpp
Generated by
1.17.0