The wrapper class for the SDL_Window class. More...
#include <window.hpp>
Public Member Functions | |
twindow (const std::string &title, const int x, const int y, const int w, const int h, const Uint32 window_flags, const Uint32 render_flags) | |
Constructor. More... | |
~twindow () | |
void | set_size (const int w, const int h) |
Wrapper for SDL_SetWindowSize. More... | |
void | center () |
Dummy function for centering the window. More... | |
void | maximize () |
Dummy function for maximizing the window. More... | |
void | restore () |
Dummy function for restoring the window. More... | |
void | to_window () |
Dummy function for returning the window to windowed mode. More... | |
void | full_screen () |
Dummy function for setting the window to fullscreen mode. More... | |
void | fill (Uint8 r, Uint8 g, Uint8 b, Uint8 a=0) |
Clears the contents of the window with a given color. More... | |
void | render () |
Renders the contents of the window. More... | |
void | set_title (const std::string &title) |
Sets the title of the window. More... | |
void | set_icon (const surface &icon) |
Sets the icon of the window. More... | |
int | get_flags () |
void | set_minimum_size (int min_w, int min_h) |
Set mimimum size of the window. More... | |
operator SDL_Window * () | |
Conversion operator to a SDL_Window*. More... | |
Private Member Functions | |
operator SDL_Renderer * () | |
Conversion operator to a SDL_Renderer*. More... | |
Private Attributes | |
SDL_Window * | window_ |
The SDL_Window we own. More... | |
Uint32 | pixel_format_ |
The preferred pixel format for the renderer. More... | |
The wrapper class for the SDL_Window class.
At the moment of writing it is not certain yet how many windows will be created. At least one as main window, but maybe the GUI dialogues will have their own window. Once that is known it might be a good idea to evaluate whether the class should become a singleton or not.
The class also wraps several functions operating on SDL_Window objects. For functions not wrapped the class offers an implicit conversion operator to a pointer to the SDL_Window object it owns.
Definition at line 52 of file window.hpp.
sdl::twindow::twindow | ( | const std::string & | title, |
const int | x, | ||
const int | y, | ||
const int | w, | ||
const int | h, | ||
const Uint32 | window_flags, | ||
const Uint32 | render_flags | ||
) |
Constructor.
The function calls SDL_CreateWindow and SDL_CreateRenderer.
title | Used as title for SDL_CreateWindow. |
x | Used as x for SDL_CreateWindow. |
y | Used as y for SDL_CreateWindow. |
w | Used as w for SDL_CreateWindow. |
h | Used as x for SDL_CreateWindow. |
window_flags | Used as flags for SDL_CreateWindow. |
render_flags | Used as flags for SDL_CreateRenderer. |
Definition at line 26 of file window.cpp.
References fill(), lg::info(), pixel_format_, render(), and window_.
sdl::twindow::~twindow | ( | ) |
Definition at line 62 of file window.cpp.
References window_.
void sdl::twindow::center | ( | ) |
Dummy function for centering the window.
Definition at line 74 of file window.cpp.
References window_.
void sdl::twindow::fill | ( | Uint8 | r, |
Uint8 | g, | ||
Uint8 | b, | ||
Uint8 | a = 0 |
||
) |
Clears the contents of the window with a given color.
r | Red value of the color. |
g | Green value of the color. |
b | Blue value of the color. |
Definition at line 99 of file window.cpp.
void sdl::twindow::full_screen | ( | ) |
Dummy function for setting the window to fullscreen mode.
Definition at line 94 of file window.cpp.
References window_.
int sdl::twindow::get_flags | ( | ) |
Definition at line 123 of file window.cpp.
References window_.
void sdl::twindow::maximize | ( | ) |
Dummy function for maximizing the window.
Definition at line 79 of file window.cpp.
References window_.
|
private |
Conversion operator to a SDL_Renderer*.
Definition at line 138 of file window.cpp.
sdl::twindow::operator SDL_Window * | ( | ) |
Conversion operator to a SDL_Window*.
Definition at line 133 of file window.cpp.
void sdl::twindow::render | ( | ) |
Renders the contents of the window.
Definition at line 108 of file window.cpp.
void sdl::twindow::restore | ( | ) |
Dummy function for restoring the window.
Definition at line 89 of file window.cpp.
References window_.
Sets the icon of the window.
This is a wrapper for SDL_SetWindowIcon.
icon
is a SDL_Surface and not a SDL_Texture, this is part of the SDL 2 API.icon | The new icon for the window. |
Definition at line 118 of file window.cpp.
References window_.
Set mimimum size of the window.
This is a wrapper for SDL_SetWindowMinimumWindowSize.
Definition at line 128 of file window.cpp.
References window_.
Wrapper for SDL_SetWindowSize.
w | Used as w for SDL_SetWindowSize. |
h | Used as x for SDL_SetWindowSize. |
Definition at line 69 of file window.cpp.
References window_.
void sdl::twindow::set_title | ( | const std::string & | title | ) |
Sets the title of the window.
This is a wrapper for SDL_SetWindowTitle.
title | The new title for the window. |
Definition at line 113 of file window.cpp.
References window_.
void sdl::twindow::to_window | ( | ) |
Dummy function for returning the window to windowed mode.
Definition at line 84 of file window.cpp.
References window_.
|
private |
The preferred pixel format for the renderer.
Definition at line 180 of file window.hpp.
Referenced by twindow().
|
private |
The SDL_Window we own.
Definition at line 177 of file window.hpp.
Referenced by center(), full_screen(), get_flags(), maximize(), restore(), set_icon(), set_minimum_size(), set_size(), set_title(), to_window(), twindow(), and ~twindow().