Jump to content
  • Advertisement
Sign in to follow this  
kappa

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

This topic is 4960 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 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, 
				CustomVertex.TransformedColored.Format, 
				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 );
			vb.Unlock();
		}

		private void Render()
		{
			if( dev == null )
				return;

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

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

			dev.EndScene();
			dev.Present();
		}

Share this post


Link to post
Share on other sites
Advertisement
Well, err.. , you draw one triangle and a quad is made of two triangles...

dev.DrawPrimitives( PrimitiveType.TriangleStrip, 0, 1 );

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!