Game Development Reference
In-Depth Information
y += timeDelta;
// reset angle to zero when angle reaches 2*PI
if( y >= 6.28f )
y = 0.0f;
// combine rotations
D3DXMATRIXp=Rx*Ry;
Device->SetTransform(D3DTS_WORLD, &p);
//
// draw the scene:
//
Device->Clear(0, 0,
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
0xffffffff, 1.0f, 0);
Device->BeginScene();
Device->SetStreamSource(0, VB, 0, sizeof(Vertex));
Device->SetIndices(IB);
Device->SetFVF(Vertex::FVF);
Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
0, 0, 8, 0, 12);
Device->EndScene();
Device->Present(0, 0, 0, 0);
}
return true;
}
Finally, we clean up any memory that we have allocated. This means
releasing the vertex and index buffer interfaces:
void Cleanup()
{
d3d::Release<IDirect3DVertexBuffer9*>(VB);
d3d::Release<IDirect3DIndexBuffer9*>(IB);
}
3.7 Summary
Vertex data is stored in the IDirect3DVertexBuffer9 inter-
face. Similarly, index data is stored in the IDirect3DIndex-
Buffer9 interface. The reason for using vertex/index buffers is
that the data can be stored in video memory.
Geometry that is static (that is, does not need to be updated every
frame) should be stored in a static vertex/index buffer. On the other
hand, geometry that is dynamic (that is, does need to get updated
every frame) should be stored in a dynamic vertex/index buffer.
Search WWH ::




Custom Search