1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
/* initialize 3D components */
//creating the view matrix
m_eyePos = D3DXVECTOR3(0, -2, 10);
m_lookAt = D3DXVECTOR3(0, 0, 0);
m_upVec = D3DXVECTOR3(0, 1, 0);
D3DXMatrixLookAtLH(&m_V, &m_eyePos, &m_lookAt, &m_upVec);
//creating the projection matrix
D3DXMatrixPerspectiveFovLH(&m_proj, D3DX_PI * 0.361f, (float)m_width / (float)m_height, 1.0f, 1000.0f);
//create vertex declaration
D3DVERTEXELEMENT9 VertexElements[] = {
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
D3DDECL_END()
};
m_pD3DDevice->CreateVertexDeclaration(VertexElements, &VertexDecl);
/* define the cube geometry */
DefineCube();
//create vertex and index buffer /* might need to change some of these values if I have problems */
m_pD3DDevice->CreateVertexBuffer(24 * sizeof(Vertex), 0, 0, D3DPOOL_MANAGED, &VertexBuffer, 0);
m_pD3DDevice->CreateIndexBuffer(36 * sizeof(WORD), D3DUSAGE_DYNAMIC, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &IndexBuffer, 0);
|