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
|
HRESULT D3DGraphic::InitD3D(HWND hWnd)
{
this->d3d=Direct3DCreate9(D3D_SDK_VERSION);
ZeroMemory(&this->d3dpp, sizeof(this->d3dpp));
this->d3dpp.Windowed = true;
this->d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
this->d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
//this->d3dpp.MultiSampleType = D3DMULTISAMPLE_16_SAMPLES;
//this->d3dpp.hDeviceWindow = hWnd;
CUSTOMVERTEX vertices[] =
{
{ 150, 50, 0.5, 1, 0xffff0000, },
{ 250, 250, 0.5, 1, 0xff00ff00, },
{ 50, 250, 0.5, 1, 0xff00ffff, },
};
if(!this->d3ddevice->CreateVertexBuffer(3 * sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &this->d3dvb, NULL))
return E_FAIL;
void* pVertices;
if(!this->d3dvb->Lock(0, sizeof(vertices), (void**)&pVertices, 0))
return E_FAIL;
memcpy(pVertices, vertices, sizeof(vertices));
this->d3dvb->Unlock();
this->d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &this->d3dpp, &this->d3ddevice);
return S_OK;
}
|