Jump to content
  • Advertisement
Sign in to follow this  
devdept

2 stupid questions

This topic is 4058 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

Hi All, 1) I know that I can draw a triangle this way: verts[0].X=150; verts[0].Y=50; verts[0].Z=0.5f; verts[0].Rhw=1; verts[0].Color = System.Drawing.Color.Aqua.ToArgb(); verts[1].X=250; verts[1].Y=250; verts[1].Z=0.5f; verts[1].Rhw=1; verts[1].Color = System.Drawing.Color.Brown.ToArgb(); verts[2].X=50; verts[2].Y=250; verts[2].Z=0.5f; verts[2].Rhw=1; verts[2].Color = System.Drawing.Color.LightPink.ToArgb(); Suppose that my triangle has only one solid color, is there not a more efficient way to specify it? (one time, instead of 3 times) 2) I can draw the triangle this way: device.SetStreamSource(0, vertexBuffer, 0); device.VertexFormat = CustomVertex.TransformedColored.Format; device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1); How can I draw one line, than a triangle, than a point? Should I call the DrawPrimitives each time with a different Primitive type? Is there no way to make the vertexBuffer to know what entity it has to draw?!? Thanks a lot, Alberto

Share this post


Link to post
Share on other sites
Advertisement
1) Not really. If you're drawing all the triangles in the batch the same colour, then you can do:
pDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
and then set the colour of the triangles in the material, but that's likely to be less efficient than just specifying a colour per-vertex.

2) No, a vertex buffer is a collection of vertices, not primitives. Which is why it's called a vertex buffer and not a primitive buffer / geometry buffer [smile]
Anyway this wouldn't be any more efficient.

Share this post


Link to post
Share on other sites
So I always specify color per vertex even if they are all the same.

This is true also for a Mesh with 1000 vertices and one color?


Thanks again,

Alberto

Share this post


Link to post
Share on other sites
Quote:
Original post by devdept
So I always specify color per vertex even if they are all the same.

This is true also for a Mesh with 1000 vertices and one color?


Thanks again,

Alberto
If the mesh doesn't have a texture, yes. Otherwise you'd probably just not bother specifying a vertex colour and use the material colour instead.

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!