Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unhandled exception during GetFVF

Posted on 2008-10-08
1
Medium Priority
?
423 Views
Last Modified: 2013-12-26
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

0
Comment
Question by:Snapples
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
jgordos earned 2000 total points
ID: 22674178
This is a SWAG, since you don't show the entire program.

You seem to be using global variables, and reusing them, too.

I can think of a lot of things that might be wrong.

Try the following:
See if you can draw the cylinder/torus if you DON'T draw the others....

I.E., change BuildScene to look like this...

void MultiMeshBasisApp::BuildScene()
{
      // 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
}

The next thing i'd try, if that still doesn't work, is to change the call where you build the mesh....

Try hard coding known good values in for hte parameters...  you might be asking the code to build something that isn't quite Kosher, so the resultant mesh is incorrect.

Try changing
D3DXCreateTorus(GETDEVICE,m_a,m_b,(UINT)m_c,(UINT)m_d,&m_pDXMesh,0);
to
D3DXCreateTorus(GETDEVICE,1.0,1.0,1,1,&m_pDXMesh,0);

And then, lastly, you talk about drawing a cylinder, but you're really drawing the torus.

Do you mean this ?

m_pCylinder = new MeshShape(MeshShape::CYLINDER,1.0f,2.0f,1.0f);

-john


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question