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;
27 _handle = other._handle;
28 other._handle =
nullptr;
33 operator SDL_Window *()
const {
return _handle; }
35 std::array<int, 2>
size()
const;
39 float pixelDensity()
const {
return SDL_GetWindowPixelDensity(_handle); }
41 float displayScale()
const {
return SDL_GetWindowDisplayScale(_handle); }
44 return SDL_GetWindowPixelFormat(_handle);
47 SDL_WindowFlags
flags()
const {
return SDL_GetWindowFlags(_handle); }
50 return SDL_SetWindowTitle(_handle,
title);
53 std::string_view
title()
const {
return SDL_GetWindowTitle(_handle); }
57 SDL_DestroyWindow(_handle);
68 SDL_WindowFlags
flags) {
69 _handle = SDL_CreateWindow(
title, w, h,
flags);
77 SDL_GetWindowSize(_handle, &width, &height);
78 return {width, height};
83 SDL_GetWindowSizeInPixels(_handle, &width, &height);
84 return {width, height};
Wrapper for std::runtime_error, which prints out the filename and code line.
Definition errors.h:27
Window(const Window &)=delete
bool setTitle(const char *title)
Definition Window.h:49
float displayScale() const
Definition Window.h:41
void destroy() noexcept
Definition Window.h:55
SDL_WindowFlags flags() const
Definition Window.h:47
std::array< int, 2 > size() const
Definition Window.h:75
SDL_PixelFormat pixelFormat() const
Definition Window.h:43
float pixelDensity() const
Definition Window.h:39
Window(const char *title, Sint32 w, Sint32 h, SDL_WindowFlags flags)
Standard constructor, which forwards to SDL_CreateWindow.
Definition Window.h:67
~Window() noexcept
Definition Window.h:61
std::string_view title() const
Definition Window.h:53
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:81