Dynamic VB, Particles, & Triangle Lists

Started by
2 comments, last by duhroach 19 years, 6 months ago
I feel really stupid for asking this, But I haven't been able to figure out the problem: I'm creating a particle system. What I wish to do, is add the verts of each particle to a vertex buffer, then render that entire buffer in one signle "drawPrimitive" call. What's happening, is that it will only draw the very first triangle, and that's all. I know there will be questions about code, So i'll just post it ahead of time..

//Dx9Primitive.cpp

//Create()..
sxDx9Driver::Get_Device()->CreateVertexBuffer(numverts*sizeof(sxPrimVertex),	D3DUSAGE_WRITEONLY, 3DFVF_PRIMVERTEX,D3DPOOL_DEFAULT, m_vertHandle, NULL );

//Lock()..
m_vertHandle->Lock( 0, sizeof(m_inputVerts)*sizeof(sxPrimVertex), (void**)&m_finalVerts,0);

//UnLock()..
memcpy( m_finalVerts, m_inputVerts, sizeof(m_inputVerts)*sizeof(sxPrimVertex) );
 m_vertHandle->Unlock();

//Render()..
sxDx9Driver::Get_Device()->SetStreamSource( 0, m_vertHandle, 0, sizeof(sxPrimVertex) );

	sxDx9Driver::Get_Device()->SetFVF( D3DFVF_PRIMVERTEX );
	sxDx9Driver::Get_Device()->DrawPrimitive( D3DPT_TRIANGLELIST, 0, m_numVerts/3);
	

Everything works fine when I use triangle STRIPS in another class (Identical code except for D3DPT_TRIANGLELIST and number primitives (numverts-2)) I'm really lost on this, And can't find an example of what the heck is going on.. any ideas? ~Main [/source]
==Colt "MainRoach" McAnlisGraphics Engineer - http://mainroach.blogspot.com
Advertisement
sizeof(m_inputVerts)*sizeof(sxPrimVertex) should be m_inputVerts*sizeof(sxPrimVertex), I think.
Hi,

you create the VertexBuffer with the variable 'numverts' and afterwards render it with the variable 'm_numVerts'. Maybe m_numVerts has a value of 3 and therefore 3/3 = 1 triangle.

In addition, you lock and fill it with 'm_inputVerts'. That's three different variables. Perhaps their values do not match. Check the values of all that variables.

Another possibility is this:
'm_inputVerts' seems to be an array. You memcpy a memory chain of the size sizeof(m_inputVerts)*sizeof(sxPrimVertex). When I do a sizeof of an array, the size of one element of that array is returned. Perhaps that is just my setup ?!

Bye,
Leoric

Well I'll be..
Thanks gentlemen, Appriciate the help!

~Main
==Colt "MainRoach" McAnlisGraphics Engineer - http://mainroach.blogspot.com

This topic is closed to new replies.

Advertisement