Garbage DrawPrimitive output

Started by
1 comment, last by Juozasg 20 years, 10 months ago
I've written a simple mesh manager. It uses a vector of pointers to vertex buffers to store the meshes. It fills the VB by using ID3DXMesh and D3DXLoadMeshFromX method. Unfortunately the output of the vb seems to be seriously f'ed up. Here's a simple snippet designed to test the manager

	g_pDirect3DDevice8->SetTexture( 0, textureManager.GetTexture(1,NULL));	//terrain

	g_pDirect3DDevice8->SetVertexShader(meshManager.GetFVFByID(1));
	g_pDirect3DDevice8->SetStreamSource( 0, meshManager.GetVBByID(1), D3DXGetFVFVertexSize(meshManager.GetFVFByID(1)));

	if(KEY_DOWN('T'))
		g_pDirect3DDevice8->DrawPrimitive( D3DPT_TRIANGLELIST , 0, (1089/3) );
	if(KEY_DOWN('L'))
		g_pDirect3DDevice8->DrawPrimitive( D3DPT_LINELIST , 0, (1089/2) );
	if(KEY_DOWN('P'))
		g_pDirect3DDevice8->DrawPrimitive( D3DPT_POINTLIST , 0, 1089 );
Here's the output : Actual mesh (from ModelView) http://juozasg.netfirms.com/mview.png Point list http://juozasg.netfirms.com/point.png Line list http://juozasg.netfirms.com/line.png Triangle list http://juozasg.netfirms.com/tl.jpg I have no idea what's wrong so all suggestions are appreciated. Juozas Gaigalas EDITED: HTML troubles [edited by - Juozasg on June 19, 2003 3:45:40 PM] [edited by - Juozasg on June 19, 2003 3:48:50 PM]
Advertisement
Are you sure that:

1) The data in the D3DX mesh isn''t triangle strips rather than a triangle list ?

2) The mesh isn''t indexed ? [Rendering an indexed mesh as non-indexed would definately give you similar to the output you''re getting]

--
Simon O''Connor
Insert Company Name Here

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Thanks for the respose. I think the indexed vertices are the source of problem. I assumed that unless I request for the index buffer, the vertices in the VB will be ready to use by the DrawPrimitive().

Do I need to use GetIndexBuffer() after loading a mesh, and then keep a copy of IB as well as VB (and SetIndices() on render), or is there a way to load the data into VB without worrying about indeces?


Both strips and lists give the same invalid picture, btw.




Juozas Gaigalas

This topic is closed to new replies.

Advertisement