forked from AerysBat/XNALara
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBillboard.cs
36 lines (32 loc) · 1.27 KB
/
Billboard.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using VertexPosTex = Microsoft.Xna.Framework.Graphics.VertexPositionTexture;
namespace XNALara
{
public class Billboard
{
private GraphicsDevice graphicsDevice;
private VertexDeclaration vertexDeclaration;
private VertexPosTex[] vertices;
private short[] indices;
public Billboard(GraphicsDevice graphicsDevice) {
this.graphicsDevice = graphicsDevice;
vertexDeclaration = new VertexDeclaration(graphicsDevice, VertexPosTex.VertexElements);
vertices = new VertexPosTex[] {
new VertexPosTex(Vector3.Zero, new Vector2(0, 0)),
new VertexPosTex(Vector3.Zero, new Vector2(1, 0)),
new VertexPosTex(Vector3.Zero, new Vector2(1, 1)),
new VertexPosTex(Vector3.Zero, new Vector2(0, 1))
};
indices = new short[] {
0, 1, 3,
3, 1, 2
};
}
public void Render() {
graphicsDevice.VertexDeclaration = vertexDeclaration;
graphicsDevice.DrawUserIndexedPrimitives<VertexPosTex>(
PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, 2);
}
}
}