Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 11th, 2014, 06:48 PM
Authorized User
Points: 79, Level: 1
Points: 79, Level: 1 Points: 79, Level: 1 Points: 79, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2013
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default DirectX exception. please help

I have a project that I started a while ago on my other laptop, which was running windows vista. I got a new laptop running windows 8, and wanted to run the project on it, but it gives me an unhandled exception. I have directx included in the program. It says Unhandled exception at 0x0f91a253. violation reading location 0xae8b587c. Here is some of my code

Code:
#pragma region Effects
	// Load our effect file 

	D3DXCreateEffectFromFile(m_pD3DDevice, L"Effect.fx", 0, 0, 0, 0, &m_pEffect, &m_pEffectError);

	m_hTech = m_pEffect->GetTechniqueByName("Effect");

	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//Sun.jpg", &m_pTexture[0]);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//earth.jpg", &m_pTexture[1]);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//mercury.jpg", &m_pTexture[2]);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//venus.jpg", &m_pTexture[3]);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//mars.jpg", &m_pTexture[4]);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//jupiter.jpg", &m_pTexture[5]);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//saturn.jpg", &m_pTexture[6]);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//uranus.jpg", &m_pTexture[7]);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//neptune.jpg", &m_pTexture[8]);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"1.bmp", &mTex0);
	D3DXCreateTextureFromFile(m_pD3DDevice, L"Textures//moon.jpg", &m_pTexture[9]);

	m_pEffect->SetTexture("Texture", mTex0);
	m_pEffect->SetFloat("DiffuseIntensity", 1.5f );
	m_pEffect->SetFloat("LineThickness", 0.15f );

#pragma endregion Effects

