Jump to content
  • Advertisement
Sign in to follow this  
Njguy

App Crash

This topic is 3556 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I added the following to my code, it compiles great, but the app crashes. I am not even sure what could be wrong. I don't have very much experience with what I am doing. If anyone has any ideas that would be great. I have posted a snippet of the original code, and a snippet of the same section but with added code. Original (Runs fine)
// Load the mesh.
	ID3DXBuffer *materialBuffer, *adjacencyBuffer;
	D3DXLoadMeshFromX( GetFilename(), D3DXMESH_MANAGED, g_engine->GetDevice(), &adjacencyBuffer, &materialBuffer, NULL, &m_staticMesh->NumMaterials, &m_staticMesh->originalMesh );

	// Optimise the mesh for better rendering performance.
	m_staticMesh->originalMesh->OptimizeInplace( D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE, (DWORD*)adjacencyBuffer->GetBufferPointer(), NULL, NULL, NULL );

	// Finished with the adjacency buffer, so destroy it.
	SAFE_RELEASE( adjacencyBuffer );
New Version (Compiles great, App crashes)
// Load the mesh.
	ID3DXBuffer *materialBuffer, *adjacencyBuffer;
	D3DXLoadMeshFromX( GetFilename(), D3DXMESH_MANAGED, g_engine->GetDevice(), &adjacencyBuffer, &materialBuffer, NULL, &m_staticMesh->NumMaterials, &tempMesh );

	// Get the vertex declaration for the NMapVertex.
	D3DVERTEXELEMENT9 elems[MAX_FVF_DECL_SIZE];
	UINT numElems = 0;
	NMapVertex::Decl->GetDeclaration(elems, &numElems);

	// Clone the mesh to the NMapVertex format.
	ID3DXMesh* clonedTempMesh = 0;
	tempMesh->CloneMesh(D3DXMESH_MANAGED, elems, g_engine->GetDevice(), &clonedTempMesh);

	// Now use D3DXComputeTangentFrameEx to build the TNB-basis for each vertex
	// in the mesh.  
	
	D3DXComputeTangentFrameEx(
	  clonedTempMesh, // Input mesh
	  D3DDECLUSAGE_TEXCOORD, 0, // Vertex element of input tex-coords.  
      D3DDECLUSAGE_BINORMAL, 0, // Vertex element to output binormal.
	  D3DDECLUSAGE_TANGENT, 0,  // Vertex element to output tangent.
      D3DDECLUSAGE_NORMAL, 0,   // Vertex element to output normal.
      0, // Options
      0, // Adjacency
	  0.01f, 0.25f, 0.01f, // Thresholds for handling errors
	  &m_staticMesh->originalMesh, // Output mesh
	  0);         // Vertex Remapping
	
	SAFE_RELEASE( tempMesh );
	SAFE_RELEASE( clonedTempMesh );
	
	// Optimise the mesh for better rendering performance.
	m_staticMesh->originalMesh->OptimizeInplace( D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE, (DWORD*)adjacencyBuffer->GetBufferPointer(), NULL, NULL, NULL );

	// Finished with the adjacency buffer, so destroy it.
	SAFE_RELEASE( adjacencyBuffer );

Share this post


Link to post
Share on other sites
Advertisement
a) Most of the calls return a HRESULT that you can test with the FAILED() macro to identify the problem. Not checking return results from DX methods is very prevalent in online tutorial code, but a bad idea.

b) Set your DX runtime to debug with maximum output (via the DX Control Panel that ships with the DXSDK) and you might get some useful information in your output window when you run from the IDE.

Share this post


Link to post
Share on other sites
Run it in the debugger to find out where it crashes. Crashes mean you've messed up a pointer somewhere or assumed something gave you back a valid pointer, when instead it failed and didn't.

Share this post


Link to post
Share on other sites
Quote:
Original post by legalize
Run it in the debugger to find out where it crashes. Crashes mean you've messed up a pointer somewhere or assumed something gave you back a valid pointer, when instead it failed and didn't.


Thats what im trying to do, but when the app crashes I have to do ctrl alt dlt, and get rid of it, or else I cant do anything. Once I get rid of it, i either have to hit continue, or break on the popup box, which does nothing. So, in short I really don't know what im doing.

Share this post


Link to post
Share on other sites
When I get a problem like this, I put break points in my code to find out exactly which line the problem occurs on...but this problem does sound familiar. One time ctr+alt+del didn't work for me and I had to repeatedly reset my computer until I fixed the problem.[crying]

Share this post


Link to post
Share on other sites
i found out the hard way that when you tell directX to load a file, you have to provide the files name AND extention... or else it whines and pouts by freezing itself and not letting u alt tab or Ctrl ALT delite out of it...

but i skimmed over your code and wasnt looking for a set of "" marks with a filename in it... so maybe this wasnt helpful...

Share this post


Link to post
Share on other sites
Quote:
Original post by Njguy
Quote:
Original post by legalize
Run it in the debugger to find out where it crashes. Crashes mean you've messed up a pointer somewhere or assumed something gave you back a valid pointer, when instead it failed and didn't.


Thats what im trying to do, but when the app crashes I have to do ctrl alt dlt, and get rid of it, or else I cant do anything. Once I get rid of it, i either have to hit continue, or break on the popup box, which does nothing. So, in short I really don't know what im doing.
Run the app in windowed mode?

Also, you can still check the return values from all your functions with the FAILED() macro, and log or break out when a function fails.

Share this post


Link to post
Share on other sites
Thanks guys your life savers, im making progress but its getting slowed down by something. Straight from the beginning, I could never minimize my application and bring it back up again, it would crash. Does anyone know why this could be? This would help my debugging process greatly.

Share this post


Link to post
Share on other sites
Quote:
Original post by Njguy
Thanks guys your life savers, im making progress but its getting slowed down by something. Straight from the beginning, I could never minimize my application and bring it back up again, it would crash. Does anyone know why this could be? This would help my debugging process greatly.
Probably because you're not handling device reset correctly. What do the Debug Runtimes tell you? Does this happen in windowed mode as well as full screen? What do you mean the app "crashes"? Access violation? What's the exact error?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!