Sign in to follow this  
devdept

2 stupid questions

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
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

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