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 32 33 34 35 36 37 38 39 40 41
|
const
vertices: array[0..3] of TCustomVertex = (
(x: -10.0; y: -10.0; z: 0; color: $00000000), // x, y, z, rhw, color),
(x: -10.0; y: 10.0; z: 0; color: $00000000),
(x: 10.0; y: -10.0; z: 0; color: $00000000),
(x: 10.0; y: 10.0; z: 0; color: $00000000)
);
index: array[0..5] of integer = ( 0,1,2,3,1,2 );
var
pVertices: Pointer;
pIndex: Pointer;
begin
Result:= E_FAIL;
if FAILED(g_pd3dDevice.CreateVertexBuffer(4*SizeOf(TCustomVertex),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, g_pVB, nil))
then Exit;
vertex
if FAILED(g_pVB.Lock(0, SizeOf(vertices), pVertices, 0))
then Exit;
CopyMemory(pVertices, @vertices, SizeOf(vertices));
g_pVB.Unlock;
if FAILED(g_pd3dDevice.CreateIndexBuffer(sizeof(integer) * 6,D3DUSAGE_WRITEONLY,
D3DFMT_INDEX32,
D3DPOOL_MANAGED,
g_pIB, nil))
then Exit;
g_pIB.Lock(0,SizeOf(index), pIndex, 0);
CopyMemory(pIndex, @index, SizeOf(index));
g_pIB.Unlock;
Result:= S_OK; |
Partager