I got a ton of questions about how to do proper set up for Direct x 11, maily because I'm not sure what needs to be checked for and the tutorials on this seem to be a little lackluster. So if I leave anything out please let me know.
Currently I do the following
1. Create a factory
2. Use the facotry to get all the available display adapters
3. Based on the first display adapter we find, get all the available display modes that are of Scaling type
4. Create the device
5. Create the swapchian based on the 800 x 600 diplsay mode found
6. Create the backbuffer render target and viewport
Now I have some issues:
Question 1
When getting the available display adapters I use this code:
for(UINT i = 0; deviceFactory->EnumAdapters(i, ¤tDeviceAdapter) != DXGI_ERROR_NOT_FOUND; ++i)
{
availableDeviceAdapters.push_back(currentDeviceAdapter);
}
currentDeviceAdapter = availableDeviceAdapters[0];
currentDeviceAdapter->GetDesc(¤tAdapterDescription);
std::wcout<<"Available Adapter:"<<currentAdapterDescription.Description<<std::endl;
std::cout<<"Finished getting adapters"<<std::endl;
getchar();
When I do clean up though using:
//Works on clean up
if(currentDeviceAdapter != NULL)
currentDeviceAdapter->Release();
//Breaks in here
for(std::vector<IDXGIAdapter*>::iterator i = availableDeviceAdapters.begin(); i != availableDeviceAdapters.end(); i++)
{
//Breaks here even when checking for NULL
if((*i) != NULL)
(*i)->Release();
}
availableDeviceAdapters.clear();
I get a accesss violation, how am I supposed to properly clean this up?
My variables are declared like so
IDXGIAdapter *currentDeviceAdapter;
std::vector<IDXGIAdapter*> availableDeviceAdapters;
Question 2
In Direct X 9 I got Direct X ready first and then created my window based on the resolution I wanted to use.
Eg: Loop through all teh supported resolutions and pick 800 x 600; If it was unavailable fallback to a 640 x 480 resolution.
It seems this can not be done in Direct X 11, unless I create window first the the swapchain creation fails. Which sort of makes sense since the OutputWindow cannot be NULL according to the documentation. But is there away arround this? Or do I need to be adjusting my window size after direct x is setup? Do I have any special checks in the window's callback function for this to happen?
Question 3
My final question... for now at least
What happened to checking device caps in Direct X 11? How do I check if the adapter I use is able to support feature X or use something Y?
Eg: The format used when creating the swap chain. Right now I use DXGI_FORMAT_R8G8B8A8_UNORM. But what if someone can't support this?