#pragma region Object Positions
	//positions

	DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&input, NULL);
	
	// Initialize Keyboard
	input->CreateDevice(GUID_SysKeyboard, &m_pDIKeyboard, NULL);

	// Initialize Mouse
	input->CreateDevice(GUID_SysMouse, &m_pDIMouse, NULL);

	// Set up Keyboard
	m_pDIKeyboard->SetCooperativeLevel(hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
	m_pDIKeyboard->SetDataFormat(&c_dfDIKeyboard);

	// Set up Mouse (c_dfDIMouse2 = 8 button mouse)
	m_pDIMouse->SetCooperativeLevel(hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
	m_pDIMouse->SetDataFormat(&c_dfDIMouse2);

	

	D3DXVECTOR3 pos[12];

	planetscaling[0] = 95.0f;
	planetscaling[1] = 900.0f;
	planetscaling[2] = 900.0f;
	planetscaling[3] = 900.0f;
	planetscaling[4] = 1000.0f;
	planetscaling[5] = 600.0f;
	planetscaling[6] = 650.0f;
	planetscaling[7] = 665.0f;
	planetscaling[8] = 660.0f;
	planetscaling[9] = 1350.0f;
	
	pos[0] = D3DXVECTOR3(0.0f, 0.0f, planetscaling[0]);			// Sun
	pos[1] = D3DXVECTOR3(150.0f, 20.0f, planetscaling[1]);		// Earth
	pos[2] = D3DXVECTOR3(50.0f, 50.0f, planetscaling[2]);		// Mercury
	pos[3] = D3DXVECTOR3(100.0f, 0.0f, planetscaling[3]);		// Venus
	pos[4] = D3DXVECTOR3(0.0f, -200.0f, planetscaling[4]);		// Mars
	pos[5] = D3DXVECTOR3(-40.0f, 0.0f, planetscaling[5]);	    // Jupiter
	pos[6] = D3DXVECTOR3(-50.0f, -100.0f, planetscaling[6]);	// Saturn
	pos[7] = D3DXVECTOR3(20.0f, -100.0f, planetscaling[7]);		// Uranus
	pos[8] = D3DXVECTOR3(0.0f, -70.0f, planetscaling[8]);		// Neptune
	pos[9] = D3DXVECTOR3(300.0f, 320.0f, planetscaling[9]);	

	Object[0].set(Sun,	  pos[0], 4.8f, -1, mTex0);	// Sun
	Object[1].set(PLANET, pos[1], 4.8f, -1, mTex0);	// Earth
	Object[2].set(PLANET, pos[2], 4.8f, -1, mTex0);	// Mercury
	Object[3].set(PLANET, pos[3], 4.8f, -1, mTex0);	// Venus
	Object[4].set(PLANET, pos[4], 4.8f, -1, mTex0);	// Mars
	Object[5].set(PLANET, pos[5], 4.8f, -1, mTex0);	// Jupiter
	Object[6].set(PLANET, pos[6], 4.8f, -1, mTex0);	// Saturn
	Object[7].set(PLANET, pos[7], 4.8f, -1, mTex0);	// Uranus
	Object[8].set(PLANET, pos[8], 4.8f, -1, mTex0);	// Neptune
	Object[9].set(MOON,	  pos[9], 4.8f, -1, mTex0);	// moon

#pragma endregion Object Positions

}
void PlanetClass::Update(double dt, IDirect3DDevice9*	m_pD3DDevice)
{

	for(int i = 0; i < 12; i++)
	{
		if(i == 0)
			continue;
		D3DXMatrixRotationY(&rotMat, (float)timeGetTime() * 0.009f);
		D3DXMatrixTranslation(&TransMat, Object[i].position.x, Object[i].position.y, Object[i].position.z);
		D3DXMatrixScaling(&ScaleMat, planetscaling[i], planetscaling[i], planetscaling[i]);
		Object[i].toParentXForm = rotMat * TransMat;
	}

		D3DXMatrixRotationY(&rotMat, 5.0f);
		D3DXMatrixTranslation(&TransMat, Object[0].position.x, Object[0].position.y, Object[0].position.z);
		D3DXMatrixScaling(&ScaleMat, planetscaling[0], planetscaling[0], planetscaling[0]);
		Object[0].toParentXForm = rotMat * TransMat;
		Object[0].ScaleXForm = ScaleMat * TransMat;


	DIMOUSESTATE2 mouseState;
	ZeroMemory(&mouseState, sizeof(mouseState));

	// Get the input device state
	hr = m_pDIMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &mouseState );
	if(FAILED(hr))
	{
		hr = m_pDIMouse->Acquire();

		// Device has probably been lost if failed, if so keep trying to get it until it’s found.
		while( hr == DIERR_INPUTLOST)
		{
			hr = m_pDIMouse->Acquire();
		}

		// If we failed for some other reason
		for(int i = 0; i < 12; i++)
		{
			if(FAILED(hr))
			return;
			// Read the device state again
			m_pDIMouse->GetDeviceState(sizeof(DIMOUSESTATE2), &mouseState);
		}

	}
	
	for(int i = 0; i < 12; i++)
	{
		if(mouseState.rgbButtons[1] & 0x80)
		{
			planetscaling[i] += mouseState.lX * 0.01f; // X Axis
			planetscaling[i] += mouseState.lY * 0.01f; // Y Axis
			m_pD3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, true);
		}
	}
			
			rad = 270.0f;
			radM = 150.0f;
			radV = 215.0f;
			radMA = 360.0f;
			radJ = 260.0f;
			radS = 330.0f;
			radU = 390.0f;
			radN = 450.0f;
			radMO = 370.0f;
			radMOON = 300.0f;

			double time = timeGetTime() * 0.00009;
			double timeM = timeGetTime() * 0.0002;
			double timeV = timeGetTime() * 0.0001;
			double timeMA = timeGetTime() * 0.00008;
			double timeJ =  timeGetTime() * 0.000009;
			double timeS = timeGetTime() * 0.000008;
			double timeU = timeGetTime() * 0.000007;
			double timeN = timeGetTime() * 0.000006;
			double timeMO = timeGetTime() * 0.00009;
			double timeMOON = timeGetTime() * 0.00009;
	
			Object[2].position.x = sin(timeM)*radM;
			Object[2].position.y = cos(timeM)*radM;

			Object[3].position.x = sin(timeV)*radV;
			Object[3].position.y = cos(timeV)*radV;
				
			Object[1].position.x = sin(time)*rad;
			Object[1].position.y = cos(time)*rad;

			Object[4].position.x = sin(timeMA)*radMA;
			Object[4].position.y = cos(timeMA)*radMA;

			Object[5].position.x = sin(timeJ)*radJ;
			Object[5].position.y = cos(timeJ)*radJ;

			Object[6].position.x = sin(timeS)*radS;
			Object[6].position.y = cos(timeS)*radS;

			Object[7].position.x = sin(timeU)*radU;
			Object[7].position.y = cos(timeU)*radU;

			Object[8].position.x = sin(timeN)*radN;
			Object[8].position.y = cos(timeN)*radN;

			Object[9].position.x = sin(timeMO)*radMO;
			Object[9].position.y = cos(timeMO)*radMO;

			Object[9].position.x = sin(timeMOON)*radMOON;
			Object[9].position.y = cos(timeMOON)*radMOON;


		

	// For each object...
	for(int i = 0; i < 12; ++i)
	{
		// Initialize to identity matrix.
		D3DXMatrixIdentity(&Object[i].toWorldXForm);
		D3DXMatrixIdentity(&Object[0].ScaleForm);

		// The ith object's world transform is given by its
		// to-parent transform, followed by its parent's
		// to-parent transform, followed by its grandparent's
		// to-parent transform, and so on, up to the root's
		// to-parent transform.
		int k = i;
		while( k != -1 ) // While there exists an ancestor.
		{
			Object[i].toWorldXForm *= Object[k].toParentXForm;
			Object[i].ScaleForm *= Object[k].ScaleXForm;
			k = Object[k].parent; // Move up the ancestry chain.
			k = Object[k].parent2;
		}
	}

	
}
It actually crashes right at the end of the while loop, and when it does it opens up a new file called d3dx9math.inl, which I don't even understand, because thats not my file. Here is the code that it shows me when it does crash
Code:
D3DXMATRIX::operator FLOAT* ()
{
    return (FLOAT *) &_11;
}

