2023-05-13 15:17:23 +02:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Quik.CommandQueue
|
|
|
|
{
|
|
|
|
public class CommandQueue : Queue<Frame>
|
|
|
|
{
|
|
|
|
public void Invoke(QuikCommandHandler handler)
|
|
|
|
{
|
|
|
|
Enqueue(Command.Invoke);
|
|
|
|
Enqueue(new Frame(handler));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ConditionalBegin(bool value)
|
|
|
|
{
|
|
|
|
Enqueue(Command.ConditionalBegin);
|
|
|
|
Enqueue((Frame)(value ? 1 : 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ConditionalBegin(Func<bool> condition)
|
|
|
|
{
|
|
|
|
Enqueue(Command.ConditionalBegin);
|
|
|
|
Enqueue(new Frame(condition));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ConditionalEnd()
|
|
|
|
{
|
|
|
|
Enqueue(Command.ConditionalEnd);
|
|
|
|
}
|
|
|
|
|
2023-05-14 22:32:32 +02:00
|
|
|
public void PushViewport()
|
2023-05-13 15:17:23 +02:00
|
|
|
{
|
|
|
|
Enqueue(Command.PushViewport);
|
2023-05-14 22:32:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void IntersectViewport(in QuikRectangle viewport)
|
|
|
|
{
|
|
|
|
Enqueue(Command.IntersectViewport);
|
2023-05-13 15:17:23 +02:00
|
|
|
Enqueue(viewport);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void StoreViewport(in QuikRectangle viewport)
|
|
|
|
{
|
|
|
|
Enqueue(Command.StoreViewport);
|
|
|
|
Enqueue(viewport);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PopViewport()
|
|
|
|
{
|
|
|
|
Enqueue(Command.PopViewport);
|
|
|
|
}
|
|
|
|
|
2023-05-14 22:32:32 +02:00
|
|
|
public void PushZ()
|
|
|
|
{
|
|
|
|
Enqueue(Command.PushZ);
|
|
|
|
}
|
|
|
|
|
2023-05-13 15:17:23 +02:00
|
|
|
public void IncrementZ()
|
|
|
|
{
|
|
|
|
Enqueue(Command.IncrementZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void AddZ(int value)
|
|
|
|
{
|
|
|
|
if (value == 1)
|
|
|
|
{
|
|
|
|
IncrementZ();
|
|
|
|
}
|
|
|
|
else if (value == -1)
|
|
|
|
{
|
|
|
|
DecrementZ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Enqueue(Command.AddZ);
|
|
|
|
Enqueue((Frame)value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void StoreZ(int value)
|
|
|
|
{
|
|
|
|
Enqueue(Command.StoreZ);
|
|
|
|
Enqueue((Frame)value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DecrementZ()
|
|
|
|
{
|
|
|
|
Enqueue(Command.DecrementZ);
|
|
|
|
}
|
|
|
|
|
2023-05-14 22:32:32 +02:00
|
|
|
public void PopZ()
|
|
|
|
{
|
|
|
|
Enqueue(Command.PopZ);
|
|
|
|
}
|
|
|
|
|
2023-05-13 15:17:23 +02:00
|
|
|
public void Line(in QuikLine line)
|
|
|
|
{
|
|
|
|
Enqueue(Command.Line);
|
|
|
|
Enqueue(line);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Line(params QuikLine[] lines)
|
|
|
|
{
|
|
|
|
Enqueue(Command.Line);
|
|
|
|
Enqueue((Frame)lines.Length);
|
|
|
|
foreach (QuikLine line in lines)
|
|
|
|
Enqueue(line);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Bezier(in QuikBezier bezier)
|
|
|
|
{
|
|
|
|
Frame a, b;
|
|
|
|
Frame.Create(bezier, out a, out b);
|
|
|
|
|
|
|
|
Enqueue(Command.Bezier);
|
|
|
|
Enqueue(a);
|
|
|
|
Enqueue(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Bezier(params QuikBezier[] beziers)
|
|
|
|
{
|
|
|
|
Frame a, b;
|
|
|
|
|
|
|
|
Enqueue(Command.Bezier);
|
|
|
|
Enqueue((Frame)beziers.Length);
|
|
|
|
|
|
|
|
foreach (QuikBezier bezier in beziers)
|
|
|
|
{
|
|
|
|
Frame.Create(bezier, out a, out b);
|
|
|
|
Enqueue(a);
|
|
|
|
Enqueue(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Rectangle(in QuikRectangle rectangle)
|
|
|
|
{
|
|
|
|
Enqueue(Command.Rectangle);
|
|
|
|
Enqueue(rectangle);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Rectangle(QuikRectangle[] rectangles)
|
|
|
|
{
|
|
|
|
Enqueue(Command.Rectangle);
|
|
|
|
Enqueue((Frame)rectangles.Length);
|
|
|
|
foreach (QuikRectangle rectangle in rectangles)
|
|
|
|
Enqueue(rectangle);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Ellipse(in QuikEllipse ellipse)
|
|
|
|
{
|
|
|
|
Frame a, b;
|
|
|
|
Frame.Create(ellipse, out a, out b);
|
|
|
|
|
|
|
|
Enqueue(Command.Ellipse);
|
|
|
|
Enqueue(a);
|
|
|
|
Enqueue(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Ellipse(params QuikEllipse[] ellipses)
|
|
|
|
{
|
|
|
|
Frame a, b;
|
|
|
|
Enqueue(Command.Ellipse);
|
|
|
|
Enqueue((Frame)ellipses.Length);
|
|
|
|
foreach (QuikEllipse ellipse in ellipses)
|
|
|
|
{
|
|
|
|
Frame.Create(ellipse, out a, out b);
|
|
|
|
Enqueue(a);
|
|
|
|
Enqueue(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Triangle(in QuikTriangle triangle)
|
|
|
|
{
|
|
|
|
Enqueue(Command.Triangle);
|
|
|
|
Enqueue(triangle.A);
|
|
|
|
Enqueue(triangle.B);
|
|
|
|
Enqueue(triangle.C);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Triangle(params QuikTriangle[] triangles)
|
|
|
|
{
|
|
|
|
Enqueue(Command.Triangle);
|
|
|
|
Enqueue((Frame)triangles.Length);
|
|
|
|
foreach (QuikTriangle triangle in triangles)
|
|
|
|
{
|
|
|
|
Enqueue(triangle.A);
|
|
|
|
Enqueue(triangle.B);
|
|
|
|
Enqueue(triangle.C);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Polygon(params QuikVec2[] polygon)
|
|
|
|
{
|
|
|
|
Enqueue(Command.Polygon);
|
|
|
|
Enqueue((Frame)polygon.Length);
|
|
|
|
foreach (QuikVec2 vertex in polygon)
|
|
|
|
{
|
|
|
|
Enqueue(vertex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-15 20:49:48 +02:00
|
|
|
public void Image(QuikTexture texture, in QuikRectangle rectangle)
|
2023-05-13 15:17:23 +02:00
|
|
|
{
|
|
|
|
Enqueue(Command.Image);
|
|
|
|
Enqueue((Frame)(int)ImageCommandFlags.Single);
|
|
|
|
Enqueue(new Frame(texture));
|
|
|
|
Enqueue(rectangle);
|
|
|
|
}
|
|
|
|
|
2023-05-15 20:49:48 +02:00
|
|
|
public void Image(QuikTexture texture, in QuikRectangle rectangle, in QuikRectangle uv)
|
2023-05-13 15:17:23 +02:00
|
|
|
{
|
|
|
|
Enqueue(Command.Image);
|
|
|
|
Enqueue((Frame)(int)(ImageCommandFlags.Single | ImageCommandFlags.UVs));
|
|
|
|
Enqueue(new Frame(texture));
|
|
|
|
Enqueue(rectangle);
|
|
|
|
Enqueue(uv);
|
|
|
|
}
|
|
|
|
|
2023-05-15 20:49:48 +02:00
|
|
|
public void Image(QuikTexture texture, QuikRectangle[] rectangles, bool interleavedUV = false)
|
2023-05-13 15:17:23 +02:00
|
|
|
{
|
|
|
|
ImageCommandFlags flags = interleavedUV ? ImageCommandFlags.UVs : ImageCommandFlags.None;
|
|
|
|
|
|
|
|
Enqueue(Command.Image);
|
|
|
|
Enqueue(new Frame((int)flags, rectangles.Length / 2));
|
|
|
|
Enqueue(new Frame(texture));
|
|
|
|
|
|
|
|
foreach (QuikRectangle rectangle in rectangles)
|
|
|
|
{
|
|
|
|
Enqueue(rectangle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-15 20:49:48 +02:00
|
|
|
public void Image(QuikTexture texture, QuikRectangle[] rectangles, QuikRectangle[] uvs)
|
2023-05-13 15:17:23 +02:00
|
|
|
{
|
|
|
|
int count = Math.Min(rectangles.Length, uvs.Length);
|
|
|
|
Enqueue(Command.Image);
|
|
|
|
Enqueue(new Frame((int)ImageCommandFlags.UVs, count));
|
|
|
|
Enqueue(new Frame(texture));
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
Enqueue(rectangles[i]);
|
|
|
|
Enqueue(uvs[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|