win32的 WORD 类详解
例:一段正方体的初始化
其他参数:
struct TriangleVertex
{
float x, y, z;
DWORD color;
};
LPDIRECT3DDEVICE9 m_pDevice;
LPDIRECT3DVERTEXBUFFER9 m_pTriangleVB;
LPDIRECT3DINDEXBUFFER9 m_pSquareIB;
//初始化代码
void Init(LPDIRECT3DDEVICE9 pDevice)
{
m_pDevice = pDevice;
float f=15.0f;
TriangleVertex tvVertices[] =
{
//顶面
{-f, f, -f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 0 - Blue
{-f, f, f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 1 - Red
{f, f, -f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 2 - Red
{f, f, f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 3 - Green
//底面
{f, -f, -f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 4 - Green
{f, -f, f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 5 - Blue
{-f, -f, -f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 6 - Red
{-f, -f, f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 7 - Green
};
// 创建顶点缓冲
m_pDevice->CreateVertexBuffer(sizeof(tvVertices), D3DUSAGE_WRITEONLY,
D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &m_pTriangleVB, NULL);
// 创建索引缓冲
m_pDevice->CreateIndexBuffer( 36 * sizeof(WORD), D3DUSAGE_WRITEONLY,
D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_pSquareIB, NULL );
// 设置顶点数据
void *pVertices = NULL;
m_pTriangleVB->Lock( 0, sizeof(TriangleVertex), &pVertices, 0 );
memcpy(pVertices, tvVertices, sizeof(tvVertices));
m_pTriangleVB->Unlock();
WORD wIndices[] ={ 0,1,2,1,3,2,
0,4,6,0,2,4,
2,5,4,2,3,5,
3,7,5,3,1,7,
1,6,7,1,0,6,
4,5,7,7,6,4 };
WORD *pIndices = NULL;
m_pSquareIB->Lock( 0, sizeof(wIndices), (void**)&pIndices, 0 );
memcpy( pIndices, wIndices, sizeof(wIndices) ) ;
m_pSquareIB->Unlock();
}
///求WORD 应用的详细说明
其他参数:
struct TriangleVertex
{
float x, y, z;
DWORD color;
};
LPDIRECT3DDEVICE9 m_pDevice;
LPDIRECT3DVERTEXBUFFER9 m_pTriangleVB;
LPDIRECT3DINDEXBUFFER9 m_pSquareIB;
//初始化代码
void Init(LPDIRECT3DDEVICE9 pDevice)
{
m_pDevice = pDevice;
float f=15.0f;
TriangleVertex tvVertices[] =
{
//顶面
{-f, f, -f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 0 - Blue
{-f, f, f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 1 - Red
{f, f, -f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 2 - Red
{f, f, f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 3 - Green
//底面
{f, -f, -f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 4 - Green
{f, -f, f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 5 - Blue
{-f, -f, -f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 6 - Red
{-f, -f, f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 7 - Green
};
// 创建顶点缓冲
m_pDevice->CreateVertexBuffer(sizeof(tvVertices), D3DUSAGE_WRITEONLY,
D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &m_pTriangleVB, NULL);
// 创建索引缓冲
m_pDevice->CreateIndexBuffer( 36 * sizeof(WORD), D3DUSAGE_WRITEONLY,
D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_pSquareIB, NULL );
// 设置顶点数据
void *pVertices = NULL;
m_pTriangleVB->Lock( 0, sizeof(TriangleVertex), &pVertices, 0 );
memcpy(pVertices, tvVertices, sizeof(tvVertices));
m_pTriangleVB->Unlock();
WORD wIndices[] ={ 0,1,2,1,3,2,
0,4,6,0,2,4,
2,5,4,2,3,5,
3,7,5,3,1,7,
1,6,7,1,0,6,
4,5,7,7,6,4 };
WORD *pIndices = NULL;
m_pSquareIB->Lock( 0, sizeof(wIndices), (void**)&pIndices, 0 );
memcpy( pIndices, wIndices, sizeof(wIndices) ) ;
m_pSquareIB->Unlock();
}
///求WORD 应用的详细说明
...全文
相关推荐
gensim-3.5.0-cp35-cp35m-win32.whl.zip
对于Word2Vec模型,可以使用`Word2Vec`类进行训练:```pythonfrom gensim.models import Word2Vecmodel = Word2Vec(corpus,
windows下 通用控件 (难找的资料)
### Windows 下通用控件知识点详解#### 一、引言Windows系统自Windows 95和Windows NT 3.51版本开始引入了一系列新的Win32控件,这些控件相较于传统的控件提供了更为丰富的功能与用户体验
gensim-3.7.0-cp36-cp36m-win32.whl.zip
- **训练模型**:使用`gensim.models.Word2Vec`类创建并训练模型,可以根据语料库大小调整参数如窗口大小(window size),最小词频(min_count),迭代次数(iterations
gensim-3.7.1-cp36-cp36m-win32.whl.zip
《 gensim 3.7.1 的安装与应用详解》gensim 是一个流行的Python库,专注于处理文本数据,特别是用于执行主题建模、文档相似性计算和词向量操作。
python处理word文件:win32com用法详解
### Python 处理 Word 文件:Win32com 模块详解#### 一、引言在日常工作中,我们经常需要处理大量的文档,比如批量修改Word文档内容、合并多个文档等。



