The polygons either aren't rendering or aren't visible, I don't know why. Maybe the vertex buffer isn't being loaded from the graphics buffer correctly. Here's the relevant code:
using System;using System.Drawing;using System.Windows.Forms;using Microsoft.DirectX;using Microsoft.DirectX.Direct3D;using Microsoft.DirectX.Generic;using Microsoft.DirectX.Direct3D.CustomVertex;using System.Runtime.InteropServices;class Program : Form{ Device device = null; VertexBuffer vb = null; public void Init() { PresentParameters pp = new PresentParameters(); pp.IsWindowed = true; pp.SwapEffect = SwapEffect.Discard; pp.AutoDepthStencilFormat = DepthFormat.D16; pp.EnableAutoDepthStencil = true; device = new Device(0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, pp); device.Transform.World = Matrix.Identity; device.Transform.View = Matrix.Identity; float aspect = (float)ClientSize.Width / (float)ClientSize.Height; device.Transform.Projection = Matrix.PerspectiveFieldOfViewLeftHanded((float)Math.PI / 3.0f, aspect, 0.1f, 1000.0f); device.RenderState.Lighting = false; device.RenderState.FillMode = FillMode.Solid; device.RenderState.CullMode = Cull.None; device.VertexFormat = PositionColored.Format; vb = new VertexBuffer(device, 6 * Marshal.SizeOf(new PositionColored()), Usage.WriteOnly, PositionColored.Format, Pool.Managed, vb_Created); vb.Created += new EventHandler(vb_Created); vb_Created(vb, null); } void vb_Created(object sender, EventArgs e) { VertexBuffer vb = (VertexBuffer)sender; PositionColored[] vertices = new PositionColored[6]; vertices[0] = new PositionColored(-1.0f, -1.0f, 5.0f, Color.Red.ToArgb()); vertices[1] = new PositionColored(-1.0f, 1.0f, 5.0f, Color.Yellow.ToArgb()); vertices[2] = new PositionColored(1.0f, -1.0f, 5.0f, Color.Green.ToArgb()); vertices[3] = new PositionColored(-1.0f, 1.0f, 5.0f, Color.Violet.ToArgb()); vertices[4] = new PositionColored(1.0f, 1.0f, 5.0f, Color.Blue.ToArgb()); vertices[5] = new PositionColored(1.0f, -1.0f, 5.0f, Color.Orange.ToArgb()); GraphicsBuffer<PositionColored> gb = vb.Lock<PositionColored>(0, 6, LockFlags.None); gb.Write(vertices); vb.Unlock(); } void renderFrame() { device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.LightBlue, 1.0f, 0); device.BeginScene(); device.SetStreamSource(0, vb, 0); device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); device.EndScene(); device.Present(); }}
I can't find anything wrong with this code. I also don't have any comparison, because I can't find any .NET 2.0 documentation for this SDK. If anyone can test this code with .Net 2.0 and the latest SDK and help me find the problem, it would be appreciated.