1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
CUSTOMVERTEX *vertices = new CUSTOMVERTEX[3];
//CUSTOMVERTEX vertices[3]; <<--"working" version
vertices[0].pos = D3DXVECTOR3(-1.0f, 0.0f, 0.0f);
vertices[0].COLOR = RED;
vertices[1].pos = D3DXVECTOR3(0.0f, 2.0f, 0.0f);
vertices[1].COLOR = GREEN;
vertices[2].pos = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
vertices[2].COLOR = BLUE;
d3ddev->CreateVertexBuffer(3 * sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL);
VOID* pVoid;
v_buffer->Lock(0, 0, (void**)&pVoid, 0);
//memcpy(pVoid, vertices, sizeof(vertices)); <<--the "working" version
memcpy(pVoid, vertices, 3); <<--is this what you meant?
v_buffer->Unlock();
short indices[] =
{
0,1,2,
};
d3ddev->CreateIndexBuffer(3 * sizeof(short), 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &i_buffer, NULL);
i_buffer->Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, indices, sizeof(indices));
i_buffer->Unlock();
vertices = nullptr;
delete[] vertices;
|