Add widgets (WIP)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user