I understand that but a sprite is a quad and from what I thought you need 4 unique points for a quad?
This basically means you don’t understand anything your code is doing.
Your idea is that a quad is just a single 4-point primitive, but your code says a quad is a D3DPT_TRIANGLELIST with 2 triangles (3-point primitives) in it in the shape of a quadrilateral.
In other words, you copied and pasted from some tutorial without understanding any of it.
This is true, I currently have a large index buffer and only lock what is needed at rendering (only 2 sprites atm)
Which means only 1 of 2 things: Either you aren’t updating the correct parts or you aren’t using the correct parts.
Simple debugging techniques will tell you which is the case.
Should I initialize every Vertex's value of the VB to 0 on creation? Is there an easy way to do this?
I can only think of something like:if(FAILED( g_pd3dDevice->CreateVertexBuffer( s_nBatchSize * 4 * sizeof( SpriteVertex ), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &m_pVB, NULL ) ) ) { m_pVB = 0;//Prints error msg } //Initialize VB to 0 SpriteVertex* pVertex; m_pVB->Lock(0, 0, (void**)&pVertex, 0); for(uINT i = 0; i < s_nBatchSize * 4 + 1 ; i++) { pVertex[i].vPos = D3DXVECTOR3(0.0f, 0.0f, 0.0f); pVertex[i].Colour = 0; pVertex[i].u1 = 0; pVertex[i].v1 = 0; } m_pVB->Unlock();
That is correct (except s_nBatchSize * 4 + 1) for initializing the whole buffer with 0’s, however looking at your 2nd screenshot the invalid region is already filled with 0’s.
Meaning although this is a good idea it won’t solve your problem.
Was that it?
Still unsure on how I am loosing data, do I need to :memcpy(pVertex, indices, sizeof(indices) / sizeof(indices[0]));
That will only copy less data than before.
L. Spiro