Link to home
Start Free TrialLog in
Avatar of Snapples
Snapples

asked on

Unhandled exception during GetFVF

Hello experts,

I'm pretty new to DirectX and Direct3D so it's all still a bit confusing.
I've been given a pre-made "engine" that can easily create and transform several shapes.

When I make a box or teapot it works but when I make anything else I get an unhandled exception in the Draw function of the Mesh at m_pDXMesh->GetFVF()

Anyone have any ideas?
Thanks in advance.
void MeshShape::Init()
{
	//default material color is white
	SetMaterialColor(1,1,1,1);
 
	switch(m_Type)
	{
	case BOX:
		D3DXCreateBox(GETDEVICE,m_a,m_b,m_c,&m_pDXMesh,0);
		break;
	case SPHERE:
		D3DXCreateSphere(GETDEVICE,m_a,(UINT)m_b,(UINT)m_c,&m_pDXMesh,0);
		break;
	case TEAPOT:
		D3DXCreateTeapot(GETDEVICE,&m_pDXMesh,0);
		break;
	case TORUS:
		D3DXCreateTorus(GETDEVICE,m_a,m_b,(UINT)m_c,(UINT)m_d,&m_pDXMesh,0);
		break;
	case CYLINDER:
		D3DXCreateCylinder(GETDEVICE,m_a,m_b,m_c,(UINT)m_d,(UINT)m_e,&m_pDXMesh,0);
		break;
	default:
		D3DXCreateBox(GETDEVICE,1,1,1,&m_pDXMesh,0);
	}
}
 
void MeshShape::Draw() 
{
    GETDEVICE->SetMaterial( &m_Mtrl );
	GETDEVICE->SetTransform( D3DTS_WORLD, &m_FinalWorld );
 
        // THIS LINE GIVES UNHANDLED EXCEPTION
	GETDEVICE->SetFVF( m_pDXMesh->GetFVF() ); 
	m_pDXMesh->DrawSubset(0);
}
 
 
 
void MultiMeshBasisApp::BuildScene()
{
	// This works
	m_pFloor = new MeshShape(MeshShape::BOX,10,0.1f,10);
	m_pFloor->SetMaterialColor(0.6f,0.6f,0.6f,1.0f);
	m_pFloor->Translate(0,-2,4);
	m_pFloor->Draw();
	
 
	// This works too
	m_pTeapot = new MeshShape(MeshShape::TEAPOT,1.0f,2.0f,1.0f);
	m_pTeapot->SetMaterialColor(1.0f,1.0f,0.1f,1.0f);
	m_pTeapot->Translate(3.0f,0.0f,6.0f);
	m_pTeapot->Draw();
 
	// This doesn't
	m_pCylinder = new MeshShape(MeshShape::TORUS,1.0f,2.0f,1.0f);
	m_pCylinder->SetMaterialColor(0.05f,0.2f,0.9f,1.0f);
	m_pCylinder->Translate(0,0,0);
	m_pCylinder->Draw(); // <- Here's the problem
 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jgordos
jgordos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial