#include"3DManager.h"
#include"NumLibary.h"
void disPlay(IDirect3DDevice9 *d9Device)
{
const int width = 800;
const int height = 600;
d9Device->CreateVertexBuffer(sizeof(Vertex)*8,D3DUSAGE_WRITEONLY,D3DFVF_XYZ,D3DPOOL_MANAGED,&vb,0);
d9Device->CreateIndexBuffer(sizeof(WORD)*36,D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_MANAGED,&ib,0);
Vertex *vertexs;
vb->Lock(0,0,(void**)&vertexs,0);
vertexs[0] = Vertex(-1.0f,-1.0f,-1.0f);
vertexs[1] = Vertex(-1.0f,1.0f,-1.0f);
vertexs[2] = Vertex(1.0f,1.0f,-1.0f);
vertexs[3] = Vertex(1.0f,-1.0f,-1.0f);
vertexs[4] = Vertex(-1.0f,-1.0f,1.0f);
vertexs[5] = Vertex(-1.0f,1.0f,1.0f);
vertexs[6] = Vertex(1.0f,1.0f,1.0f);
vertexs[7] = Vertex(1.0f,-1.0f,1.0f);
vb->Unlock();
WORD *id;
ib->Lock(0,0,(void**)&id,0);
id[0] = 0; id[1] = 1; id[2] = 2;
id[3] = 0; id[4] = 2; id[5] = 3;
id[6] = 4; id[7] = 6; id[8] = 5;
id[9] = 4; id[10] = 7; id[11] = 6;
id[12] = 4; id[13] = 5; id[14] = 1;
id[15] = 4; id[16] = 1; id[17] = 0;
id[18] = 3; id[19] = 2; id[20] = 6;
id[21] = 3; id[22] = 6; id[23] = 7;
id[24] = 1; id[25] = 5; id[26] = 6;
id[27] = 1; id[28] = 6; id[29] = 2;
id[30] = 4; id[31] = 0; id[32] = 3;
id[33] = 4; id[34] = 3; id[35] = 7;
ib->Unlock();
D3DXVECTOR3 postion(0,0,-5);
D3DXVECTOR3 target(0,0,0);
D3DXVECTOR3 up(0,1,0);
D3DXMATRIX v;
D3DXMatrixLookAtLH(&v,&postion,&target,&up);
d9Device->SetTransform(D3DTS_VIEW,&v);
D3DXMATRIX proj;
D3DXMatrixPerspectiveFovLH(&proj,D3DX_PI*0.5,800/600,1.0,1000);
d9Device->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
}
void show(IDirect3DDevice9 *d9Device)
{
if(d9Device){
D3DXMATRIX x,y,p;
D3DXMatrixRotationX(&x,3.14/4);
D3DXMatrixRotationY(&y,0);
p = x*y;
d9Device->SetTransform(D3DTS_WORLD,&p);
d9Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
d9Device->BeginScene();
d9Device->SetStreamSource(0,vb,0,sizeof(Vertex));
d9Device->SetIndices(ib);
d9Device->SetFVF(D3DFVF_XYZ);
d9Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST ,0,0,8,0,12);
d9Device->EndScene();
d9Device->Present(0,0,0,0);
}
}
这段代码没有画出图像!还请不吝赐教
DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,VCount,0,LCount/3);
这个函数不显示!请问为什么啊.?
|