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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
| |
struct d3dvtx_s {
D3DXVECTOR3 pnt; D3DCOLOR clr; D3DXVECTOR2 tx1; };
const int FVFVTX1_X = (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
d3dvtx_s* VtxSet; unsigned short* VtxIdxSet;
LPDIRECT3DVERTEXBUFFER9 lpVtxBuf; LPDIRECT3DINDEXBUFFER9 lpIdxBuf;
VtxSet = new d3dvtx_s[9];
SetVertex(0, 0.0f, 0.0f, 0.0f, 0xFF00, 0.0f, 0.0f);
SetVertex(1, 1.0f, 0.0f, 0.0f, 0xFF00, 0.0f, 0.0f);
SetVertex(2, 2.0f, 0.0f, 0.0f, 0xFF00, 0.0f, 0.0f);
SetVertex(3, 0.0f, 1.0f, 0.0f, 0xFF00, 0.0f, 0.0f);
SetVertex(4, 1.0f, 1.0f, 0.0f, 0xFF00, 0.0f, 0.0f);
SetVertex(5, 2.0f, 1.0f, 0.0f, 0xFF00, 0.0f, 0.0f);
SetVertex(6, 0.0f, 2.0f, 0.0f, 0xFF00, 0.0f, 0.0f);
SetVertex(7, 1.0f, 2.0f, 0.0f, 0xFF00, 0.0f, 0.0f);
SetVertex(8, 2.0f, 2.0f, 0.0f, 0xFF00, 0.0f, 0.0f);
size_t wsz = 9 * sizeof(d3dvtx_s);
lpD3Ddev->CreateVertexBuffer(wsz, 0, FVFVTX1_X, D3DPOOL_MANAGED, &lpVtxBuf, NULL);
d3dvtx_s* vbuf;
lpVtxBuf->Lock(0, 0, reinterpret_cast<void**>(&vbuf), D3DLOCK_NOSYSLOCK);
memcpy(vbuf, VtxSet, wsz);
lpVtxBuf->Unlock();
VtxIdxSet = new unsigned short[3];
VtxIdxSet[0] = 1;
VtxIdxSet[1] = 3;
VtxIdxSet[2] = 7;
size_t isz = 3 * sizeof(unsigned short);
lpD3Ddev->CreateIndexBuffer(isz, 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &lpIdxBuf, NULL);
unsigned short* ibuf;
lpIdxBuf->Lock(0, 0, reinterpret_cast<void**>(&ibuf), D3DLOCK_NOSYSLOCK);
memcpy(ibuf, VtxIdxSet, isz);
lpIdxBuf->Unlock();
lpD3Ddev->SetIndices(lpIdxBuf);
|