Jump to content
  • Advertisement
Sign in to follow this  

Vertex Buffer problem with C# DX9

This topic is 4901 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been trying for quite some time now to get this vertex buffer to work. All im trying to do is do is draw a single triangle, it worked without the Vertex Buffer but with it it just doesn't draw it. Heres my code: using System; using System.Drawing; using System.Data; using System.Diagnostics; using System.Windows.Forms; using Microsoft.DirectX; using D3D = Microsoft.DirectX.Direct3D; namespace game { public class Form1 : Form { D3D.Device device = null; D3D.VertexBuffer vb = null; protected D3D.CustomVertex.TransformedColored[] data; public Form1() { InitD3D(); this.Size = new Size(800,600); this.Text = "GAME"; } public void InitD3D() { D3D.PresentParameters param = new D3D.PresentParameters(); param.Windowed = true; param.SwapEffect = D3D.SwapEffect.Discard; data = new D3D.CustomVertex.TransformedColored[3]; device = new D3D.Device(0, D3D.DeviceType.Hardware, this, D3D.CreateFlags.SoftwareVertexProcessing, param); vb = new D3D.VertexBuffer(typeof(D3D.CustomVertex.TransformedColored), data.Length, device, D3D.Usage.WriteOnly, D3D.CustomVertex.TransformedColored.Format, D3D.Pool.Managed); data[0].X = 800.0f; data[0].Y = 0.0f; data[0].Z = 1.0f; data[0].Rhw = 1.0f; data[0].Color = Color.Red.ToArgb(); data[1].X = 800.0f; data[1].Y = 600.0f; data[1].Z = 1.0f; data[1].Rhw = 1.0f; data[1].Color = Color.Red.ToArgb(); data[2].X = 0.0f; data[2].Y = 600.0f; data[2].Z = 1.0f; data[2].Rhw = 1.0f; data[2].Color = Color.Red.ToArgb(); vb.SetData(data, 0, D3D.LockFlags.None); } public void Render() { device.VertexFormat = D3D.CustomVertex.TransformedColored.Format; device.Clear(D3D.ClearFlags.Target, Color.Black, 1.0f, 0); device.BeginScene(); device.SetStreamSource(0, vb, 0); device.DrawUserPrimitives(D3D.PrimitiveType.TriangleStrip, 0, data.Length / 3); device.EndScene(); device.Present(); } public static void Main() { Form1 form = new Form1(); form.Show(); while (form.Created) { form.Render(); Application.DoEvents(); } } } } If anyone could help me it would be very appreciated, thank you. Oh, and sorry for the messy code. [Edited by - Wicken on February 15, 2005 3:42:23 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!