D3DXINLINE
D3DXMATRIX::operator CONST FLOAT* () const
{
    return (CONST FLOAT *) &_11;
}


// assignment operators
D3DXINLINE D3DXMATRIX&
D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat )
{
    D3DXMatrixMultiply(this, this, &mat);
    return *this;
}

D3DXINLINE D3DXMATRIX&
D3DXMATRIX::operator += ( CONST D3DXMATRIX& mat )
{
    _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14;
    _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24;
    _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34;
    _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44;
    return *this;
}

D3DXINLINE D3DXMATRIX&
D3DXMATRIX::operator -= ( CONST D3DXMATRIX& mat )
{
    _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14;
    _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24;
    _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34;
    _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44;
    return *this;
}
it shows the arrow pointing inside this function D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ), at the return *this line. I don't know if this exception has to do with trying to run it on a new operating system, or maybe something isn't installed on the computer, but was installed on the previous one. and this is a 3d project as well, but I also noticed that when I go inside the project folder and trying to open up one of the 3d objects, it says an error occurred tying to open that type of file, which is a .x file. Its weird to because I have directx installed on the computer. Microsoft directx sdk (June 2010) version. I don't know if its the version of directx or that I cant open up the .x file from the project folder which could be causing the project to crash like it is. So this is my issue, and any help would be greatly appreciated

Thanks a lot
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Directx Initialization crossfire19 C++ Programming 0 February 11th, 2014 06:22 PM
about directx Innaorouk C# 2 August 27th, 2007 08:39 PM
Help. How to play media files using DirectX dextergaisie Pro VB 6 0 May 15th, 2007 06:09 AM
managed directx 9drawsubset problem? mmmobasher C# 0 December 1st, 2005 05:29 AM
directx programing bcmaverik VB.NET 5 January 28th, 2004 07:07 AM



All times are GMT -4. The time now is 03:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.