Add a secondary texture coordinate to Vertex.
This commit is contained in:
@@ -69,12 +69,12 @@ namespace OpenRA.Graphics
|
||||
var eb = endColor.B / 255.0f;
|
||||
var ea = endColor.A / 255.0f;
|
||||
|
||||
vertices[nv++] = new Vertex(start - corner + Offset, sr, sg, sb, sa);
|
||||
vertices[nv++] = new Vertex(start + corner + Offset, sr, sg, sb, sa);
|
||||
vertices[nv++] = new Vertex(end + corner + Offset, er, eg, eb, ea);
|
||||
vertices[nv++] = new Vertex(end + corner + Offset, er, eg, eb, ea);
|
||||
vertices[nv++] = new Vertex(end - corner + Offset, er, eg, eb, ea);
|
||||
vertices[nv++] = new Vertex(start - corner + Offset, sr, sg, sb, sa);
|
||||
vertices[nv++] = new Vertex(start - corner + Offset, sr, sg, sb, sa, 0, 0);
|
||||
vertices[nv++] = new Vertex(start + corner + Offset, sr, sg, sb, sa, 0, 0);
|
||||
vertices[nv++] = new Vertex(end + corner + Offset, er, eg, eb, ea, 0, 0);
|
||||
vertices[nv++] = new Vertex(end + corner + Offset, er, eg, eb, ea, 0, 0);
|
||||
vertices[nv++] = new Vertex(end - corner + Offset, er, eg, eb, ea, 0, 0);
|
||||
vertices[nv++] = new Vertex(start - corner + Offset, sr, sg, sb, sa, 0, 0);
|
||||
}
|
||||
|
||||
public void DrawLine(float2 start, float2 end, float width, Color color)
|
||||
@@ -93,12 +93,12 @@ namespace OpenRA.Graphics
|
||||
var b = color.B / 255.0f;
|
||||
var a = color.A / 255.0f;
|
||||
|
||||
vertices[nv++] = new Vertex(start - corner + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(start + corner + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(end + corner + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(end + corner + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(end - corner + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(start - corner + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(start - corner + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(start + corner + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(end + corner + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(end + corner + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(end - corner + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(start - corner + Offset, r, g, b, a, 0, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -186,12 +186,12 @@ namespace OpenRA.Graphics
|
||||
if (nv + 6 > renderer.TempBufferSize)
|
||||
Flush();
|
||||
|
||||
vertices[nv++] = new Vertex(ca + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(cb + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(cc + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(cc + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(cd + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(ca + Offset, r, g, b, a);
|
||||
vertices[nv++] = new Vertex(ca + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(cb + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(cc + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(cc + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(cd + Offset, r, g, b, a, 0, 0);
|
||||
vertices[nv++] = new Vertex(ca + Offset, r, g, b, a, 0, 0);
|
||||
|
||||
// Advance line segment
|
||||
end = next;
|
||||
@@ -243,12 +243,12 @@ namespace OpenRA.Graphics
|
||||
var cb = color.B / 255.0f;
|
||||
var ca = color.A / 255.0f;
|
||||
|
||||
vertices[nv++] = new Vertex(a + Offset, cr, cg, cb, ca);
|
||||
vertices[nv++] = new Vertex(b + Offset, cr, cg, cb, ca);
|
||||
vertices[nv++] = new Vertex(c + Offset, cr, cg, cb, ca);
|
||||
vertices[nv++] = new Vertex(c + Offset, cr, cg, cb, ca);
|
||||
vertices[nv++] = new Vertex(d + Offset, cr, cg, cb, ca);
|
||||
vertices[nv++] = new Vertex(a + Offset, cr, cg, cb, ca);
|
||||
vertices[nv++] = new Vertex(a + Offset, cr, cg, cb, ca, 0, 0);
|
||||
vertices[nv++] = new Vertex(b + Offset, cr, cg, cb, ca, 0, 0);
|
||||
vertices[nv++] = new Vertex(c + Offset, cr, cg, cb, ca, 0, 0);
|
||||
vertices[nv++] = new Vertex(c + Offset, cr, cg, cb, ca, 0, 0);
|
||||
vertices[nv++] = new Vertex(d + Offset, cr, cg, cb, ca, 0, 0);
|
||||
vertices[nv++] = new Vertex(a + Offset, cr, cg, cb, ca, 0, 0);
|
||||
}
|
||||
|
||||
public void FillEllipse(RectangleF r, Color color, int vertices = 32)
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Graphics
|
||||
for (var i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
var v = vertices[i];
|
||||
vertices[i] = new Vertex(v.X, v.Y, v.Z, v.U, v.V, palette.TextureIndex, v.C);
|
||||
vertices[i] = new Vertex(v.X, v.Y, v.Z, v.S, v.T, v.U, v.V, palette.TextureIndex, v.C);
|
||||
}
|
||||
|
||||
for (var row = 0; row < map.MapSize.Y; row++)
|
||||
|
||||
@@ -35,12 +35,12 @@ namespace OpenRA.Graphics
|
||||
if (r.Sheet.Type == SheetType.DualIndexed)
|
||||
attribC *= -1;
|
||||
|
||||
vertices[nv] = new Vertex(a, r.Left, r.Top, paletteTextureIndex, attribC);
|
||||
vertices[nv + 1] = new Vertex(b, r.Right, r.Top, paletteTextureIndex, attribC);
|
||||
vertices[nv + 2] = new Vertex(c, r.Right, r.Bottom, paletteTextureIndex, attribC);
|
||||
vertices[nv + 3] = new Vertex(c, r.Right, r.Bottom, paletteTextureIndex, attribC);
|
||||
vertices[nv + 4] = new Vertex(d, r.Left, r.Bottom, paletteTextureIndex, attribC);
|
||||
vertices[nv + 5] = new Vertex(a, r.Left, r.Top, paletteTextureIndex, attribC);
|
||||
vertices[nv] = new Vertex(a, r.Left, r.Top, 0, 0, paletteTextureIndex, attribC);
|
||||
vertices[nv + 1] = new Vertex(b, r.Right, r.Top, 0, 0, paletteTextureIndex, attribC);
|
||||
vertices[nv + 2] = new Vertex(c, r.Right, r.Bottom, 0, 0, paletteTextureIndex, attribC);
|
||||
vertices[nv + 3] = new Vertex(c, r.Right, r.Bottom, 0, 0, paletteTextureIndex, attribC);
|
||||
vertices[nv + 4] = new Vertex(d, r.Left, r.Bottom, 0, 0, paletteTextureIndex, attribC);
|
||||
vertices[nv + 5] = new Vertex(a, r.Left, r.Top, 0, 0, paletteTextureIndex, attribC);
|
||||
}
|
||||
|
||||
public static void FastCopyIntoChannel(Sprite dest, byte[] src) { FastCopyIntoChannel(dest, 0, src); }
|
||||
|
||||
@@ -16,14 +16,15 @@ namespace OpenRA.Graphics
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vertex
|
||||
{
|
||||
public readonly float X, Y, Z, U, V, P, C;
|
||||
public readonly float X, Y, Z, S, T, U, V, P, C;
|
||||
|
||||
public Vertex(float3 xyz, float u, float v, float p, float c)
|
||||
: this(xyz.X, xyz.Y, xyz.Z, u, v, p, c) { }
|
||||
public Vertex(float3 xyz, float s, float t, float u, float v, float p, float c)
|
||||
: this(xyz.X, xyz.Y, xyz.Z, s, t, u, v, p, c) { }
|
||||
|
||||
public Vertex(float x, float y, float z, float u, float v, float p, float c)
|
||||
public Vertex(float x, float y, float z, float s, float t, float u, float v, float p, float c)
|
||||
{
|
||||
X = x; Y = y; Z = z;
|
||||
S = s; T = t;
|
||||
U = u; V = v;
|
||||
P = p; C = c;
|
||||
}
|
||||
|
||||
@@ -95,12 +95,12 @@ namespace OpenRA.Graphics
|
||||
var channelC = ChannelSelect[(int)s.Channel + 1];
|
||||
return new Vertex[6]
|
||||
{
|
||||
new Vertex(coord(0, 0), s.Left, s.Top, channelP, channelC),
|
||||
new Vertex(coord(su, 0), s.Right, s.Top, channelP, channelC),
|
||||
new Vertex(coord(su, sv), s.Right, s.Bottom, channelP, channelC),
|
||||
new Vertex(coord(su, sv), s.Right, s.Bottom, channelP, channelC),
|
||||
new Vertex(coord(0, sv), s.Left, s.Bottom, channelP, channelC),
|
||||
new Vertex(coord(0, 0), s.Left, s.Top, channelP, channelC)
|
||||
new Vertex(coord(0, 0), s.Left, s.Top, 0, 0, channelP, channelC),
|
||||
new Vertex(coord(su, 0), s.Right, s.Top, 0, 0, channelP, channelC),
|
||||
new Vertex(coord(su, sv), s.Right, s.Bottom, 0, 0, channelP, channelC),
|
||||
new Vertex(coord(su, sv), s.Right, s.Bottom, 0, 0, channelP, channelC),
|
||||
new Vertex(coord(0, sv), s.Left, s.Bottom, 0, 0, channelP, channelC),
|
||||
new Vertex(coord(0, 0), s.Left, s.Top, 0, 0, channelP, channelC)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user