一个非常奇怪的directx(direct3d)问题 [英] A really weird directx(direct3d) problem

查看:61
本文介绍了一个非常奇怪的directx(direct3d)问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目的是创建一个茶壶网格,获得顶点和顶点。从它索引,并从顶点和索引中绘制

the purpose is to create a mesh of teapot,get the vertices & index from it,and draw from the vertices and index

ID3DXMesh *Teapot;

D3DXCreateTeapot(dev,&Teapot,NULL);

Teapot->DrawSubset(0);

dev->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);

IDirect3DVertexBuffer9 *VertextBuffer;
IDirect3DIndexBuffer9 *IndexBuffer;

DWORD NumFaces=Teapot->GetNumFaces();
DWORD NumVertices=Teapot->GetNumVertices();
DWORD BytesPerVertex=Teapot->GetNumBytesPerVertex();

if(Teapot->GetVertexBuffer(&VertextBuffer)!=D3D_OK)MessageBox(NULL,TEXT("GetVertexBuffer() Failed!!"),TEXT(""),MB_OK);
if(Teapot->GetIndexBuffer(&IndexBuffer)!=D3D_OK)MessageBox(NULL,TEXT("GetIndexBuffer() Failed!!"),TEXT(""),MB_OK);
if(dev->SetStreamSource(0,VertextBuffer,0,BytesPerVertex)!=D3D_OK)MessageBox(NULL,TEXT("SetStreamSource() Failed!!"),TEXT(""),MB_OK);

dev->BeginScene();
if(dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,NumVertices,0,NumFaces)!=D3D_OK)MessageBox(NULL,TEXT("DrawIndexedPrimitive() Failed!!"),TEXT(""),MB_OK);

dev->EndScene();
dev->Present(0,0,0,0);





一切都还可以!很棒!!!

但是

如果我只是删除代码 Teapot-> DrawSubset(0); 在第 5行,消息框会告诉我



DrawIndexedPrimitive()失败!!



只是想知道为什么

WEll,英语是我的第二语言,所以我不是很擅长,但你明白我的意思

谢谢



everything''s ok!Wonderful!!!
But
if I just delete the code "Teapot->DrawSubset(0);" at line 5th,the messagebox will tell me

DrawIndexedPrimitive() Failed!!

Just want to know WHY
WEll,English is my 2nd language so I''m not really good at it,but you know what I mean
Thank you

推荐答案

我猜是因为没有调用 DrawSubset(0) <而没有任何东西在triange列表中br />
查看 DrawSubset 的文档,了解为什么需要调用它。

对我而言,这意味着微软,''我们说它虽然我们并没有真正说出来' DrawSubset 将网格或网格的一部分转换为要呈现的三角形列表by DrawIndexedPrimitive
My guess would be that''s because there''s nothing in the triange list without the call to DrawSubset(0)
Look at the documentation for DrawSubset to see why you would need to call it.
To me it implies in a Microsoft, ''we said it even though we didn''t really say it'' way that DrawSubset turns a mesh or part of a mesh into a triangle list to be rendered by DrawIndexedPrimitive.


这篇关于一个非常奇怪的directx(direct3d)问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