Sign in to follow this  

[.net] The final vertice in my quad won't draw?

Recommended Posts

I was following the msdn d3d tutorials on how to draw a triangle and when I was done I thought that I should try to draw a quad too. Now however the fourth corned of it wont draw, whatever I do it's still a triangle. Could someone help me with this? it's probbably something I overlooked.
public void OnCreateDevice(	object Sender, EventArgs e )
			Device dev = (Device)Sender;

			vb = new VertexBuffer( typeof(CustomVertex.TransformedColored), 
				4, dev, 0, 
				Pool.Default );

			vb.Created += new System.EventHandler( this.OnCreateVertexBuffer );
			this.OnCreateVertexBuffer( vb, null );
		public void OnCreateVertexBuffer( object Sender, EventArgs e )
			VertexBuffer vert = (VertexBuffer)Sender;

			GraphicsStream stm = vb.Lock(0,0,0);
			CustomVertex.TransformedColored[] verts = new CustomVertex.TransformedColored[4];
			verts[0].X=150;verts[0].Y=150;verts[0].Z=0.5f;verts[0].Rhw=1;verts[0].Color = System.Drawing.Color.Black.ToArgb();
			verts[1].X=185;verts[1].Y=150;verts[1].Z=0.5f;verts[1].Rhw=1;verts[1].Color = System.Drawing.Color.Brown.ToArgb();
			verts[2].X=185;verts[2].Y=185;verts[2].Z=0.5f;verts[2].Rhw=1;verts[2].Color = System.Drawing.Color.BurlyWood.ToArgb();
			verts[3].X=150;verts[3].Y=185;verts[3].Z=0.5f;verts[3].Rhw=1;verts[3].Color = System.Drawing.Color.Black.ToArgb();
			stm.Write( verts );

		private void Render()
			if( dev == null )

			dev.Clear( ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0 );

			dev.SetStreamSource( 0, vb, 0 );
			dev.VertexFormat = CustomVertex.TransformedColored.Format;
			dev.DrawPrimitives( PrimitiveType.TriangleStrip, 0, 1 );


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this