Open DoogeJ opened 4 years ago
This draws a (secretly 3D) triangle:
VertexPositionColor[] _vertexPositionColors = new[]
{
new VertexPositionColor(new Vector3(0, 1, 0), Color.Red),
new VertexPositionColor(new Vector3(1, -1, 0), Color.Green),
new VertexPositionColor(new Vector3(-1, -1, 0), Color.Blue)
};
BasicEffect effect = new BasicEffect(GraphicsDevice);
effect.World = Matrix.Identity;
effect.View = Matrix.CreateLookAt(new Vector3(0, 0, 5), Vector3.Zero, Vector3.Up);
float aspect = (float)Window.ClientBounds.Width / (float)Window.ClientBounds.Height;
effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect, 1, 100);
effect.VertexColorEnabled = true;
effect.CurrentTechnique.Passes[0].Apply();
GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, _vertexPositionColors, 0, 1);
Triangles are useful!
It would be nice to have a version with line thickness and a solid one.
https://en.wikipedia.org/wiki/Triangle
https://gamedev.stackexchange.com/questions/31047/how-do-i-draw-a-single-triangle-with-xna-and-fill-it-with-a-texture
http://rbwhitaker.wikidot.com/drawing-triangles