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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
g_pD3DDevice->CreateVertexBuffer(8 * sizeof(Vertex), 0, D3DFVF_DIFFUSE | D3DFVF_XYZ | D3DFVF_TEX1,
D3DPOOL_DEFAULT, &g_pVertBuff, NULL);
g_pD3DDevice->CreateIndexBuffer(36 * sizeof(int), 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &g_pIndexBuff, NULL);
Vertex* pVertices;
WORD* pIndices;
g_pVertBuff->Lock(0, 0, (void**) (&pVertices), D3DLOCK_NOSYSLOCK);
g_pIndexBuff->Lock(0, 0, (void**) (&pIndices), D3DLOCK_NOSYSLOCK);
D3DVECTOR vTemp;
vTemp.x = -1.0f;
vTemp.y = 1.0f;
vTemp.z = -1.0f;
pVertices[0].vPosition = vTemp;
vTemp.x = -1.0f;
vTemp.y = 1.0f;
vTemp.z = 1.0f;
pVertices[1].vPosition = vTemp;
vTemp.x = 1.0f;
vTemp.y = 1.0f;
vTemp.z = 1.0f;
pVertices[2].vPosition = vTemp;
vTemp.x = 1.0f;
vTemp.y = 1.0f;
vTemp.z = -1.0f;
pVertices[3].vPosition = vTemp;
vTemp.x = -1.0f;
vTemp.y = -1.0f;
vTemp.z = -1.0f;
pVertices[4].vPosition = vTemp;
vTemp.x = -1.0f;
vTemp.y = -1.0f;
vTemp.z = 1.0f;
pVertices[5].vPosition = vTemp;
vTemp.x = 1.0f;
vTemp.y = -1.0f;
vTemp.z = 1.0f;
pVertices[6].vPosition = vTemp;
vTemp.x = 1.0f;
vTemp.y = -1.0f;
vTemp.z = -1.0f;
pVertices[7].vPosition = vTemp;
pVertices[0].color = D3DCOLOR_XRGB(255, 255, 0);
pVertices[0].u = -1.0f;
pVertices[0].v = 0.0f;
pVertices[1].color = D3DCOLOR_XRGB(0, 255, 255);
pVertices[1].u = -1.0f;
pVertices[1].v = 0.0f;
pVertices[2].color = D3DCOLOR_XRGB(255, 0, 255);
pVertices[2].u = 0.0f;
pVertices[2].v = -0.5f;
pVertices[3].color = D3DCOLOR_XRGB(0, 255, 255);
pVertices[3].u = -0.5f;
pVertices[3].v = 1.0f;
pVertices[4].color = D3DCOLOR_XRGB(255, 255, 0);
pVertices[4].u = -0.3f;
pVertices[4].v = 0.0f;
pVertices[5].color = D3DCOLOR_XRGB(255, 0, 255);
pVertices[5].u = 0.8f;
pVertices[5].v = 0.3f;
pVertices[6].color = D3DCOLOR_XRGB(0, 255, 255);
pVertices[6].u = -0.1f;
pVertices[6].v = 0.2f;
pVertices[7].color = D3DCOLOR_XRGB(0, 255, 0);
pVertices[7].u = -0.4f;
pVertices[7].v = 0.5f;
int aiIndex[36] = {0, 3, 7, 0, 7, 4, // Vorderseite
2, 1, 5, 2, 5, 6, // Hinterseite
1, 0, 4, 1, 4, 5, // Linke Seite
3, 2, 6, 3, 6, 7, // Rechte Seite
0, 1, 2, 0, 2, 3, // Oberseite
6, 5, 4, 6, 4, 7}; // Unterseite
for(int i = 0; i < 36; i++)
{
pIndices[i] = (WORD) aiIndex[i];
}
g_pVertBuff->Unlock();
g_pIndexBuff->Unlock();
-------------------schnipp-----------
//Zeichnen des Dreiecks
if(FAILED(result = g_pD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 8,0, 12)))
{
MessageBox(NULL, L"FEhler", L"Fehler", MB_ICONERROR);
}
|