学习顶点缓存与索引缓存(三)

Posted on 2008-08-10 22:19 orlando 阅读(374) 评论(0)  编辑 收藏 引用

在学习顶点缓存与索引缓存(一)的代码中
改成下面这样就达到目的
 //顶点数据
 CUSTOMVERTEX g_Vertices[10];
 g_Vertices[0].x = 300;
 g_Vertices[0].y = 250;
 g_Vertices[0].z = 0.5f;
 g_Vertices[0].rhw = 1.0f;
 g_Vertices[0].color = 0xffff0000;

 //g_Vertices[9]=g_Vertices[0];
 for(int i=0; i<8; i++)
 {
  g_Vertices[i+1].x =  (float)(200*sin(i*3.14159/4.0)) + 300;
  g_Vertices[i+1].y = -(float)(200*cos(i*3.14159/4.0)) + 250;
  g_Vertices[i+1].z = 0.5f;
  g_Vertices[i+1].rhw = 1.0f;
  g_Vertices[i+1].color = 0xff00ff00;
 }
 g_Vertices[9]=g_Vertices[1];


g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, 0,8 );


索引缓存可以不止一次的引用同一顶点,这提供了超过三角形列表的性能优势,因为可以多次重复使用一个顶点,也提供了超过三角形带的创造优势,因为创造过程不那么复杂。

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


posts - 16, comments - 17, trackbacks - 0, articles - 1

Copyright © orlando