DX10 / C++ Sample Code Crashes On Execution

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

35 Replies - 1734 Views - Last Post: 23 April 2012 - 02:55 PM Rate Topic: -----

Topic Sponsor:

#1 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

DX10 / C++ Sample Code Crashes On Execution

Posted 31 January 2012 - 08:00 PM

Greetings Community!

I've been working on this issue for a few days, I've debugged the application in VS 2010 and traced outputs and they are all correct. I'm learning DirectX 10 from "Advanced 3D Game Programming with DirectX 10.0" - Peter Walsh, he used VS 2005 and I've converted all the book source to 2010 without issues.

I've compiled the demo application and when executed it just crashes, I'm thinking the error is due to how he is drawing text to the screen but I'm fairly new to this and I'm reaching out to learn more from experienced coders. I'm very comfortable with C++ logic and the only thing I've not gotten into yet are Templates. The application is just suppose to post text to the screen with a random color.

I believe I've attached all the needed code for the application, including the library file in question. Line 45 in the first code block is the call in question, this is what I believe is crashing the application. This chapter contains 2 projects, both are using the same method for drawing text and both crash. I've zipped the solution and all files so that if you'd like to see it on your end you can download it from: Temp Link 64MB Archive (I use a certian style structure and not the default SDK install folders so you may have to update the solution to use you're paths for the include directory, and linker directory.

Thank you for your time!

Here's The Application Code: (This file uses a library of encapsulated DX functions)

/*******************************************************************
 *         Advanced 3D Game Programming with DirectX 10.0
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *	
 *	See license.txt for modification and distribution information
 *		copyright (c) 2007 by Peter Walsh, Wordware
 ******************************************************************/

#include "stdafx.h"

#include <string>
using namespace std;

class cD3DSampleApp : public cApplication
{

public:

	//==========--------------------------  cApplication

	virtual void DoFrame( float timeDelta );

	cD3DSampleApp() :
		cApplication()
	{
		m_title = wstring( L"Direct3D Sample" );
	}
};

cApplication* CreateApplication()
{
	return new cD3DSampleApp();
}

void cD3DSampleApp::DoFrame( float timeDelta )
{
	if(!Graphics()) 
		return;

	// Clear the previous contents of the backbuffer
	float colClear[4] = {RandFloat(), RandFloat(), RandFloat(), 1.0f};
	Graphics()->Clear(colClear);
	
	// Output green text at a random location
	Graphics()->DrawTextString( rand()%640, rand()%480, D3DXCOLOR(0, 1, 0, 1), L"Advanced Direct3D 10.0" );

	// Present the back buffer to the primary surface to make it visible
	Graphics()->Present();
}



Here is the Graphic Portion:

/*******************************************************************
 *         Advanced 3D Game Programming with DirectX 10.0
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *	
 *	See license.txt for modification and distribution information
 *		copyright (c) 2007 by Peter Walsh, Wordware
 ******************************************************************/

#include <algorithm>

#include "stdafx.h"
#include "GraphicsLayer.h"
#include "Application.h"
#include "GameErrors.h"
#include "DxHelper.h"
#include "window.h"

using namespace std;


/**
 * This is the static member variable that points to the one
 * (and only one) graphics layer allowed in each application.
 */
cGraphicsLayer* cGraphicsLayer::m_pGlobalGLayer = NULL;

cGraphicsLayer::cGraphicsLayer(HWND hWnd)
{
	if(m_pGlobalGLayer)
		throw cGameError(
			L"cGraphicsLayer object already instantiated\n");
	m_pGlobalGLayer = this;

	m_hWnd = hWnd;
	m_pDevice = NULL;
	m_pBackBuffer = NULL;
	m_pSwapChain = NULL;
	m_pRenderTargetView = NULL;
	m_pFont = NULL;		
	m_pFontSprite = NULL;	
	m_pMessageQueue = NULL;
}


void cGraphicsLayer::DestroyAll()
{
	SafeRelease(m_pMessageQueue);
	SafeRelease(m_pFont);
	SafeRelease(m_pFontSprite);
	SafeRelease(m_pRenderTargetView);
    SafeRelease(m_pBackBuffer);	
	SafeRelease(m_pSwapChain);
	SafeRelease(m_pDevice);

	/**
	 * Prevent any further access to the graphics class
	 */
	m_pGlobalGLayer = NULL;
}

