Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
I am trying to learn D3D, mostly by looking at tutorials, sample projects etc...
I have made a render function, trying to render a simple triangle. It compiles and runs ok, but there is no triangle, only the black background color!? It is probably just a tiny thing I've forgotten, but I am just not able to figure out what I've forgotten! Any help is greatly appreciated!
public void Render()
device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);
CustomVertex.PositionColored vert = new CustomVertex.PositionColored;
vert.X = -1.0f; vert.Y = -1.0f; vert.Z = 0.0f; vert.Color = Color.Blue.ToArgb();
vert.X = 1.0f; vert.Y = -1.0f; vert.Z = 0.0f; vert.Color = Color.Blue.ToArgb();
vert.X = 0.0f; vert.Y = 1.0f; vert.Z = 0.0f; vert.Color = Color.Blue.ToArgb();
VertexBuffer vb = new VertexBuffer(typeof(CustomVertex.PositionColored), vert.Length, device, Usage.None, CustomVertex.PositionColored.Format, Pool.Managed);
GraphicsStream stm = vb.Lock(0, 0, 0);
device.SetStreamSource(0, vb, 0);
device.VertexFormat = CustomVertex.PositionColored.Format;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);