|
|
各位大哥好,我是初学者。
我遇到一个问题,我最开始是画一个实心的三角形,
顶点结构:
CUSTOMVERTEX g_Vertices[] =
{
{320.0f, 50.0f, 0.5f, 1.0f, D3DCOLOR_ARGB (0, 255, 0, 0), },
{250.0f, 400.0f, 0.5f, 1.0f, D3DCOLOR_ARGB (0, 0, 255, 0), },
{50.0f, 400.0f, 0.5f, 1.0f, D3DCOLOR_ARGB (0, 0, 0, 255), },
};
建立缓冲:
hr = pd3dDevice->CreateVertexBuffer(
3*sizeof(CUSTOMVERTEX),
0,
D3DFVF_XYZRHW|D3DFVF_DIFFUSE,
D3DPOOL_DEFAULT,
&g_pVB,
NULL );
画:
pd3dDevice->BeginScene();
// Draw the contents of the vertex buffer
// Set the data stream first
pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
// Set the Vertex format for the stream next
pd3dDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );
// Draw the vertices within the buffer using triangle strips
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 );
// Tell Direct3D that drawing is complete
pd3dDevice->EndScene();
第一次,我用这个程序画了一个填充了颜色的三角形,为了测试DrawPrimitive的第一个参数,我将其改成了其他的值,但了一会儿后发现,当我再次恢复为以上值是,画出来的并不是填充了的三角形,请问是什么原因呢?
我感觉是DrawPrimitive的问题,或者是不是我没有释放某些指针,导致显存保留了以前的内容。或者是。。。。??? |
|