Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Draw()
- {
- Device->Clear(0, 0, D3DCLEAR_TARGET, WHITE, 1, 0);
- Device->BeginScene();
- DrawEnvironment(Device,Environment);
- Device->EndScene();
- if (FAILED(Device->Present(0,0,0,0)))
- {
- while(Device->TestCooperativeLevel() == D3DERR_DEVICELOST) Sleep(100);
- D3DPRESENT_PARAMETERS D3dPresParams = GetDeviceParams(Window);
- if (FAILED(Device->Reset(&D3dPresParams)))
- return true;
- }
- return false;
- }
- LPDIRECT3DVERTEXBUFFER9 CreateEnvironment(LPDIRECT3DDEVICE9 D3dDevice)
- {
- LPDIRECT3DVERTEXBUFFER9 Buffer = 0;
- ENV_VERTEX* Vertices = 0;
- Vertices = new (std::nothrow) ENV_VERTEX[40];
- for (UINT i=0, ii=-10; i<10; i+=2, ii+=2)
- {
- Vertices[i].P = D3DXVECTOR3((float)ii,0,10);
- Vertices[i+1].P = D3DXVECTOR3((float)ii,0,-10);
- }
- for (UINT i=10, ii=10; i<20; i+=2, ii-=2)
- {
- Vertices[i].P = D3DXVECTOR3((float)ii,0,10);
- Vertices[i+1].P = D3DXVECTOR3((float)ii,0,-10);
- }
- for (UINT i=20, ii=-10; i<30; i+=2, ii+=2)
- {
- Vertices[i].P = D3DXVECTOR3(10,0,(float)ii);
- Vertices[i+1].P = D3DXVECTOR3(-10,0,(float)ii);
- }
- for (UINT i=30, ii=10; i<40; i+=2, ii-=2)
- {
- Vertices[i].P = D3DXVECTOR3(10,0,(float)ii);
- Vertices[i+1].P = D3DXVECTOR3(-10,0,(float)ii);
- }
- for (UINT i=0; i<40; ++i)
- Vertices[i].C = GREY;
- if (FAILED(D3dDevice->CreateVertexBuffer(40*sizeof(ENV_VERTEX), 0, ENVFVF, D3DPOOL_MANAGED, &Buffer, 0)))
- return 0;
- VOID* Address;
- Buffer->Lock(0,0,&Address,0);
- memcpy(Address,Vertices,40*sizeof(ENV_VERTEX));
- Buffer->Unlock();
- SAFE_ARRAY_DELETE(Vertices);
- return Buffer;
- }
- void DrawEnvironment(LPDIRECT3DDEVICE9 D3dDevice, LPDIRECT3DVERTEXBUFFER9 Buffer)
- {
- D3dDevice->SetFVF(ENVFVF);
- D3dDevice->SetStreamSource(0,Buffer,0,sizeof(ENV_VERTEX));
- D3dDevice->DrawPrimitive(D3DPT_LINELIST,0,20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement