Riistvara referaat Direct3D
see, et Direct3D on otseselt seotud kuvadraiveritega ja saab paremaid tulemusi
renderdamisel kui GDI.
Direct3D 3 põhilist üldistust: seadmed, vahendid ja swap ketid (vt lisatud skeemi).
Näidised
Kolmnurga joonistamine Direct3D-s :
// A 3-vertex polygon definition
D3DLVERTEX v[3];
// Vertex established
v[0]=D3DLVERTEX( D3DVECTOR(0.f, 5.f, 10.f), 0x00FF0000, 0, 0, 0 );
// Vertex established
v[1]=D3DLVERTEX( D3DVECTOR(0.f, 5.f, 10.f), 0x0000FF00, 0, 0, 0 );
// Vertex established
v[2]=D3DLVERTEX( D3DVECTOR(0.f, 5.f, 10.f), 0x000000FF, 0, 0, 0 );
// Function call to draw the triangle
pDevice->DrawPrimitive( D3DPT_TRIANGLELIST, D3DFVF_LVERTEX, v, 3,
0 );
Kolmnurga joonistamine Direct3D 9:
struct Vertex { float x, y, z; D3DCOLOR color; };
Vertex triangle[] = {
{ 0.f, 5.f, 10.f, 0x00FF0000 },
{ 0.f, 5.f, 10.f, 0x0000FF00 },
{ 0.f, 5.f, 10.f, 0x000000FF }
};
// set Flexible Vertex Format
pDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE);