• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

Direct X 11: Creating the device issue

2 posts in this topic

I'm trying to jump into Direct X 11 and I'm having some issues creating a device when the adapter is specified


I currently have this custom struct to hold the information of each adapter that could exist. I also have a vector to hold them all in

//Struct to hold adapter information
struct DisplayAdapter
	IDXGIAdapter* adapter;
	DXGI_MODE_DESC* resolutions;
	DXGI_ADAPTER_DESC description;
	UINT numberOfResolutions;

//Vector of all the devices
std::vector<DisplayAdapter> availableDisplayAdapters;

I use this method to find all of the available adapters, which then fills my adapter vector

bool SystemX11::findDisplayAdapters()
        //Clean out the vector of adapters and set the current adapter to 0
	currentAdapter = 0;

	HRESULT result;

        //Create the factory
	IDXGIFactory *factory = NULL;
	result = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**) (&factory));

		std::cout<<"Failed to create the factory"<<std::endl;
		return false;
        //Create all the items needs to store and find the display adapters
	DisplayAdapter tempAdapter;
	IDXGIOutput *adapterOutput;
	ZeroMemory(&tempAdapter, sizeof(DisplayAdapter));
	ZeroMemory(&adapterOutput, sizeof(IDXGIOutput));
        //Find all the display adapters
	for(UINT i = 0; factory->EnumAdapters(i, &tempAdapter.adapter) != DXGI_ERROR_NOT_FOUND; ++i)
		//Get the description
		//Get the display modes
		tempAdapter.adapter->EnumOutputs(0, &adapterOutput);
		adapterOutput->GetDisplayModeList(supportedDisplayFormat, 0, &tempAdapter.numberOfResolutions, NULL);
		tempAdapter.resolutions = new DXGI_MODE_DESC[tempAdapter.numberOfResolutions];
		adapterOutput->GetDisplayModeList(supportedDisplayFormat, 0, &tempAdapter.numberOfResolutions, tempAdapter.resolutions);

		//[Debug Stuff]
		std::wcout<<"Display Adapter: "<<tempAdapter.description.Description<<std::endl;
		for(int i = 0; i < tempAdapter.numberOfResolutions; i++)
			if(tempAdapter.resolutions[i].Scaling == 0)
				std::cout<<tempAdapter.resolutions[i].Width<<" x "<<tempAdapter.resolutions[i].Height<<" "<<tempAdapter.resolutions[i].RefreshRate.Numerator/tempAdapter.resolutions[i].RefreshRate.Denominator<<"hz"<<std::endl;
                //Put the new adapter in the vector of available adapters

	//Clean up of stuff

        //CLean up the factor
	if(factory != NULL)
		factory ->Release();
        //Clean up the temp adapter
	if(tempAdapter.adapter != NULL)

        ///Clean the temp resolutions
	if(tempAdapter.resolutions != NULL)
		delete [] tempAdapter.resolutions;

        //Clear the adapter output
	if(adapterOutput != NULL)

	return true;

Here is the clean up adapter method above just in case

bool SystemX11::cleanDisplayAdapters()
        //If there is nothing to clean backout
		return false;

        //For every device do clean up
	for(std::vector<DisplayAdapter>::iterator i = availableDisplayAdapters.begin(); i != availableDisplayAdapters.end(); i++)
		(*i).numberOfResolutions = NULL;
		ZeroMemory(&(*i).description, sizeof(DXGI_ADAPTER_DESC));
		delete [] (*i).resolutions;
        //Clear the vector

	return true;

Now my issue is when I acutally try to create the device, for some reason it fails to create when I use my first adapter in my vector. This is the only adatper I have. Also for some reason if I use NULL in the first parameter the device creates just fine.


Here is my create device code

bool SystemX11::createDirectDevice(int adapterToUse)
        //Make sure we are creating on the right device, adapterToUse is 0 in this case. The first slot in the vector
	std::wcout<<"Creating device from: "<<availableDisplayAdapters[adapterToUse].description.Description<<std::endl;

        //Attempt to create the device
	hr = D3D11CreateDevice(availableDisplayAdapters[adapterToUse].adapter,

        //If we failed
		std::cout<<"Failed to create the Direct X device. HR Error: "<<hr<<std::endl;
		return false;

	return true;

What am I doing wrong?

I'm not really sure why this is happening, the hr error code printed out is -2147024809

Edited by noodleBowl

Share this post

Link to post
Share on other sites

If you specify an adapter as the first parameter of D3D11CreateDevice, then you have to pass D3D_DRIVER_TYPE_UNKNOWN as the driver type. I believe the docs for D3D11CreateDevice say this if you read through the remarks section.


<Other portions of quote>


While this is something to try out. Is it possible that because I use a "temp" DisplayAdapter struct and clean it up that I'm faced with null memory area?

Also maybe the scope of the "temp" object could be effecting it? Seeing as the method to find the adapters and the method to create the device are seperated


I would solve this using a deep copy but I'm unsure how to do this.  Especially since the struct includes pointers for the IDXGIAdapter COM object and array of DXGI_MODE_DESCs. Or am I just thinking wayout in left field?


Then at least I would know the error lies in the D3D_DRIVER_TYPE_UNKNOWN and not something else.

Edited by noodleBowl

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0