Skip to main content
gamedev.net
🔒 Locked

Render methods

Started by Mari_p 3 replies 300+ views
Original Post
Mari_p
Mari_p
Compare the following two methods:
for(DWORD i = 0; i < NumMaterials; i++)
			{
				device->SetMaterial(&Materials[i]);
				device->SetTexture(0, Textures[i]);
			
				device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,
											  0,
											  pAttribTable[i].VertexStart,
											  pAttribTable[i].VertexCount,
											  pAttribTable[i].FaceStart*3,
											  pAttribTable[i].FaceCount );
			}
and
for(DWORD i = 0; i < NumMaterials; i++)
			{
				device->SetMaterial(&Materials[i]);
				device->SetTexture(0, Textures[i]);
			
				mesh->DrawSubset(i);
			}
OK, since they are called the same number of times per frame, in this case, what is the difference between them? I rendered my scene using these two methods and I didn''t notice any difference of performance. Thanks for the help.
glassJAw
glassJAw
What is in mesh->DrawSubset()?
Mari_p
Mari_p
...do you mean what is being rendered? A scenery composed of ~50 meshes, each one with ~1000 vertices and some textures.




[edited by - Mari_p on December 28, 2003 12:09:44 AM]
Fidelio66
Fidelio66
A D3DXMESH is just a class that holds an index buffer, vertex buffer and some other stuff. The performance would be the same since they probably do the same.

It might even be worthwhile to use meshes for everything instead of defining and using vertex buffer/index buffer combinations yourself. With a mesh you can use a number of very useful utility functions, like sorting triangles to optimize the cache of the video card, weldvertices to merge points that are the same, normalize to generate averaged normals automatically, an advanced technique to draw it using less triangles (progressive mesh) and easy load/save to/from .x files.

Topic Locked

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

Sign in to reply to this topic.