#### Archived

This topic is now archived and is closed to further replies.

# Garbage DrawPrimitive output

This topic is 5574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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

##### Share on other sites
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

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5
frob
13

• 12
• 9
• 31
• 16
• 9
• ### Forum Statistics

• Total Topics
632612
• Total Posts
3007422

×