Add widgets (WIP)

This commit is contained in:
Jérôme Leclercq
2021-10-04 09:25:45 +02:00
parent 68708c54f7
commit a66f6faed1
31 changed files with 1955 additions and 24 deletions

View File

@@ -8,10 +8,57 @@
namespace Nz
{
inline void Sprite::SetColor(const Color& color)
{
m_color = color;
UpdateVertices();
}
inline void Sprite::SetCornerColor(RectCorner corner, const Color& color)
{
m_cornerColor[UnderlyingCast(corner)] = color;
UpdateVertices();
}
inline void Sprite::SetMaterial(std::shared_ptr<Material> material)
{
m_material = std::move(material);
}
inline void Sprite::SetSize(const Vector2f& size)
{
m_size = size;
UpdateVertices();
}
inline void Sprite::UpdateVertices()
{
VertexStruct_XYZ_Color_UV* vertices = m_vertices.data();
Vector3f origin = Vector3f::Zero();
vertices->color = m_color * m_cornerColor[UnderlyingCast(RectCorner::LeftTop)];
vertices->position = Vector3f(-origin);
vertices->uv = m_textureCoords.GetCorner(RectCorner::LeftTop);
vertices++;
vertices->color = m_color * m_cornerColor[UnderlyingCast(RectCorner::RightTop)];
vertices->position = m_size.x * Vector3f::Right() - origin;
vertices->uv = m_textureCoords.GetCorner(RectCorner::RightTop);
vertices++;
vertices->color = m_color * m_cornerColor[UnderlyingCast(RectCorner::LeftBottom)];
vertices->position = m_size.y * Vector3f::Down() - origin;
vertices->uv = m_textureCoords.GetCorner(RectCorner::LeftBottom);
vertices++;
vertices->color = m_color * m_cornerColor[UnderlyingCast(RectCorner::RightBottom)];
vertices->position = m_size.x * Vector3f::Right() + m_size.y * Vector3f::Down() - origin;
vertices->uv = m_textureCoords.GetCorner(RectCorner::RightBottom);
}
}
#include <Nazara/Graphics/DebugOff.hpp>