Sign in to follow this  

Dynamic VB, Particles, & Triangle Lists

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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