|
2个三角形构成的正方形,我就是贴不上去图啊!
帮我看看定义的对不对!
//从图片文件中直接创建纹理对象
:3DXCreateTextureFromFile( m_pDevice, "texture.jpg", &m_pTexture );
CUSTOMVERTEX vertices[4];
vertices[0].position = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); //点A的坐标
vertices[0].normal = D3DXVECTOR3( -1.0f, 0.0f, 0.0f ); //点A的法线矢量
vertices[0].tu = 0.0f; //点A的纹理坐标
vertices[0].tv = 0.0f;
vertices[1].position = D3DXVECTOR3( 0.0f, 2.0f, 0.0f ); //点b的坐标
vertices[1].normal = D3DXVECTOR3( -1.0f, 2.0f, 0.0f ); //点A的法线矢量
vertices[1].tu = 0.0f; //点b的纹理坐标
vertices[1].tv = 1.0f;
vertices[2].position = D3DXVECTOR3( 2.0f, 2.0f, 0.0f ); //点c的坐标
vertices[2].normal = D3DXVECTOR3( 2.0f, 2.0f, 0.0f ); //点A的法线矢量
vertices[2].tu = 1.0f; //点c的纹理坐标
vertices[2].tv = 1.0f;
vertices[3].position = D3DXVECTOR3( 2.0f, 0.0f, 0.0f ); //点d的坐标
vertices[3].normal = D3DXVECTOR3( 2.0f, 0.0f, 0.0f ); //点A的法线矢量
vertices[3].tu = 1.0f; //点d的纹理坐标
vertices[3].tv = 0.0f;
//创建圆锥曲面的顶点缓存区,填入顶点数据
m_pDevice->CreateVertexBuffer(
sizeof(vertices),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &m_pVB, NULL );
//把顶点数据填入顶点缓存区
void* pVertices;
m_pVB->Lock( 0, sizeof(vertices), (void**)&pVertices, 0 );
memcpy( pVertices, vertices, sizeof(vertices) );
m_pVB->Unlock();
[em17] |
|