到目前为止,我已经在 DirectX 9 中完成了一个框架,它使用单个 VertexBuffer 来绘制我加载的每个纹理,我使用了一个顶点数组来绘制 Lock 和 Unlock 调用中的每个纹理 Quad。我听说有一种叫做批处理的东西,我可以将它锁定一次,然后在我绘制所有内容时解锁。我知道我可以在一次调用中绘制每个纹理四边形来锁定和解锁,但我不知道如何为每个纹理设置不同的纹理。这里有人可以指导我吗?
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);