11111

nt ModelClass::GetIndexCount()
{
return m_indexCount;
}
The InitializeBuffers function is where we handle creating the vertex and index buffers.
Usually you would read in a model and create the buffers from that data file.
For this tutorial we will just set the points in the vertex and index buffer
manually since it is only a single triangle.

InitializeBuffers函数是我们创建vertex and index buffers的地方。
通常你会读一个模型然后从模型数据文件(data file)创建buffer
这个教程我们只是设点的 vertex and index buffer ,因为它只是一个三角形。

bool ModelClass::InitializeBuffers(ID3D11Device* device)
{
VertexType* vertices;
unsigned long* indices;
D3D11_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
D3D11_SUBRESOURCE_DATA vertexData, indexData;
HRESULT result;
First create two temporary arrays to hold the vertex and index data that we will use later to populate the final buffers with.

// Set the number of vertices in the vertex array.
m_vertexCount = 3;

// Set the number of indices in the index array.
m_indexCount = 3;

// Create the vertex array.
// 顶点数组
vertices = new VertexType[m_vertexCount];
if(!vertices)
{
return false;
}

// Create the index array.
indices = new unsigned long[m_indexCount];
if(!indices)
{
return false;
}
Now fill both the vertex and index array with the three points of the triangle
as well as the index to each of the points.
Please note that I create the points in the clockwise order of drawing them.
If you do this counter clockwise it will think the triangle
is facing the opposite direction and not draw it due to back face culling.
Always remember that the order in which you send your vertices to the GPU
is very important.
The color is set here as well since it is part of the vertex description.
I set the color to green.

 

 

 

class:

DirectX 类:
1.#include <d3d11.h>
"""
Header : D3D11.h
Library: D3D11.lib
"""
ID3D11Device(interface):D3D的设备驱动层,一个显卡对应一个设备

ID3D11Buffer :D3D的缓存

VertexType: D3D的顶点类

D3D11_BUFFER_DESC:Describes a buffer resource
typedef struct D3D11_BUFFER_DESC {
UINT ByteWidth;
D3D11_USAGE Usage;
UINT BindFlags;
UINT CPUAccessFlags;
UINT MiscFlags;
UINT StructureByteStride;
} D3D11_BUFFER_DESC;

D3D11_SUBRESOURCE_DATA



2.#include <d3dx10math.h>
向量:
D3DXVECTOR3
D3DXVECTOR4

posted @ 2016-01-20 19:49  shinymood  阅读(211)  评论(0编辑  收藏  举报