_font writereserve
This commit is contained in:
@@ -283,6 +283,22 @@ FORCE_INLINE Render2DVertex MakeVertex(const Float2& point, const Float2& uv, co
|
||||
};
|
||||
}
|
||||
|
||||
FORCE_INLINE Render2DVertex MakeTransformedVertex(const Float2& pos, const Float2& uv, const Color& color)
|
||||
{
|
||||
Float2 point;
|
||||
ApplyTransform(pos, point);
|
||||
|
||||
//return MakeVertex(point, uv, color, ClipLayersStack.Peek().Mask, { 0.0f, (float)Render2D::Features }, TintLayersStack.Peek());
|
||||
return
|
||||
{
|
||||
point,
|
||||
Half2(uv),
|
||||
color * TintLayersStack.Peek(),
|
||||
{ 0.0f, (float)Render2D::Features },
|
||||
ClipLayersStack.Peek().Mask
|
||||
};
|
||||
}
|
||||
|
||||
void WriteTri(const Float2& p0, const Float2& p1, const Float2& p2, const Float2& uv0, const Float2& uv1, const Float2& uv2, const Color& color0, const Color& color1, const Color& color2)
|
||||
{
|
||||
Render2DVertex tris[3];
|
||||
@@ -316,15 +332,24 @@ void WriteRect(const Rectangle& rect, const Color& color1, const Color& color2,
|
||||
const Float2 uvUpperLeft = Float2::Zero;
|
||||
const Float2 uvBottomRight = Float2::One;
|
||||
|
||||
Render2DVertex quad[4];
|
||||
quad[0] = MakeVertex(rect.GetBottomRight(), uvBottomRight, color3);
|
||||
quad[1] = MakeVertex(rect.GetBottomLeft(), Float2(uvUpperLeft.X, uvBottomRight.Y), color4);
|
||||
quad[2] = MakeVertex(rect.GetUpperLeft(), uvUpperLeft, color1);
|
||||
quad[3] = MakeVertex(rect.GetUpperRight(), Float2(uvBottomRight.X, uvUpperLeft.Y), color2);
|
||||
VB.Write(quad, sizeof(quad));
|
||||
Render2DVertex* quad = (Render2DVertex*)VB.WriteReserve(sizeof(Render2DVertex) * 4);
|
||||
//Render2DVertex quad[4];
|
||||
quad[0] = MakeTransformedVertex(rect.GetBottomRight(), uvBottomRight, color3);
|
||||
quad[1] = MakeTransformedVertex(rect.GetBottomLeft(), Float2(uvUpperLeft.X, uvBottomRight.Y), color4);
|
||||
quad[2] = MakeTransformedVertex(rect.GetUpperLeft(), uvUpperLeft, color1);
|
||||
quad[3] = MakeTransformedVertex(rect.GetUpperRight(), Float2(uvBottomRight.X, uvUpperLeft.Y), color2);
|
||||
//VB.Write(quad, sizeof(quad));
|
||||
|
||||
uint32 indices[6];
|
||||
RENDER2D_WRITE_IB_QUAD(indices);
|
||||
//uint32 indices[6];
|
||||
uint32* indices = (uint32*)IB.WriteReserve(sizeof(uint32) * 6);
|
||||
indices[0] = VBIndex + 0;
|
||||
indices[1] = VBIndex + 1;
|
||||
indices[2] = VBIndex + 2;
|
||||
indices[3] = VBIndex + 2;
|
||||
indices[4] = VBIndex + 3;
|
||||
indices[5] = VBIndex + 0;
|
||||
//IB.Write(indices, sizeof(indices));
|
||||
//RENDER2D_WRITE_IB_QUAD(indices);
|
||||
|
||||
VBIndex += 4;
|
||||
IBIndex += 6;
|
||||
@@ -332,15 +357,24 @@ void WriteRect(const Rectangle& rect, const Color& color1, const Color& color2,
|
||||
|
||||
void WriteRect(const Rectangle& rect, const Color& color, const Float2& uvUpperLeft, const Float2& uvBottomRight)
|
||||
{
|
||||
Render2DVertex quad[4];
|
||||
quad[0] = MakeVertex(rect.GetBottomRight(), uvBottomRight, color);
|
||||
quad[1] = MakeVertex(rect.GetBottomLeft(), Float2(uvUpperLeft.X, uvBottomRight.Y), color);
|
||||
quad[2] = MakeVertex(rect.GetUpperLeft(), uvUpperLeft, color);
|
||||
quad[3] = MakeVertex(rect.GetUpperRight(), Float2(uvBottomRight.X, uvUpperLeft.Y), color);
|
||||
VB.Write(quad, sizeof(quad));
|
||||
Render2DVertex* quad = (Render2DVertex*)VB.WriteReserve(sizeof(Render2DVertex) * 4);
|
||||
//Render2DVertex quad[4];
|
||||
quad[0] = MakeTransformedVertex(rect.GetBottomRight(), uvBottomRight, color);
|
||||
quad[1] = MakeTransformedVertex(rect.GetBottomLeft(), Float2(uvUpperLeft.X, uvBottomRight.Y), color);
|
||||
quad[2] = MakeTransformedVertex(rect.GetUpperLeft(), uvUpperLeft, color);
|
||||
quad[3] = MakeTransformedVertex(rect.GetUpperRight(), Float2(uvBottomRight.X, uvUpperLeft.Y), color);
|
||||
//VB.Write(quad, sizeof(quad));
|
||||
|
||||
uint32 indices[6];
|
||||
RENDER2D_WRITE_IB_QUAD(indices);
|
||||
//uint32 indices[6];
|
||||
uint32* indices = (uint32*)IB.WriteReserve(sizeof(uint32) * 6);
|
||||
indices[0] = VBIndex + 0;
|
||||
indices[1] = VBIndex + 1;
|
||||
indices[2] = VBIndex + 2;
|
||||
indices[3] = VBIndex + 2;
|
||||
indices[4] = VBIndex + 3;
|
||||
indices[5] = VBIndex + 0;
|
||||
//IB.Write(indices, sizeof(indices));
|
||||
//RENDER2D_WRITE_IB_QUAD(indices);
|
||||
|
||||
VBIndex += 4;
|
||||
IBIndex += 6;
|
||||
|
||||
Reference in New Issue
Block a user