mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-08 23:10:58 -04:00
Implement Width/Height/Size getters for Texture and Surface
This commit is contained in:
parent
ca505369f3
commit
9e53670b2e
@ -193,4 +193,16 @@ void Surface::FillRects(const Rect* rects, int count, Uint32 color) {
|
|||||||
throw Exception("SDL_FillRects failed");
|
throw Exception("SDL_FillRects failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Surface::GetWidth() const {
|
||||||
|
return surface_->w;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Surface::GetHeight() const {
|
||||||
|
return surface_->h;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point Surface::GetSize() const {
|
||||||
|
return Point(surface_->w, surface_->h);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <SDL2pp/Config.hh>
|
#include <SDL2pp/Config.hh>
|
||||||
#include <SDL2pp/Optional.hh>
|
#include <SDL2pp/Optional.hh>
|
||||||
#include <SDL2pp/Rect.hh>
|
#include <SDL2pp/Rect.hh>
|
||||||
|
#include <SDL2pp/Point.hh>
|
||||||
|
|
||||||
struct SDL_Surface;
|
struct SDL_Surface;
|
||||||
struct SDL_PixelFormat;
|
struct SDL_PixelFormat;
|
||||||
@ -479,6 +480,30 @@ public:
|
|||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void FillRects(const Rect* rects, int count, Uint32 color);
|
void FillRects(const Rect* rects, int count, Uint32 color);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get surface width
|
||||||
|
///
|
||||||
|
/// \return Surface width in pixels
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
int GetWidth() const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get surface height
|
||||||
|
///
|
||||||
|
/// \return Surface height in pixels
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
int GetHeight() const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get surface size
|
||||||
|
///
|
||||||
|
/// \return SDL2pp::Point representing surface dimensions in pixels
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Point GetSize() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -140,4 +140,11 @@ int Texture::GetHeight() const {
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point Texture::GetSize() const {
|
||||||
|
int w, h;
|
||||||
|
if (SDL_QueryTexture(texture_, nullptr, nullptr, &w, &h) != 0)
|
||||||
|
throw Exception("SDL_QueryTexture failed");
|
||||||
|
return Point(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -389,6 +389,18 @@ public:
|
|||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
int GetHeight() const;
|
int GetHeight() const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get texture image size
|
||||||
|
///
|
||||||
|
/// \return SDL2pp::Point representing texture dimensions in pixels
|
||||||
|
///
|
||||||
|
/// \throws SDL2pp::Exception
|
||||||
|
///
|
||||||
|
/// \see http://wiki.libsdl.org/SDL_QueryTexture
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Point GetSize() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user