I'm reading Introduction to 3D Game Programming with DirectX 10 to learn some DirectX, and I was trying to do the proposed exercises (chapter 4 for the ones who have the book).
One exercise asks to disable the Alt+Enter functionality (toggle full screen mode) using IDXGIFactory::MakeWindowAssociation
.
However it toggles full screen mode anyway, and I can't understand why. This is my code:
HR(D3D10CreateDevice(
0, //default adapter
md3dDriverType,
0, // no software device
createDeviceFlags,
D3D10_SDK_VERSION,
&md3dDevice) );
IDXGIFactory *factory;
HR(CreateDXGIFactory(__uuidof(IDXGIFactory), (void **)&factory));
HR(factory->CreateSwapChain(md3dDevice, &sd, &mSwapChain));
factory->MakeWindowAssociation(mhMainWnd, DXGI_MWA_NO_ALT_ENTER);
ReleaseCOM(factory);
I think the problem is this.
Since you create the device by yourself (and not through the factory) any calls made to the factory you created won't change anything.
So either you:
a) Create the factory earlier and create the device through it
OR
b) Retrieve the factory actually used to create the device through the code below.
IDXGIDevice * pDXGIDevice;
HR( md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void **)&pDXGIDevice) );
IDXGIAdapter * pDXGIAdapter;
HR( pDXGIDevice->GetParent(__uuidof(IDXGIAdapter), (void **)&pDXGIAdapter) );
IDXGIFactory * pIDXGIFactory;
pDXGIAdapter->GetParent(__uuidof(IDXGIFactory), (void **)&pIDXGIFactory);
And call the function through that factory (after the SwapChain has been created)
pIDXGIFactory->MakeWindowAssociation(mhMainWnd, DXGI_MWA_NO_ALT_ENTER);