Implement Texture::UpdateYUV()

This commit is contained in:
Dmitry Marakasov 2015-01-15 17:13:00 +03:00
parent e5c74863f0
commit be15f8c1d6
2 changed files with 24 additions and 0 deletions

View File

@ -93,6 +93,11 @@ void Texture::Update(const Optional<Rect>& rect, const void* pixels, int pitch)
throw Exception("SDL_UpdateTexture failed");
}
void Texture::UpdateYUV(const Optional<Rect>& rect, const Uint8* yplane, int ypitch, const Uint8* uplane, int upitch, const Uint8* vplane, int vpitch) {
if (SDL_UpdateYUVTexture(texture_, rect ? &*rect : nullptr, yplane, ypitch, uplane, upitch, vplane, vpitch) != 0)
throw Exception("SDL_UpdateYUVTexture failed");
}
void Texture::SetBlendMode(SDL_BlendMode blendMode) {
if (SDL_SetTextureBlendMode(texture_, blendMode) != 0)
throw Exception("SDL_SetTextureBlendMode failed");

View File

@ -311,6 +311,25 @@ public:
////////////////////////////////////////////////////////////
void Update(const Optional<Rect>& rect, const void* pixels, int pitch);
////////////////////////////////////////////////////////////
/// \brief Update the given texture rectangle with new pixel data
///
/// \param[in] rect Rect representing the area to update, or NullOpt to
/// update the entire texture
/// \param[in] yplane Raw pixel data for the Y plane
/// \param[in] ypitch Number of bytes between rows of pixel data for the Y plane
/// \param[in] uplane Raw pixel data for the U plane
/// \param[in] upitch Number of bytes between rows of pixel data for the U plane
/// \param[in] vplane Raw pixel data for the V plane
/// \param[in] vpitch Number of bytes between rows of pixel data for the V plane
///
/// \throws SDL2pp::Exception
///
/// \see http://wiki.libsdl.org/SDL_UpdateYUVTexture
///
////////////////////////////////////////////////////////////
void UpdateYUV(const Optional<Rect>& rect, const Uint8* yplane, int ypitch, const Uint8* uplane, int upitch, const Uint8* vplane, int vpitch);
////////////////////////////////////////////////////////////
/// \brief Set the blend mode for a texture, used by SDL2pp::Renderer::Copy
///