cGraphicsLayer::~cGraphicsLayer()
{
	DestroyAll();
}


void cGraphicsLayer::Present()
{
	HRESULT r = S_OK;

	assert(m_pDevice);
    
	r = m_pSwapChain->Present(0, 0);
	if(FAILED(r))
	{
		OutputDebugString(L"Present Failed!\n");
	}

	DumpMessages();
}

void cGraphicsLayer::DumpMessages()
{
	assert(m_pMessageQueue);

	HRESULT r = 0;

	while(1)
	{
		// Get the size of the message
		SIZE_T messageLength = 0;
		r = m_pMessageQueue->GetMessage(0, NULL, &messageLength);
		if(messageLength == 0)
			break;

		// Allocate space and get the message
		D3D10_MESSAGE * pMessage = (D3D10_MESSAGE*)malloc(messageLength);
		r = m_pMessageQueue->GetMessage(0, pMessage, &messageLength);
		if(FAILED(r))
		{
			OutputDebugString(L"Failed to get Direct3D Message");
			break;
		}
	
		TCHAR strOutput[MAX_PATH];
		swprintf_s(strOutput, MAX_PATH, L"D3DDMSG [Cat[%i] Sev[%i] ID[%i]: %s\n",
			pMessage->Category, pMessage->Severity, pMessage->ID, pMessage->pDescription);
		OutputDebugString(strOutput);
	}
}

void cGraphicsLayer::Clear(const float (&colClear)[4])
{
	HRESULT r = S_OK;
	assert(m_pDevice);

	m_pDevice->ClearRenderTargetView(m_pRenderTargetView, colClear);
}

void cGraphicsLayer::InitD3D(int width, int height, int bpp)
{
	HRESULT r = 0;

	// Structure to hold the creation parameters for the device
	DXGI_SWAP_CHAIN_DESC swapDesc;
	ZeroMemory(&swapDesc, sizeof(swapDesc));

	// Only want one back buffer
	swapDesc.BufferCount = 1;

	// Width and height of the back buffer
    swapDesc.BufferDesc.Width = 640;
    swapDesc.BufferDesc.Height = 480;

	// Standard 32bit surface type
    swapDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

	// 60hz refresh rate
    swapDesc.BufferDesc.RefreshRate.Numerator = 60;
    swapDesc.BufferDesc.RefreshRate.Denominator = 1;
    swapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;

	// Connect it to our main window
    swapDesc.OutputWindow = m_hWnd;

	// No multisampling
    swapDesc.SampleDesc.Count = 1;
    swapDesc.SampleDesc.Quality = 0;

	// Windowed mode
    swapDesc.Windowed = TRUE;
	
	// Create the device using hardware acceleration 
	r = D3D10CreateDeviceAndSwapChain( 
			NULL,							// Default adapter
			D3D10_DRIVER_TYPE_HARDWARE,		// Hardware accelerated device
			NULL,							// Not using a software DLL for rendering
			D3D10_CREATE_DEVICE_DEBUG,		// Flag to allow debug output
			D3D10_SDK_VERSION,				// Indicates the SDK version being used
			&swapDesc,		
			&m_pSwapChain,
			&m_pDevice);

	if(FAILED(r))
	{
		throw cGameError(L"Could not create IDirect3DDevice10");
	}

	r = m_pDevice->QueryInterface(__uuidof(ID3D10InfoQueue), (LPVOID*)&m_pMessageQueue);
	if(FAILED(r))
	{
		throw cGameError(L"Could not create IDirect3DDevice10 message queue");
	}
	m_pMessageQueue->SetMuteDebugOutput(false);	// No muting
	m_pMessageQueue->SetMessageCountLimit(-1);	// Unlimited messages

	// Keep a copy of the screen dimensions
	m_rcScreenRect.left = m_rcScreenRect.top = 0;
	m_rcScreenRect.right = width;
	m_rcScreenRect.bottom = height;

	// Get a copy of the pointer to the back buffer
    r = m_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&m_pBackBuffer);
    if(FAILED(r))
	{
		throw cGameError(L"Could not get back buffer");
	}
	
	// Create a render target view
    r = m_pDevice->CreateRenderTargetView(m_pBackBuffer, NULL, &m_pRenderTargetView);
    if(FAILED(r))
	{
		throw cGameError(L"Could not create render target view");
	}

	// Attach the render target view to the output merger state
    m_pDevice->OMSetRenderTargets(1, &m_pRenderTargetView, NULL);

	// Create a viewport the same size as the backbuffer
	D3D10_VIEWPORT vp;
    vp.Width = width;
    vp.Height = height;
    vp.MinDepth = 0.0f;
    vp.MaxDepth = 1.0f;
    vp.TopLeftX = 0;
    vp.TopLeftY = 0;
    m_pDevice->RSSetViewports( 1, &vp );

	// Create the font for rendering text
	D3DX10CreateFont(m_pDevice, 
		15, 0, 
		FW_BOLD, 
		1, 
		FALSE, 
		DEFAULT_CHARSET, 
        OUT_DEFAULT_PRECIS, 
		DEFAULT_QUALITY, 
		DEFAULT_PITCH | FF_DONTCARE, 
		L"Arial", 
		&m_pFont);
	assert(m_pFont);

	// Create the sprite to use to render letters
	D3DX10CreateSprite(m_pDevice, m_uiMAX_CHARS_PER_FRAME, &m_pFontSprite);
}


