出于某种原因,如果它是指针,我无法将数据存储在数组中。如果我阻止它成为一个指针,它可以完美地工作,但我需要一个包含可变数量的数组,所以它必须是一个指针。这是我的代码。为什么这个数组一次不能存储多个顶点?
MVertex* Vertices = new MVertex[VertexCount];
//MVertex Vertices[4];
string LDum;
getline(Input, LDum);
for (int i = 0; i < 4; i++)
{
MVertex V;
string Line;
getline(Input, Line);
istringstream ISS(Line);
string X, Y, Z;
ISS >> X >> Y >> Z;
V.X = atoi(X.c_str());
V.Y = atoi(Y.c_str());
V.Z = atoi(Z.c_str());
Vertices[i] = V;
}
Input.close();
GraphicsDevice->CreateVertexBuffer(4 * sizeof(MVertex), 0, MFVF,
D3DPOOL_MANAGED, &MVertexBuffer, NULL);
VOID* pVoid;
MVertexBuffer->Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, Vertices, sizeof(Vertices));
MVertexBuffer->Unlock();
int Size = sizeof(Vertices);
delete[] Vertices;