|
我用索引缓冲绘制一个长方体,运行之后可以正常显示,但是结束进程之后VS输出提示:
Direct3D9: (WARN) :Vertexbuffer created with POOL_DEFAULT but WRITEONLY not set. Performance penalty could be severe.
Direct3D9: (WARN) :Indexbuffer created with POOL_DEFAULT but WRITEONLY not set. Performance penalty could be severe.
请问为什么会出现上面的提示?下面是我的代码。 谢谢。
- HRESULT InitVBandIB()
- {
- if( FAILED( pd3dDevice->CreateVertexBuffer ( 8*sizeof( CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &pVB, NULL)))
- return E_FAIL;
-
- CUSTOMVERTEX* vertices;
- if( pVB->Lock ( 0, 0, ( void**)&vertices, 0))
- return E_FAIL;
- vertices[0].position = D3DXVECTOR3((float)(-4), -0.5f, -4.0f);
- vertices[1].position = D3DXVECTOR3(-4.0f, 0.5f, -4.0f);
- vertices[2].position = D3DXVECTOR3( 4.0f, 0.5f, -4.0f);
- vertices[3].position = D3DXVECTOR3( 4.0f, -0.5f, -4.0f);
- vertices[4].position = D3DXVECTOR3(-4.0f, -0.5f, 4.0f);
- vertices[5].position = D3DXVECTOR3(-4.0f, 0.5f, 4.0f);
- vertices[6].position = D3DXVECTOR3( 4.0f, 0.5f, 4.0f);
- vertices[7].position = D3DXVECTOR3( 4.0f, -0.5f, 4.0f);
- pVB->Unlock ();
- if( FAILED( pd3dDevice->CreateIndexBuffer ( 36*sizeof(WORD), 0, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &pIB, 0)))
- return E_FAIL;
-
- WORD* indices = 0;
- if( FAILED( pIB->Lock ( 0, 0, ( void**)&indices,0)))
- return E_FAIL;
- indices[0] = 0; indices[1] = 1; indices[2] = 2;
- indices[3] = 0; indices[4] = 2; indices[5] = 3;
- indices[6] = 4; indices[7] = 6; indices[8] = 5;
- indices[9] = 4; indices[10] = 7; indices[11] = 6;
- indices[12] = 4; indices[13] = 5; indices[14] = 1;
- indices[15] = 4; indices[16] = 1; indices[17] = 0;
- indices[18] = 3; indices[19] = 2; indices[20] = 6;
- indices[21] = 3; indices[22] = 6; indices[23] = 7;
- indices[24] = 1; indices[25] = 5; indices[26] = 6;
- indices[27] = 1; indices[28] = 6; indices[29] = 2;
- indices[30] = 4; indices[31] = 0; indices[32] = 3;
- indices[33] = 4; indices[34] = 3; indices[35] = 7;
- pIB->Unlock ();
- pd3dDevice->SetRenderState ( D3DRS_FILLMODE, D3DFILL_WIREFRAME);
- return S_OK;
- }
- void Render()
- {
- if( moveFlag)
- {
- d3d::SetMoveWorldMatrix ( pd3dDevice);
- d3d::SetMoveViewMatrix ( pd3dDevice);
- }
- else
- {
- d3d::SetWorldMatrix( pd3dDevice);
- d3d::SetBirdViewMatrix( pd3dDevice);
- }
- d3d::SetProjectionMatrix( width, height, pd3dDevice);
- pd3dDevice->Clear ( 0, 0, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
- if( SUCCEEDED( pd3dDevice->BeginScene ()))
- {
- pd3dDevice->SetStreamSource ( 0, pVB, 0, sizeof( CUSTOMVERTEX));
- pd3dDevice->SetFVF ( D3DFVF_CUSTOMVERTEX);
- pd3dDevice->SetIndices ( pIB);
- pd3dDevice->DrawIndexedPrimitive ( D3DPT_TRIANGLELIST, 0, 0, 8, 0, 12);
- //pd3dDevice->SetStreamSource ( 0, bVB, 0, sizeof( CUSTOMVERTEX));
- //pd3dDevice->SetFVF ( D3DFVF_CUSTOMVERTEX);
- //pd3dDevice->SetIndices ( bIB);
- //pd3dDevice->DrawIndexedPrimitive ( D3DPT_TRIANGLELIST, 0, 0, 49, 0, 3);
- pd3dDevice->EndScene ();
- }
- pd3dDevice->Present ( 0,0,0,0);
- }
-
复制代码
|
|