21 #include <SDL_render.h>
31 const Uint32 window_flags,
32 const Uint32 render_flags)
33 : window_(SDL_CreateWindow(title.c_str(), x, y, w, h, window_flags))
34 , pixel_format_(SDL_PIXELFORMAT_UNKNOWN)
37 throw texception(
"Failed to create a SDL_Window object.",
true);
40 if(!SDL_CreateRenderer(
window_, -1, render_flags)) {
41 throw texception(
"Failed to create a SDL_Renderer object.",
true);
44 SDL_RendererInfo
info;
45 if(SDL_GetRendererInfo(*
this, &info) != 0) {
46 throw texception(
"Failed to retrieve the information of the renderer.",
50 if(info.num_texture_formats == 0) {
51 throw texception(
"The renderer has no texture information available.\n",
71 SDL_SetWindowSize(
window_, w, h);
76 SDL_SetWindowPosition(
window_, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
86 SDL_SetWindowFullscreen(
window_, 0);
96 SDL_SetWindowFullscreen(
window_, SDL_WINDOW_FULLSCREEN_DESKTOP);
101 SDL_SetRenderDrawColor(*
this, r, g, b, a);
102 if(SDL_RenderClear(*
this) != 0) {
103 throw texception(
"Failed to clear the SDL_Renderer object.",
110 SDL_RenderPresent(*
this);
115 SDL_SetWindowTitle(
window_, title.c_str());
120 SDL_SetWindowIcon(
window_, icon);
125 return SDL_GetWindowFlags(
window_);
130 SDL_SetWindowMinimumSize(
window_, min_w, min_h);
133 twindow::operator SDL_Window*()
138 twindow::operator SDL_Renderer*()
140 return SDL_GetRenderer(window_);
void restore()
Dummy function for restoring the window.
void set_size(const int w, const int h)
Wrapper for SDL_SetWindowSize.
void full_screen()
Dummy function for setting the window to fullscreen mode.
GLint GLint GLint GLint GLint GLint y
GLdouble GLdouble GLdouble b
void render()
Renders the contents of the window.
GLubyte GLubyte GLubyte GLubyte w
void set_icon(const surface &icon)
Sets the icon of the window.
void fill(Uint8 r, Uint8 g, Uint8 b, Uint8 a=0)
Clears the contents of the window with a given color.
GLboolean GLboolean GLboolean GLboolean a
SDL_Window * window_
The SDL_Window we own.
void set_minimum_size(int min_w, int min_h)
Set mimimum size of the window.
void to_window()
Dummy function for returning the window to windowed mode.
Contains a wrapper class for the GPU_Image class.
GLfloat GLfloat GLfloat GLfloat h
GLint GLint GLint GLint GLint x
GLdouble GLdouble GLdouble r
Contains a basic exception class for SDL operations.
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.
void set_title(const std::string &title)
Sets the title of the window.
Contains a wrapper class for the SDL_Window class.
void maximize()
Dummy function for maximizing the window.
void center()
Dummy function for centering the window.
Uint32 pixel_format_
The preferred pixel format for the renderer.
GLsizei const GLcharARB ** string