参考教程
Tutorial 1: Grid and Camera Movement
学习记录
本篇主要介绍对地形网格的绘制,代码基于上一篇内容。
  既然说是地形网格,那么自然是以网格为主。我们之前在 ModelClass 中读取模型文件来创建模型数据,在 TerrainClass 中则是使用代码生成网格。首先来看我们 TerrainClass 的声明:
| 1 | //////////////////////////////////////////////////////////////////////////////// | 
   和 ModelClass 几乎相同。在它的 InitializeBuffers 方法中,我们使用代码生成顶点和索引数据,代码如下:
| 1 | bool TerrainClass::InitializeBuffers(ID3D11Device* device) | 
可以看到我们是以四条线的方式来确定每一个四边形,所以在绘制图元类型的时候我们选用线绘制:
| 1 | // Set the type of primitive that should be rendered from this vertex buffer, in this case lines. | 
最终效果(高处往下看):
