问题描述
- 关于 Direct3D 顶点索引缓存的填充问题
- 小弟最近在学Direct3D
这两天一直纳闷那个顶点索引缓存填充的问题
因为我自己填充顶点和索引的时候画出来的立方体总是缺一个角
试了好几次也没有效果
源代码:
lpd3dDevice->CreateVertexBuffer(sizeof(CUSTOMVERTEX)*80D3DFVF_CUSTOMD3DPOOL_DEFAULT&lpd3dVertexNULL);
lpd3dDevice->CreateIndexBuffer(sizeof(WORD) * 360D3DFMT_INDEX16D3DPOOL_DEFAULT&lpd3dIndexNULL);CUSTOMVERTEX vertex[] = { {-20.0-20.0-20.0D3DCOLOR_XRGB(rand()%255rand()%255rand()%255)} {20.0-20.0-20.0D3DCOLOR_XRGB(rand()%255rand()%255rand()%255)} {20.020.0-20.0D3DCOLOR_XRGB(rand()%255rand()%255rand()%255)} {-20.020.0-20.0D3DCOLOR_XRGB(rand()%255rand()%255rand()%255)} {-20.0-20.020.0D3DCOLOR_XRGB(rand()%255rand()%255rand()%255)} {20.0-20.020.0D3DCOLOR_XRGB(rand()%255rand()%255rand()%255)} {20.020.020.0D3DCOLOR_XRGB(rand()%255rand()%255rand()%255)} {-20.020.0-20.0D3DCOLOR_XRGB(rand()%255rand()%255rand()%255)}};void * pVertex = NULL;lpd3dVertex->Lock(0sizeof(vertex)(void**)&pVertex0); memcpy(pVertexvertexsizeof(vertex));lpd3dVertex->Unlock();
WORD Index[] = {012023015054047073237276126165456467};
WORD pIndex = NULL; // 设置索引
lpd3dIndex->Lock(00(void*)&pIndex0);memcpy(pIndexIndexsizeof(Index));lpd3dIndex->Unlock();lpd3dDevice->SetRenderState(D3DRS_LIGHTINGFALSE); //关闭光照lpd3dDevice->SetRenderState(D3DRS_CULLMODED3DCULL_CCW); //开启背面消隐
求大神帮助
时间: 2024-11-01 13:54:16