void cGraphicsLayer::DrawTextString(int x, int y, D3DXCOLOR color, const TCHAR* strOutput)
{
	m_pFontSprite->Begin(0);
	RECT rect = {x, y, m_rcScreenRect.right, m_rcScreenRect.bottom};
	m_pFont->DrawText(m_pFontSprite, strOutput, -1, &rect, DT_LEFT, color);
	m_pFontSprite->End();
}


void cGraphicsLayer::Create(HWND hWnd, short width, short height)
{
	new cGraphicsLayer(hWnd); // construct the object.

	// Init Direct3D and the device for fullscreen operation
	Graphics()->InitD3D(width, height, 32);
}



For all applications created the following is used:

/*******************************************************************
 *         Advanced 3D Game Programming with DirectX 10.0
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *	
 *	See license.txt for modification and distribution information
 *		copyright (c) 2007 by Peter Walsh, Wordware
 ******************************************************************/

#include "stdafx.h"

#include <list>
using namespace std;

#include <mmsystem.h> // for timeGetTime

cApplication* cApplication::m_pGlobalApp = NULL;

HINSTANCE g_hInstance;

HINSTANCE AppInstance()
{
	return g_hInstance;
}

/**
 * WinMain is hidden away in a library because
 * almost everything it does is the same across
 * all applications we'll write.
 */
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{

	cApplication* pApp;

	g_hInstance = hInstance;

	try
	{
		pApp = CreateApplication();

		pApp->Init();
		pApp->SceneInit();
		pApp->Run();
	}
	catch( cGameError& err )
	{
		/**
		 * Knock out the graphics before we try to pop up a dialog, 
		 * just to be safe.
		 */
		if( Graphics() )
		{
			Graphics()->DestroyAll();
		}
		MessageBox( NULL, err.GetText(), L"Error!", MB_OK|MB_ICONEXCLAMATION );

		// Clean everything up
		delete pApp;
		return 0;
	}

	delete pApp;
	return 0;
}



cApplication::cApplication()
{
	if( m_pGlobalApp )
	{
		throw cGameError(L"Application object already created!\n");
	}
	m_pGlobalApp = this;

	m_title = wstring(L"Default window name");
	m_width = 640;
	m_height = 480;
	m_bpp = 32;
	m_bActive = true;
}


cApplication::~cApplication()
{
	delete Graphics();
	delete Input();
	delete Sound();
	delete MainWindow();
}


void cApplication::Init()
{
	InitPrimaryWindow();
	InitGraphics();
	InitInput();
	InitSound();
	InitExtraSubsystems();
}


