I had given it up for a few years already (since DirectX 8). I'm not quite sure whether I can help or not.
Anyway, at least, I should be able to provide some basic information.
Firstly,
lpD3Device->CreateIndexBuffer(m_unNumberOfIndicies*sizeof(int),0, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &m_IB, 0);
This line is probably incorrect. D3DFMT_INDEX16 is probably two bytes integer. However, you copy to the buffer a block of 4 bytes integer later. You must be very unlucky. Otherwise, you should have noticed it because the program crashed during execution.
Secondly, the orientations of Direct3D and OpenGL are different. OpenGL is right-handed and Direct3D is left-handed. Also, the direction of the axis of Direct3D and OpenGL point towards different directions too. Therefore, when you converting a 3D mesh from OpenGL to Direct3D (vice versa), you need to explicitly reverse the winding in order to make culling to work correctly. Also, please pay some attention about the direction of the axis.
(Anyway, if the windings of a 3D model are consistent in the first place, there will be two cases only. You can try them both to see which one is correct simply.)
To reverse the winding, you can
for( t=0, j=0; j<height-3; j++ ) for( i=0; i<width-1; i++ ) { idx[t++] = (j )*width + i ; idx[t++] = (j+1)*width + i+1; // switch this line with the following line idx[t++] = (j )*width + i+1; // << idx[t++] = (j )*width + i ; idx[t++] = (j+1)*width + i ; // switch this line with the following line idx[t++] = (j+1)*width + i+1; // << } for( i=0; i<width-1; i++ ) { idx[t++] = (height-2)*width; idx[t++] = i; // switch this line with the following line idx[t++] = i+1; // << idx[t++] = (height-2)*width+1; idx[t++] = (height-3)*width + i+1; // switch this line with the following line idx[t++] = (height-3)*width + i; // << }
[Edited by - ma_hty on June 12, 2009 8:47:52 AM]