22 #include <SDL3/SDL_hints.h>
23 #include <SDL3/SDL_render.h>
27 #include <SDL3/SDL_mouse.h>
36 const uint32_t window_flags)
37 : window_(SDL_CreateWindow(title.c_str(),
w,
h, window_flags | SDL_WINDOW_HIDDEN))
40 throw exception(
"Failed to create a SDL_Window object.",
true);
52 SDL_SetHint(SDL_HINT_RENDER_DRIVER,
"direct3d11");
56 SDL_SetHint(SDL_HINT_ORIENTATIONS,
"LandscapeLeft LandscapeRight");
62 if(!SDL_SetNumberProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, 1)) {
63 throw exception(
"Failed to set vsync",
true);
67 if(!SDL_SetPointerProperty(props, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER,
window_)) {
68 throw exception(
"Failed to set window pointer property",
true);
71 if(!SDL_CreateRendererWithProperties(props)) {
72 throw exception(
"Failed to create a SDL_Renderer object.",
true);
76 SDL_SetRenderDrawBlendMode(*
this, SDL_BLENDMODE_BLEND);
80 SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
"0");
87 if(!(window_flags & SDL_WINDOW_HIDDEN)) {
102 SDL_SetRenderLogicalPresentation(SDL_GetRenderer(
window_),
w,
h, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
103 SDL_WarpMouseInWindow(
window_,
w / 2,
h / 2);
113 SDL_GetRenderLogicalPresentation(SDL_GetRenderer(
window_), &res.x, &res.y,
nullptr);
115 SDL_GetWindowSize(*
this, &res.x, &res.y);
124 SDL_GetCurrentRenderOutputSize(*
this, &res.x, &res.y);
132 SDL_SetWindowPosition(
window_, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
146 SDL_SetWindowFullscreen(
window_,
false);
160 SDL_SetWindowFullscreen(
window_,
true);
166 SDL_SetRenderDrawColor(*
this, r,
g,
b, a);
167 if(!SDL_RenderClear(*
this)) {
168 throw exception(
"Failed to clear the SDL_Renderer object.",
true);
174 SDL_RenderPresent(*
this);
180 SDL_SetWindowTitle(
window_, title.c_str());
185 SDL_SetWindowIcon(
window_, icon);
190 SDL_SetWindowMinimumSize(
window_, min_w, min_h);
200 return SDL_GetWindowFlags(
window_);
205 return SDL_GetDisplayForWindow(
window_);
210 SDL_Renderer* r = SDL_GetRenderer(
window_);
214 SDL_SetRenderLogicalPresentation(r,
w,
h, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
224 SDL_Renderer* r = SDL_GetRenderer(
window_);
226 SDL_RendererLogicalPresentation mode = SDL_LOGICAL_PRESENTATION_INTEGER_SCALE;
227 SDL_GetRenderLogicalPresentation(r, &
w, &
h, &mode);
233 SDL_Renderer* r = SDL_GetRenderer(
window_);
234 SDL_RendererLogicalPresentation mode = SDL_LOGICAL_PRESENTATION_INTEGER_SCALE;
235 SDL_GetRenderLogicalPresentation(r, &
w, &
h, &mode);
238 window::operator SDL_Window*()
243 window::operator SDL_Renderer*()
245 return SDL_GetRenderer(window_);
void set_size(const int w, const int h)
Wrapper for SDL_SetWindowSize.
void to_window()
Dummy function for returning the window to windowed mode.
window(const window &)=delete
point get_size()
Gets the window's size, in screen coordinates.
void fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a=0)
Clears the contents of the window with a given color.
point get_logical_size() const
void center()
Dummy function for centering the window.
void render()
Renders the contents of the window.
void restore()
Dummy function for restoring the window.
void set_minimum_size(int min_w, int min_h)
Set minimum size of the window.
SDL_Window * window_
The SDL_Window we own.
void full_screen()
Dummy function for setting the window to fullscreen mode.
void set_icon(const surface &icon)
Sets the icon of the window.
void set_logical_size(int w, int h)
Sets the desired size of the rendering surface.
void maximize()
Dummy function for maximizing the window.
void set_title(const std::string &title)
Sets the title of the window.
point get_output_size()
Gets the window's renderer output size, in pixels.
Contains a basic exception class for SDL operations.
Contains a wrapper class for the SDL_Window class.