void cApplication::Run()
{
	bool done = false;

	static float lastTime = (float)timeGetTime(); 

	while( !done )
	{
		/**
		 * Does the user want to quit?
		 */
	/*	if( Input()->GetKeyboard() )
		{
			if( Input()->GetKeyboard()->Poll( DIK_ESCAPE ) ||
				Input()->GetKeyboard()->Poll( DIK_Q ) )
			{
				PostMessage( MainWindow()->GetHWnd(), WM_CLOSE, 0, 0 );
			}
		}*/


		/**
		 * Message pump
		 */
		while( !done && MainWindow()->HasMessages() )
		{
			if( resFalse == MainWindow()->Pump() )
				done = true;
		}



		/**
		 * We're about ready to let the class draw the frame.
		 * find out how much time elapsed since the last frame
		 * we calc these whether we have focus or not, to avoid
		 * a large delta once we start rendering after idle time
		 */
		float currTime = (float)timeGetTime();
		float delta = (currTime - lastTime)/1000.f;

		if( m_bActive  )
		{
			// Update the Input devices
			if( Input() )
				Input()->UpdateDevices();

			DoFrame( delta );
		}
		else
		{
			DoIdleFrame( delta );
		}

		lastTime = currTime;
	}
}



void cApplication::DoFrame( float timeDelta )
{

}

void cApplication::DoIdleFrame( float timeDelta )
{
}


void cApplication::SceneInit()
{
	// by default, we have no scene, so do nothing.
}


void cApplication::InitPrimaryWindow()
{
	new cWindow( m_width, m_height, m_title.c_str() );

	MainWindow()->RegisterClass();
	MainWindow()->InitInstance();
}


void cApplication::InitGraphics()
{

	cGraphicsLayer::Create( 
		MainWindow()->GetHWnd(), 
		m_width, m_height);
}


void cApplication::InitInput()
{
	cInputLayer::Create( AppInstance(), MainWindow()->GetHWnd(), NULL, true, true );
}


void cApplication::InitSound()
{
	cSoundLayer::Create( MainWindow()->GetHWnd() );
}


void cApplication::InitExtraSubsystems()
{
}


void cApplication::SceneEnd()
{
}



Is This A Good Question/Topic? 0
  • +

Replies To: DX10 / C++ Sample Code Crashes On Execution

#2 stayscrisp  Icon User is offline

  • Lets-a play!
  • member icon

Reputation: 800
  • View blog
  • Posts: 3,691
  • Joined: 14-February 08

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 02:18 AM

Can you please give the error you receive when the application crashes?
Was This Post Helpful? 0
  • +
  • -

#3 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 10:20 AM

No error is given just crashes and windows tries to find the problem and fails.

Here's the debug output from VS 2010:

