Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Program exits at Direct3D initialization (D3D11CreateDevice)

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Nick C.   Members   


Posted 06 November 2012 - 04:26 AM

Hello everyone

About a week ago I've started reading "3D game programming with DirectX 11" by Frank D. Luna. After a few days I came at the point of the initialization. It took me a while to get everything to work properly (linking libraries (especially Effects11.lib) and including wrong paths), but eventually it worked. But all of a sudden (that's what I'm here for, possible causes Posted Image), not one of my projects works anymore. In each of my projects the program exits at the same line: D3D11CreateDevice. Using breakpoints, I can't step into the line. I don't get any errors or warnings.

The values of the datamembers, just before execution of this method are:

createDeviceFlags = 2; (changed from 0 to 2 at the preceding instruction)
D3D11_SDK_VERSION: speaks for itself. (7 possibilities ofcourse)
&md3dDevice, and &md3dImmediateContext: 0X00000000;
&featureLevel: some random address;

Any possible causes would be appreciated Posted Image
Btw, I've already reinstalled directx sdk (June 2010), after some problems.

[source lang="cpp"]bool D3DApp::InitDirect3D(){// Create the device and device context.UINT createDeviceFlags = 0;#if defined(DEBUG) || defined(_DEBUG) createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;#endifD3D_FEATURE_LEVEL featureLevel;HRESULT hr = D3D11CreateDevice( 0, // default adapter md3dDriverType, 0, // no software device createDeviceFlags, 0, 0, // default feature level array D3D11_SDK_VERSION, &md3dDevice, &featureLevel, &md3dImmediateContext); //...remaining thing to do}[/source]

Edit: Sigh, even code tags don't work -.-
Edit2: Damnit, I don't know anymore, recreated project (new projects, but dragged same files), and now I'm getting the same error I got a few hours ago:
"warning LNK4204: 'C:\Nick\D3D projects\DVD\Code\Test\Debug\vc100.pdb' is missing debugging information for referencing module; linking object as if no debug info C:\Nick\D3D projects\DVD\Code\Test\Effects11d.lib(d3dx11dbg.obj)"

14 warnings. Alle possible solutions I found from google didn't help.

Edited by Nick C., 06 November 2012 - 05:15 AM.

#2 Tsus   Members   


Posted 06 November 2012 - 06:47 AM

Hi Nick,

Using a default adapter doesn't work for me either. Perhaps just try to iterate the adapters. (In case you have multiple graphics cards, try to build a device on each and see which one has the best feature level.)

bool D3D::CreateDevice()
	// Get the factory, so we can iterate the adapters and later build a swap chain.
	if(FAILED(CreateDXGIFactory(__uuidof(IDXGIFactory) ,(void**)&_Factory)))
		_Factory = NULL;
	UINT createDeviceFlags = 0;
#ifdef _DEBUG
	createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
	D3D_DRIVER_TYPE driverTypes[] =
	UINT numDriverTypes = sizeof( driverTypes ) / sizeof( driverTypes[0] );
	unsigned int numFeatureLevels = 3;

	// Iterate the driver types (chose the first one that works. -> possible to use software fallback)
	for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ )
		_DriverType = driverTypes[driverTypeIndex];
		// Iterate the adapters
		for ( UINT i = 0;
			_Factory->EnumAdapters(i, &_Adapter) != DXGI_ERROR_NOT_FOUND;
		++i )
			// Try to create a device
			hr = D3D11CreateDevice(_Adapter, _DriverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels,	  D3D11_SDK_VERSION,  &_Device, &_FeatureLevel, &_ImmediateContext);
			if (SUCCEEDED(hr)) // pick the first that works (this is not necessarily the best one!)
		if( SUCCEEDED( hr ) )
	return true;

As for the debug info: do you have built the effect framework on debug and release, and link the correct version respectively?

Best regards,

#3 Nick C.   Members   


Posted 06 November 2012 - 07:23 AM

Thanks for the answer Tsus, however I've already solved my two problems (but I'll keep your code in mind, might come in handy in the future :)).

As for the LNK4204 warning, I rebuilt the solution in "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\Effects11" under debug mode, copied it to my project's directory and linked the correct libraries (which I did so many times...).
But the biggest problem was in fact, only a few Direct3D11 methods could be used properly. As pure frustration, I reinstalled my graphics driver, and it works perfectly now! :)
(don't ask why, how can drivers change by themselves..)

Anyway, thanks for the help, and sorry I posted this topic, but I just wanted some help badly, after hours and hours of messing around.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.