SDL/Window: removed pixel format member and promoted renderer info wholly to class member
The pixel format member was really rather useless, since SDL_RenderInfo returns an array of supported formats and only the first one was being saved.
This commit is contained in:
parent
855345291b
commit
ca44435550
2 changed files with 12 additions and 10 deletions
|
@ -18,8 +18,6 @@
|
|||
#include "sdl/surface.hpp"
|
||||
#include "sdl/exception.hpp"
|
||||
|
||||
#include <SDL_render.h>
|
||||
|
||||
namespace sdl
|
||||
{
|
||||
|
||||
|
@ -31,7 +29,7 @@ window::window(const std::string& title,
|
|||
const uint32_t window_flags,
|
||||
const uint32_t 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);
|
||||
}
|
||||
|
@ -63,8 +60,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();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
* Contains a wrapper class for the @ref SDL_Window class.
|
||||
*/
|
||||
|
||||
#include <SDL_render.h>
|
||||
#include <SDL_video.h>
|
||||
|
||||
#include <string>
|
||||
|
@ -167,6 +168,12 @@ public:
|
|||
|
||||
int get_display_index();
|
||||
|
||||
/** Gets the renderer info for this window. */
|
||||
const SDL_RendererInfo& get_renderer_info() const
|
||||
{
|
||||
return info_;
|
||||
}
|
||||
|
||||
/***** ***** ***** Conversion operators. ***** ***** *****/
|
||||
|
||||
/**
|
||||
|
@ -185,8 +192,8 @@ private:
|
|||
/** The @ref SDL_Window we own. */
|
||||
SDL_Window* window_;
|
||||
|
||||
/** The preferred pixel format for the renderer. */
|
||||
uint32_t pixel_format_;
|
||||
/** Info about the current renderer. */
|
||||
SDL_RendererInfo info_;
|
||||
};
|
||||
|
||||
} // namespace sdl
|
||||
|
|
Loading…
Add table
Reference in a new issue