Jump to content
  • Advertisement
Sign in to follow this  
beavis6325

directx program crashing

This topic is 4892 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 have been working on loading bsp levels in with directx in my current project and I've had a few problems. First, does directx crash when you feed it too much data. For example, when I comment out my frustum culling code just to check if the level will render, the program crashes. If I only render a small percentage of the leaves then it doesn't crash, or if it is a small level. Second: The reason I've had this trouble in the first place is because I can't get my frustum culling code to work. I am loading quake 3 .bsp files. I cull away clusters fine, but the problem comes when checking if a box is in my frustum. I've been checking over my frustum calculation code and my box in frustum function and I am just stuck and feel like giving up. I will list my code for those two functions if anyone thinks they can help.
void Camera::Frustum::CalculateFrustum(){
	D3DXMATRIX   proj;								// This will hold our projection matrix
	D3DXMATRIX   view;								// This will hold our view matrix
	D3DXMATRIX	 clip;								// This will hold the clipping planes

	g_pD3DDevice->GetTransform(D3DTS_PROJECTION, &proj);
	g_pD3DDevice->GetTransform(D3DTS_VIEW, &view);

	D3DXMatrixMultiply(&clip, &view, &proj);

	// This will extract the RIGHT side of the frustum
	m_Frustum

.a = clip._14 - clip._11; m_Frustum

.b = clip._24 - clip._21; m_Frustum

.c = clip._34 - clip._31; m_Frustum

.d = clip._44 - clip._41; // Normalize the RIGHT side D3DXPlaneNormalize(&m_Frustum

, &m_Frustum

); // This will extract the LEFT side of the frustum m_Frustum

.a = clip._14 + clip._11; m_Frustum

.b = clip._24 + clip._21; m_Frustum

.c = clip._34 + clip._31; m_Frustum

.d = clip._44 + clip._41; // Normalize the LEFT side D3DXPlaneNormalize(&m_Frustum

, &m_Frustum

); // This will extract the BOTTOM side of the frustum m_Frustum[BOTTOM].a = clip._14 + clip._12; m_Frustum[BOTTOM].b = clip._24 + clip._22; m_Frustum[BOTTOM].c = clip._34 + clip._32; m_Frustum[BOTTOM].d = clip._44 + clip._43; // Normalize the BOTTOM side D3DXPlaneNormalize(&m_Frustum[BOTTOM], &m_Frustum[BOTTOM]); // This will extract the TOP side of the frustum m_Frustum[TOP].a = clip._14 - clip._12; m_Frustum[TOP].b = clip._24 - clip._22; m_Frustum[TOP].c = clip._34 - clip._32; m_Frustum[TOP].d = clip._44 - clip._43; // Normalize the TOP side D3DXPlaneNormalize(&m_Frustum[TOP], &m_Frustum[TOP]); // This will extract the BACK side of the frustum m_Frustum[BACK].a = clip._14 - clip._13; m_Frustum[BACK].b = clip._24 - clip._23; m_Frustum[BACK].c = clip._34 - clip._33; m_Frustum[BACK].d = clip._44 - clip._43; // Normalize the BACK side D3DXPlaneNormalize(&m_Frustum[BACK], &m_Frustum[BACK]); // This will extract the FRONT side of the frustum m_Frustum[FRONT].a = clip._14 + clip._13; m_Frustum[FRONT].b = clip._24 + clip._23; m_Frustum[FRONT].c = clip._34 + clip._33; m_Frustum[FRONT].d = clip._44 + clip._43; // Normalize the FRONT side D3DXPlaneNormalize(&m_Frustum[FRONT], &m_Frustum[FRONT]); } bool CFrustum::BoxInFrustum( float x, float y, float z, float x2, float y2, float z2) { // Go through all of the corners of the box and check then again each plane // in the frustum. If all of them are behind one of the planes, then it most // like is not in the frustum. for(int i = 0; i < 6; i++ ) { if(m_Frustum[A] * x + m_Frustum * y + m_Frustum[C] * z + m_Frustum[D] > 0) continue; if(m_Frustum[A] * x2 + m_Frustum * y + m_Frustum[C] * z + m_Frustum[D] > 0) continue; if(m_Frustum[A] * x + m_Frustum * y2 + m_Frustum[C] * z + m_Frustum[D] > 0) continue; if(m_Frustum[A] * x2 + m_Frustum * y2 + m_Frustum[C] * z + m_Frustum[D] > 0) continue; if(m_Frustum[A] * x + m_Frustum * y + m_Frustum[C] * z2 + m_Frustum[D] > 0) continue; if(m_Frustum[A] * x2 + m_Frustum * y + m_Frustum[C] * z2 + m_Frustum[D] > 0) continue; if(m_Frustum[A] * x + m_Frustum * y2 + m_Frustum[C] * z2 + m_Frustum[D] > 0) continue; if(m_Frustum[A] * x2 + m_Frustum * y2 + m_Frustum[C] * z2 + m_Frustum[D] > 0) continue; // If we get here, it isn't in the frustum return false; } // Return a true for the box being inside of the frustum return true; }

Share this post


Link to post
Share on other sites
Advertisement
D3D will not crash if fed too much data, it will just run slowly. The most common cause in cases like this is sending bad index data.

Have you read the Forum FAQ on how to debug D3D? If not, you should.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!