Graphics/Sprite: Add [Get|Set]TextureCoords & SetTextureRect

This commit is contained in:
Jérôme Leclercq
2021-11-24 22:00:29 +01:00
parent b8b0552a4e
commit c9aba016a8
5 changed files with 64 additions and 11 deletions

View File

@@ -8,6 +8,21 @@
namespace Nz
{
inline const Color& Sprite::GetColor() const
{
return m_color;
}
inline const Color& Sprite::GetCornerColor(RectCorner corner) const
{
return m_cornerColor[UnderlyingCast(corner)];
}
inline const Rectf& Sprite::GetTextureCoords() const
{
return m_textureCoords;
}
inline void Sprite::SetColor(const Color& color)
{
m_color = color;
@@ -24,6 +39,8 @@ namespace Nz
inline void Sprite::SetMaterial(std::shared_ptr<Material> material)
{
assert(material);
m_material = std::move(material);
}
@@ -34,6 +51,19 @@ namespace Nz
UpdateVertices();
}
inline void Sprite::SetTextureCoords(const Rectf& textureCoords)
{
m_textureCoords = textureCoords;
UpdateVertices();
}
inline void Sprite::SetTextureRect(const Rectf& textureRect)
{
Vector2ui textureSize(GetTextureSize());
return SetTextureCoords(textureRect / Vector2f(textureSize));
}
inline void Sprite::UpdateVertices()
{
VertexStruct_XYZ_Color_UV* vertices = m_vertices.data();