I have created billboard class but it's drawing one single billboard per draw call, now I want to it draw ALL the billboards with one draw call.
I'm creating the vertex buffer as the following:
// Class Constructor
float scale = 20.0f;
device->CreateVertexBuffer(4 * sizeof(BILLBOARD_VERTEX),
D3DUSAGE_WRITEONLY,
CustomBillboardFVF,
D3DPOOL_DEFAULT,
&vbuffer,
NULL);
vbuffer->Lock(0, 0, (void**)&vertices, 0);
pVertices[0] = BILLBOARD_VERTEX(D3DXVECTOR3(-1.0f*scale, 1.0f*scale, 0.0f), 0.0f, 0.0f);
pVertices[1] = BILLBOARD_VERTEX(D3DXVECTOR3(1.0f*scale, 1.0f*scale, 0.0f), 1.0f, 0.0f);
pVertices[2] = BILLBOARD_VERTEX(D3DXVECTOR3(-1.0f*scale, -1.0f*scale, 0.0f), 0.0f, 1.0f);
pVertices[3] = BILLBOARD_VERTEX(D3DXVECTOR3(1.0f*scale, -1.0f*scale, 0.0f), 1.0f, 1.0f);
vbuffer->Unlock();
For rendering:
void render()
{
device->SetFVF(CustomBillboardFVF);
device->SetTexture(0, billboardTexture);
device->SetStreamSource(0, vbuffer, 0, sizeof(BILLBOARD_VERTEX));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
}
I'm storing the billboards in vector<billboard>.
How do I change my code to render all the billboards with one single draw call?