I have done a framework so far in DirectX 9 and It uses a Single VertexBuffer which draws every texture I load, I have used one Vertex Array which draws every single Texture Quad inside of a Lock and Unlock call. I have heard there is a thing called Batching where I can Lock it once and Unlock when I draw everything. I know I can draw every texture quad in one call to lock and unlock but I have no idea how i can set different textures to each of these. Can Anyone here Guide me ?
vertexBufferRHW->Lock(0, 0, (void**)&VerticesRHW, NULL);
VerticesRHW[0].Color = color;
VerticesRHW[0].X = (float) Position.X;
VerticesRHW[0].Y = (float) Position.Y;
VerticesRHW[0].Z = 0.0f;
VerticesRHW[0].RHW = 1.0f;
VerticesRHW[0].U = 0.0f;
VerticesRHW[0].V = 0.0f;
VerticesRHW[1].Color = color;
VerticesRHW[1].X = (float) (Position.X+TextureFile.Width);
VerticesRHW[1].Y = (float) Position.Y;
VerticesRHW[1].Z = 0.0f;
VerticesRHW[1].RHW = 1.0f;
VerticesRHW[1].U = 1.0f;
VerticesRHW[1].V = 0.0f;
VerticesRHW[2].Color = color;
VerticesRHW[2].X = (float) (Position.X+TextureFile.Width);
VerticesRHW[2].Y = (float) (Position.Y+TextureFile.Height);
VerticesRHW[2].Z = 0.0f;
VerticesRHW[2].RHW = 1.0f;
VerticesRHW[2].U = 1.0f;
VerticesRHW[2].V = 1.0f;
VerticesRHW[3].Color = color;
VerticesRHW[3].X = (float) Position.X ;
VerticesRHW[3].Y = (float) (Position.Y+TextureFile.Height);
VerticesRHW[3].Z = 0.0f;
VerticesRHW[3].RHW = 1.0f;
VerticesRHW[3].U = 0.0f;
VerticesRHW[3].V = 1.0f;
vertexBufferRHW->Unlock();
spriteDevice->SetTexture(0,TextureFile.TextureFile);
spriteDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,0,2);