optimize mesh sprite index buffer
parent
ca6c91446e
commit
46f2cad81a
|
@ -6,6 +6,15 @@ namespace Kav
|
||||||
public class MeshSprite
|
public class MeshSprite
|
||||||
{
|
{
|
||||||
private static readonly int PixelScale = 40;
|
private static readonly int PixelScale = 40;
|
||||||
|
private static readonly short[] Indices = new short[]
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
2
|
||||||
|
};
|
||||||
|
|
||||||
public IndexBuffer IndexBuffer { get; }
|
public IndexBuffer IndexBuffer { get; }
|
||||||
public VertexBuffer VertexBuffer { get; }
|
public VertexBuffer VertexBuffer { get; }
|
||||||
|
@ -29,7 +38,7 @@ namespace Kav
|
||||||
6,
|
6,
|
||||||
BufferUsage.WriteOnly
|
BufferUsage.WriteOnly
|
||||||
);
|
);
|
||||||
IndexBuffer.SetData(GenerateIndexArray());
|
IndexBuffer.SetData(Indices);
|
||||||
|
|
||||||
VertexBuffer = new VertexBuffer(
|
VertexBuffer = new VertexBuffer(
|
||||||
graphicsDevice,
|
graphicsDevice,
|
||||||
|
@ -56,7 +65,7 @@ namespace Kav
|
||||||
6,
|
6,
|
||||||
BufferUsage.WriteOnly
|
BufferUsage.WriteOnly
|
||||||
);
|
);
|
||||||
IndexBuffer.SetData(GenerateIndexArray());
|
IndexBuffer.SetData(Indices);
|
||||||
|
|
||||||
VertexBuffer = new VertexBuffer(
|
VertexBuffer = new VertexBuffer(
|
||||||
graphicsDevice,
|
graphicsDevice,
|
||||||
|
@ -67,18 +76,6 @@ namespace Kav
|
||||||
VertexBuffer.SetData(GenerateVertexArray(Texture));
|
VertexBuffer.SetData(GenerateVertexArray(Texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static short[] GenerateIndexArray()
|
|
||||||
{
|
|
||||||
short[] result = new short[6];
|
|
||||||
result[0] = 0;
|
|
||||||
result[1] = 1;
|
|
||||||
result[2] = 2;
|
|
||||||
result[3] = 1;
|
|
||||||
result[4] = 3;
|
|
||||||
result[5] = 2;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static VertexPositionNormalTexture[] GenerateVertexArray(Texture2D texture)
|
private static VertexPositionNormalTexture[] GenerateVertexArray(Texture2D texture)
|
||||||
{
|
{
|
||||||
VertexPositionNormalTexture[] result = new VertexPositionNormalTexture[4];
|
VertexPositionNormalTexture[] result = new VertexPositionNormalTexture[4];
|
||||||
|
|
Loading…
Reference in New Issue