Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

CustomVertex.PositionColored problem

Started by Dratcha Jan 14, 2005 at 1:27 AM 1 replies 1.6k views
Original Post
Dratcha
Dratcha
I am trying to learn DirectX 9 with c# and am going through a tutorial I found which so far has been prety good up until now. To start, I will show the method which is giving me the problems: protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI/4, this.Width/this.Height, 1f, 50f); device.Transform.View = Matrix.LookAtLH(new Vector3(0,0,30), new Vector3(0,0,0), new Vector3(0,1,0)); device.RenderState.Lighting = false; device.RenderState.CullMode = Cull.None; CustomVertex.PositionColored[] vertices = new CustomVertex.PositionColored[3]; vertices[0].SetPosition(new Vector3(0f, 0f, 0f)); vertices[0].Color = Color.Red.ToArgb(); vertices[1].SetPosition(new Vector3(10f, 0f, 0f)); vertices[1].Color = Color.Green.ToArgb(); vertices[2].SetPosition(new Vector3(5f, 100f, 0f)); vertices[2].Color = Color.Yellow.ToArgb(); device.Clear(ClearFlags.Target, Color.DarkSlateBlue, 1.0f, 0); device.BeginScene(); device.VertexFormat = CustomVertex.PositionColored.Format; device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices); device.EndScene(); device.Present(); this.Invalidate(); } The problem is with the vertices[x].SetPosition(new Vector3(0f, 0f, 0f)); When I try to compile, I get the error message: Microsoft.DirectX.Direct3D.CustomVertex.PositionColored does not contain a definition for SetPosition. I have also tried: vertices[x].Position.Add(new Vector3(0f, 0f, 0f)); This doesn't give me an error, but it also doesn't render anything on the screen. Also, I can render the triangle if I use CustomVertex.TransformedColored so I know that is working, but I need to use CustomVertex.PositionColored I don't know if most examples I am following are 8.0 and earlier. Is there another way to do this? Am I doing it right but missing something?
Dave Hunt
Dave Hunt
Try:

vertices[0].X = 0.0f;vertices[0].Y = 0.0f;vertices[0].Z = 0.0f;etc.

andyb716
andyb716
I had that problem and microsoft changed it to
verts[0].Position = new Vector3(0f, 0f, 0f);

thats what I had to do. the poster above I think is right too.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.