6#include <SDL3/SDL_gpu.h>
14 explicit Window(
const char *
title, Sint32 w, Sint32 h, SDL_WindowFlags
flags);
17 explicit Window(SDL_Window *ptr) : _handle(ptr) {}
21 other._handle =
nullptr;
26 _handle = other._handle;
27 other._handle =
nullptr;
31 operator SDL_Window *()
const {
return _handle; }
33 std::array<int, 2>
size()
const;
37 float pixelDensity()
const {
return SDL_GetWindowPixelDensity(_handle); }
39 float displayScale()
const {
return SDL_GetWindowDisplayScale(_handle); }
42 return SDL_GetWindowPixelFormat(_handle);
45 SDL_WindowFlags
flags()
const {
return SDL_GetWindowFlags(_handle); }
48 return SDL_SetWindowTitle(_handle,
title);
51 std::string_view
title()
const {
return SDL_GetWindowTitle(_handle); }
55 SDL_DestroyWindow(_handle);
66 SDL_WindowFlags
flags) {
67 _handle = SDL_CreateWindow(
title, w, h,
flags);
75 SDL_GetWindowSize(_handle, &width, &height);
76 return {width, height};
81 if (!SDL_GetWindowSizeInPixels(_handle, &width, &height)) {
83 return {width, height};
Wrapper for std::runtime_error, which prints out the filename and code line.
Definition errors.h:29
Window(const Window &)=delete
bool setTitle(const char *title)
Definition Window.h:47
float displayScale() const
Definition Window.h:39
void destroy() noexcept
Definition Window.h:53
SDL_WindowFlags flags() const
Definition Window.h:45
std::array< int, 2 > size() const
Definition Window.h:73
SDL_PixelFormat pixelFormat() const
Definition Window.h:41
float pixelDensity() const
Definition Window.h:37
Window(const char *title, Sint32 w, Sint32 h, SDL_WindowFlags flags)
Standard constructor, which forwards to SDL_CreateWindow.
Definition Window.h:65
~Window() noexcept
Definition Window.h:59
std::string_view title() const
Definition Window.h:51
Window & operator=(Window &&other) noexcept
Definition Window.h:24
Window(Window &&other) noexcept
Definition Window.h:20
Window(SDL_Window *ptr)
This constructor takes ownership of the provided handle.
Definition Window.h:17
std::array< int, 2 > sizeInPixels() const
Definition Window.h:79