Hello all,
I have been having some very strange results when trying to draw a scene with both filled/textured triangle-composed objects together with objects composed of lines.
For example, I'm trying to draw my bounding cube around my model. The cube is just a bunch of line-connected vertices which hold a color and a position, drawn by the "DrawIndexedPrimitve() command. But the cube only shows up in my second viewport( I have two viewports, split screen ). Everything else shows up in both viewports, including all of the textured meshes/terrain, and even the normals ( which I also draw with lines ).
The only thing I've been able to figure out, is that it has something to do with the "SetTexture()" call in my Model's render section. If I REMOVE the SetTexture call in the Model's render section ( which is the last rendering done before the cube gets rendered ), then the cube doesn't show up in EITHER viewport. I'm thinking that maybe I'm making some device calls in a funny order, because since my intent is just to draw the cube's lines with the color values at the vertices, the texture shouldn't have anything to do with it.
I'll post the cube's render section and the model's render section here. Please let me know if you have any ideas, or need more information.
Cube:
//No texture has been set
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COL ORARG2, D3DTA_CURRENT);
//Select vertex buffer
m_pd3dDevice->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(CRVertex));
m_pd3dDevice->SetFVF( D3DFVF_CRVERTEX );
//Select index buffer
m_pd3dDevice->SetIndices(m_pIndexBuffer);
//Turn off lighting
m_pd3dDevice->SetRenderState(D3DRS_LIGHTING,FALSE);
//Draw the primitives
m_pd3dDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, m_iVertTotalCount, 0, 12);
Model:
//A texture has been set. We want our texture to be shaded based
//on the current light levels, so used D3DTOP_MODULATE.
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
//Turn on lighting
m_pd3dDevice->SetRenderState(D3DRS_LIGHTING,TRUE);
for (DWORD i=0; i<numMaterials; i++)
{
// Set the material and texture for this subset
m_pd3dDevice->SetMaterial(&meshMaterials);
m_pd3dDevice->SetTexture(0,meshTextures);
// Draw the mesh subset
mesh->DrawSubset( i );
}