diff --git a/src/sdl/window.cpp b/src/sdl/window.cpp index bfcfeda30ee4..666cc6f81e2c 100644 --- a/src/sdl/window.cpp +++ b/src/sdl/window.cpp @@ -18,8 +18,6 @@ #include "sdl/surface.hpp" #include "sdl/exception.hpp" -#include - namespace sdl { @@ -31,7 +29,7 @@ window::window(const std::string& title, const Uint32 window_flags, const Uint32 render_flags) : window_(SDL_CreateWindow(title.c_str(), x, y, w, h, window_flags)) - , pixel_format_(SDL_PIXELFORMAT_UNKNOWN) + , info_() { if(!window_) { throw exception("Failed to create a SDL_Window object.", true); @@ -42,13 +40,12 @@ window::window(const std::string& title, throw exception("Failed to create a SDL_Renderer object.", true); } - SDL_RendererInfo info; - if(SDL_GetRendererInfo(*this, &info) != 0) { + if(SDL_GetRendererInfo(*this, &info_) != 0) { throw exception("Failed to retrieve the information of the renderer.", true); } - if(info.num_texture_formats == 0) { + if(info_.num_texture_formats == 0) { throw exception("The renderer has no texture information available.\n", false); } @@ -59,8 +56,6 @@ window::window(const std::string& title, // Use linear scaling when rendering, if applicable. SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); - pixel_format_ = info.texture_formats[0]; - fill(0,0,0); render(); diff --git a/src/sdl/window.hpp b/src/sdl/window.hpp index 11a232d0afc4..9251a2e35990 100644 --- a/src/sdl/window.hpp +++ b/src/sdl/window.hpp @@ -19,6 +19,7 @@ * Contains a wrapper class for the @ref SDL_Window class. */ +#include #include #include @@ -157,6 +158,12 @@ class window int get_display_index(); + /** Gets the renderer info for this window. */ + const SDL_RendererInfo& get_renderer_info() const + { + return info_; + } + /***** ***** ***** Conversion operators. ***** ***** *****/ /** @@ -175,8 +182,8 @@ class window /** The @ref SDL_Window we own. */ SDL_Window* window_; - /** The preferred pixel format for the renderer. */ - Uint32 pixel_format_; + /** Info about the current renderer. */ + SDL_RendererInfo info_; }; } // namespace sdl