1 #include "ge211_window.hxx"
2 #include "ge211_error.hxx"
8 using namespace detail;
10 Window::Window(
const std::string& title, Dims<int> dim)
11 : ptr_{SDL_CreateWindow(title.
c_str(),
12 SDL_WINDOWPOS_UNDEFINED,
13 SDL_WINDOWPOS_UNDEFINED,
19 throw Host_error{
"Could not create window"};
22 uint32_t Window::get_flags_() const NOEXCEPT
24 return SDL_GetWindowFlags(get_raw_());
30 SDL_GetWindowSize(get_raw_(), &result.width, &result.height);
36 SDL_SetWindowSize(get_raw_(), dims.
width, dims.
height);
38 if (get_dimensions() != dims)
42 #if SDL_VERSION_ATLEAST(2, 0, 5)
43 bool Window::get_resizeable() const NOEXCEPT
45 return (get_flags_() & SDL_WINDOW_RESIZABLE) != 0;
48 void Window::set_resizeable(
bool resizable) NOEXCEPT
50 SDL_SetWindowResizable(get_raw_(), resizable? SDL_TRUE : SDL_FALSE);
57 SDL_GetWindowPosition(get_raw_(), &result.x, &result.y);
63 SDL_SetWindowPosition(get_raw_(), position.
x, position.
y);
70 return (get_flags_() & SDL_WINDOW_FULLSCREEN) != 0;
75 uint32_t flags = fullscreen? SDL_WINDOW_FULLSCREEN : 0;
77 if (SDL_SetWindowFullscreen(get_raw_(), flags) < 0)
78 throw Host_error{
"Window::set_fullscreen: failed"};
84 SDL_GetDisplayBounds(0, &rect);
85 return {rect.w, rect.h};
90 int top, left, bottom, right;
91 SDL_GetWindowBordersSize(get_raw_(), &top, &left, &bottom, &right);
94 SDL_GetDisplayUsableBounds(0, &rect);
96 return {rect.w - left - right, rect.h - top - bottom};