'DSSample.exe': Loaded 'E:\DX10_Source\Chapter 03\BIN\DSSample.exe', Symbols loaded.
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\d3d10.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\d3d10core.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\dxgi.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\d3dx10_43.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\dinput8.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\dsound.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\powrprof.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\igd10umd32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\D3D10SDKLayers.DLL', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\D3DCompiler_43.dll', Cannot find or open the PDB file
D3D10: WARNING: ID3D10Buffer::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS ]
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\hid.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\ntmarta.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\Wldap32.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\MMDevAPI.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\propsys.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'DSSample.exe': Loaded 'C:\Windows\SysWOW64\AudioSes.dll', Cannot find or open the PDB file
D3DDMSG [Cat[6] Sev[2] ID[55]: ??????????????›????????????????????????4?????!????
D3DDMSG [Cat[6] Sev[2] ID[55]: ??????????????›????????????????????????4?????!????
D3DDMSG [Cat[6] Sev[2] ID[55]: ??????????????›????????????????????????4?????!????
D3DDMSG [Cat[6] Sev[2] ID[55]: ??????????????›????????????????????????4?????!????
D3DDMSG [Cat[6] Sev[2] ID[55]: ??????????????›????????????????????????4?????!????
D3DDMSG [Cat[6] Sev[2] ID[55]: ??????????????›????????????????????????4?????!???? <--- repeates while running
The program '[2900] DSSample.exe: Native' has exited with code 0 (0x0). <- I end debug mode here




I searched on google about this error and it seems that VS 2010 is the cause of the issue. Above the missing PDB files are also not an issue from what I've read online( Correct me if I'm wrong please!).

D3D10: WARNING: ID3D10Buffer::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS ]


Was This Post Helpful? 0
  • +
  • -

#4 stayscrisp  Icon User is offline

  • Lets-a play!
  • member icon

Reputation: 800
  • View blog
  • Posts: 3,691
  • Joined: 14-February 08

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 10:30 AM

Are you running visual studio as an administrator?
Was This Post Helpful? 0
  • +
  • -

#5 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 10:44 AM

I was just launching it off the taskbar, I just tried using the 'Run as Administrator' option. The output is identical.
Was This Post Helpful? 0
  • +
  • -

#6 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 12:50 PM

I suspect very strongly that this issue is being caused by mixing 32- and 64-bit code and/or your environment being set up incorrectly. Looking at your paths you are referencing C:\Windows\SysWOW64. You should also have a C:\Windows\System32 folder next to the SysWOW64. Can you do a search for the relevant .pdb files in both? I'm suspecting they might exist in your System32 folder instead.

Let's see where that takes us.
Was This Post Helpful? 0
  • +
  • -

#7 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 01:16 PM

.PDB or the .dll files it's trying to find? As for the .PDB nothing is listed like kernel32.pdb

Both folders contain the .dll files from what I've searched so far for .dll
Was This Post Helpful? 0
  • +
  • -

#8 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 01:36 PM

Okay, I've inspected the .sln file from the zip that you've provided. There are four build configurations:

	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Win32 = Debug|Win32
		Debug|x64 = Debug|x64
		Release|Win32 = Release|Win32
		Release|x64 = Release|x64
	EndGlobalSection



over four projects (including the main one):

Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLib", "GameLib\GameLib.vcxproj", "{D29DCD4F-7D0A-4925-B4D5-3BD64EFB6668}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "D3DSample", "D3DSample\D3DSample.vcxproj", "{9B7D01C9-2257-4676-BA2F-03D088E08045}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DSSample", "DSSample\DSSample.vcxproj", "{C2650C13-58AD-4C15-B5FF-3B6ABA83F4D0}"
EndProject



Can you answer the following:

1. What is the OS you are using?
2. Which build configurations are you using?
3. What is the build config for each of the projects?
4. What is the name of the default project (the one highlighted in bold in the solution pane?
Was This Post Helpful? 0
  • +
  • -

#9 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 01:45 PM

Can you answer the following:

1. What is the OS you are using? - Windows 7
2. Which build configurations are you using? - Win32 / Release
3. What is the build config for each of the projects? - Win32 / Release
4. What is the name of the default project (the one highlighted in bold in the solution pane? - DSSample is bold
Was This Post Helpful? 0
  • +
  • -

#10 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 01:59 PM

Okay, immediately I can see the following issues:

1. I'm assuming you're using Win7-32 and not 64-bit.
2. You should be building in debug and not release! This is why there is the lack of information, because your code isn't hooked into your IDE as it should be in order to pinpoint what has gone wrong. Please build everything in Win32 / Debug and see what happens.
Was This Post Helpful? 0
  • +
  • -

#11 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 02:00 PM

I will go do that right now!

Windows 7 - 64Bit also (Edit)

This post has been edited by gaddam: 01 February 2012 - 02:04 PM

Was This Post Helpful? 0
  • +
  • -

#12 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 02:24 PM

'D3DSample.exe': Loaded 'E:\DX10_Source\Chapter 03\BIN\D3DSample.exe', Symbols loaded.
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\d3d10.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\d3d10core.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\dxgi.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\D3DX10d_43.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\dsound.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\powrprof.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\dinput8.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\igd10umd32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\D3D10SDKLayers.DLL', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\D3DCompiler_43.dll', Cannot find or open the PDB file
D3D10: WARNING: ID3D10Buffer::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS ]
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\hid.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\MMDevAPI.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\propsys.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\AudioSes.dll', Cannot find or open the PDB file
D3DX10: (INFO) Using Intel SSE2 optimizations
D3DDMSG [Cat[6] Sev[2] ID[55]: ??????????????›????????????????????????4?????!????????
The program '[976] D3DSample.exe: Native' has exited with code 0 (0x0).



While running in debugger VS2010: This just repeats, can't access window once it loses focus.

D3DDMSG [Cat[6] Sev[2] ID[55]: ??????????????›????????????????????????4?????!????????



This appears when I end debugging:

The program '[976] D3DSample.exe: Native' has exited with code 0 (0x0).




When I launch the application outside of VS2010 it just hangs and eventually closes with windows trying to find a solution.
Was This Post Helpful? 0
  • +
  • -

#13 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 01 February 2012 - 02:32 PM

Debug code will not run outside the environment, only release will.

There is something wrong with your setup in that I do not know why over forum posts what is wrong, and my card doesn't support DX10! One would normally come over and inspect your environment in a work setting.

Is there another member with DX10 compat. who can try to run the project in its current state?
Was This Post Helpful? 0
  • +
  • -

#14 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 02 February 2012 - 08:24 AM

Update:

Last night I reformatted my computer, installed everything from scratch! I had VS 2008 Express installed and even though I uninstalled it all, just incase something was lingering around! I did some further google searches to find out about the PDB files on msdn. I am now using the Microsoft Server to load them and it appears to work for those. I've updated the zip file in the original post to only reflect the program in question, so it won't have multiple projects in it. This time it includes the full directory structure, and all SDK's are defaulted to normal install paths.
SLN <- link again (edit)

Here is the new debug information from VS 2010:

'D3DSample.exe': Loaded 'C:\Programming\DX10 Learning\Adv DX10 3D GP\CH2-DXInitiation\Chapter 02\BIN\D3DSample.exe', Symbols loaded.
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\d3d10.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\d3d10core.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\dxgi.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\D3DX10d_43.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll', Symbols loaded (source information stripped).
'D3DSample.exe': Unloaded 'C:\Windows\SysWOW64\setupapi.dll'
'D3DSample.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll'
'D3DSample.exe': Unloaded 'C:\Windows\SysWOW64\oleaut32.dll'
'D3DSample.exe': Unloaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\igd10umd32.dll', Cannot find or open the PDB file
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\D3D10SDKLayers.DLL', Symbols loaded (source information stripped).
'D3DSample.exe': Loaded 'C:\Windows\SysWOW64\D3DCompiler_43.dll', Symbols loaded (source information stripped).
D3D10: WARNING: ID3D10Buffer::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS ]
D3DX10: (INFO) Using Intel SSE2 optimizations
D3DDMSG [Cat[6] Sev[2] ID[55]: ??????????????›????????????????????????4?????!???????? <- scrolls till I end debugger
The program '[900] D3DSample.exe: Native' has exited with code 0 (0x0).



Something further to note is that the breakpoints now show information:
There are only 50 lines in the file so not sure why it's showing those line numbers.

DSSample.cpp, line 148 (no condition) break always
DSSample.cpp, line 94 (no condition) break always



When I break the debugger it's landing in this function:
It's getting the messages from DirectX and outputting them to the window as it should, and there is an error encoded but I'm not sure what the exact error is, just from this output.

void cGraphicsLayer::DumpMessages()
{
	assert(m_pMessageQueue);

	HRESULT r = 0;

	while(1)
	{
		// Get the size of the message
		SIZE_T messageLength = 0;
		r = m_pMessageQueue->GetMessage(0, NULL, &messageLength);
		if(messageLength == 0)
			break;

		// Allocate space and get the message
		D3D10_MESSAGE * pMessage = (D3D10_MESSAGE*)malloc(messageLength);
		r = m_pMessageQueue->GetMessage(0, pMessage, &messageLength);
		if(FAILED(r))
		{
			OutputDebugString(L"Failed to get Direct3D Message");
			break;
		}
	
		TCHAR strOutput[MAX_PATH];
		swprintf_s(strOutput, MAX_PATH, L"D3DDMSG [Cat[%i] Sev[%i] ID[%i]: %s\n",
			pMessage->Category, pMessage->Severity, pMessage->ID, pMessage->pDescription);
		OutputDebugString(strOutput);
	}
}



I'm really hoping that someone in the community is able to compile this and help me with a solution so I can continue on with my learning efforts. Thank you for your time and patience with this noob.

This post has been edited by gaddam: 02 February 2012 - 08:35 AM

Was This Post Helpful? 0
  • +
  • -

#15 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 02 February 2012 - 08:44 AM

Ok I'm on a roll here now, so I'm going to keep at this until it's resolved!

The function I posted above is actually helpful! I just looked up the error and here it is:

HRESULT: 0x00000037 (55)
Name: ERROR_DEV_NOT_EXIST
Description: n/a
Severity code: Success
Facility Code: FACILITY_NULL (0)
Error Code: 0x0037 (55)



So now I need to figure out why the device isn't getting initialized properly and then I can move on from there. I'll be posting the solution here if I find it or a member of the community finds it, so that others who purchase this learning material are able to resolve the issues I ran into!

Also, Please correct me if I'm wrong, or going about this in an incorrect manner!

Code used to initiate D3D and setup the device:

void cGraphicsLayer::InitD3D(int width, int height, int bpp)
{
	HRESULT r = 0;

	// Structure to hold the creation parameters for the device
	DXGI_SWAP_CHAIN_DESC swapDesc;
	ZeroMemory(&swapDesc, sizeof(swapDesc));

	// Only want one back buffer
	swapDesc.BufferCount = 1;

	// Width and height of the back buffer
    swapDesc.BufferDesc.Width = 640;
    swapDesc.BufferDesc.Height = 480;

	// Standard 32bit surface type
    swapDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

	// 60hz refresh rate
    swapDesc.BufferDesc.RefreshRate.Numerator = 60;
    swapDesc.BufferDesc.RefreshRate.Denominator = 1;
    swapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;

	// Connect it to our main window
    swapDesc.OutputWindow = m_hWnd;

	// No multisampling
    swapDesc.SampleDesc.Count = 1;
    swapDesc.SampleDesc.Quality = 0;

	// Windowed mode
    swapDesc.Windowed = TRUE;
	
	// Create the device using hardware acceleration 
	r = D3D10CreateDeviceAndSwapChain( 
			NULL,							// Default adapter
			D3D10_DRIVER_TYPE_HARDWARE,		// Hardware accelerated device
			NULL,							// Not using a software DLL for rendering
			D3D10_CREATE_DEVICE_DEBUG,		// Flag to allow debug output
			D3D10_SDK_VERSION,				// Indicates the SDK version being used
			&swapDesc,		
			&m_pSwapChain,
			&m_pDevice);

	if(FAILED(r))
	{
		throw cGameError(L"Could not create IDirect3DDevice10");
	}

	r = m_pDevice->QueryInterface(__uuidof(ID3D10InfoQueue), (LPVOID*)&m_pMessageQueue);
	if(FAILED(r))
	{
		throw cGameError(L"Could not create IDirect3DDevice10 message queue");
	}
	m_pMessageQueue->SetMuteDebugOutput(false);	// No muting
	m_pMessageQueue->SetMessageCountLimit(-1);	// Unlimited messages

	// Keep a copy of the screen dimensions
	m_rcScreenRect.left = m_rcScreenRect.top = 0;
	m_rcScreenRect.right = width;
	m_rcScreenRect.bottom = height;

	// Get a copy of the pointer to the back buffer
    r = m_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&m_pBackBuffer);
    if(FAILED(r))
	{
		throw cGameError(L"Could not get back buffer");
	}
	
	// Create a render target view
    r = m_pDevice->CreateRenderTargetView(m_pBackBuffer, NULL, &m_pRenderTargetView);
    if(FAILED(r))
	{
		throw cGameError(L"Could not create render target view");
	}

	// Attach the render target view to the output merger state
    m_pDevice->OMSetRenderTargets(1, &m_pRenderTargetView, NULL);

	// Create a viewport the same size as the backbuffer
	D3D10_VIEWPORT vp;
    vp.Width = width;
    vp.Height = height;
    vp.MinDepth = 0.0f;
    vp.MaxDepth = 1.0f;
    vp.TopLeftX = 0;
    vp.TopLeftY = 0;
    m_pDevice->RSSetViewports( 1, &vp );

	// Create the font for rendering text
	D3DX10CreateFont(m_pDevice, 
		15, 0, 
		FW_BOLD, 
		1, 
		FALSE, 
		DEFAULT_CHARSET, 
        OUT_DEFAULT_PRECIS, 
		DEFAULT_QUALITY, 
		DEFAULT_PITCH | FF_DONTCARE, 
		L"Arial", 
		&m_pFont);
	assert(m_pFont);

	// Create the sprite to use to render letters
	D3DX10CreateSprite(m_pDevice, m_uiMAX_CHARS_PER_FRAME, &m_pFontSprite);
}



I'm not getting any of the error msgs thrown, so I can only assume that the device is being created properly and getting lost..

This post has been edited by gaddam: 02 February 2012 - 08:49 AM

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3