Get the current display mode using D3D10
Hi I'm moving to D3D10 from D3D9. I know in d3d9 you can use GetAdaptorDisplayMode. But can't figure out how to do it in D3D10, specifically how to get the display format. I know that I could use EnumDisplaySettings to get the current resolution and bits per pixel, but there is no way to safely convert this to a DXGI Format.
So is there a proper function to do this? Or do I need to use some sort of hack?
Thx
Eternal Newbie
Create a IDXGIFactory interface, get an IDXGIAdapter and make a call to its function EnumOutputs.
That gives me list of possible display modes for a particular adaptor. But doesn't give me the current display mode. I could search the list for modes that match the details I get from EnumDisplaySettings, however that seems kinda roundabout way of doing things. Also to get the format you would have to store all potential formats for each bit depth and search through them.
Any alternatives??
Thx
Raj
Any alternatives??
Thx
Raj
I didn't think that would work as you need to fill in DXGI_SWAP_CHAIN_DESC to create the swap chain in the first place. But if i create a swapchain without filling DXGI_SWAP_CHAIN_DESC or its BufferDesc, D3D10CreateDeviceAndSwapChain will use the current display format??
Is that right?
Raj
Is that right?
Raj
i don't use D3D10CreateDeviceAndSwapChain() but
D3D10CreateDevice() and IDXGIFactory::CreateSwapChain()
which needs a DXGI_SWAP_CHAIN_DESC (cannot be null).
however, i tried D3D10CreateDeviceAndSwapChain() and it *only* works with a valid DXGI_SWAP_CHAIN_DESC here. does your code work without it?
if it works, how does the DXGI_SWAP_CHAIN_DESC look like? is it in current mode or in first enumed mode (smallest dimension), i am just interested..?
for an existing swap chain you can do like this to get the output and mode:
DXGI_SWAP_CHAIN_DESC scDesc;
DXGI_MODE_DESC closestModeDesc;
IDXGIOutput* output;
swapChain->GetDesc(&scDesc);
// we can further check which enumed mode matches best:
swapChain->GetContainingOutput(&output);
output->FindClosestMatchingMode(&scDesc.BufferDesc, &closestModeDesc, d3dDevice);
if you want to create the swap chain in a specific mode you can either enum the adapters->outputs->modes and use one of the modes as it is (or tweaked).
or you can use IDXGIOutput::FindClosestMatchingMode() instead.
but don't forget to check the enumed adapters for DX10 support:
bool canDX10 = SUCCEEDED(dxgiAdapter->CheckInterfaceSupport(__uuidof(ID3D10Device), NULL));
D3D10CreateDevice() and IDXGIFactory::CreateSwapChain()
which needs a DXGI_SWAP_CHAIN_DESC (cannot be null).
however, i tried D3D10CreateDeviceAndSwapChain() and it *only* works with a valid DXGI_SWAP_CHAIN_DESC here. does your code work without it?
if it works, how does the DXGI_SWAP_CHAIN_DESC look like? is it in current mode or in first enumed mode (smallest dimension), i am just interested..?
for an existing swap chain you can do like this to get the output and mode:
DXGI_SWAP_CHAIN_DESC scDesc;
DXGI_MODE_DESC closestModeDesc;
IDXGIOutput* output;
swapChain->GetDesc(&scDesc);
// we can further check which enumed mode matches best:
swapChain->GetContainingOutput(&output);
output->FindClosestMatchingMode(&scDesc.BufferDesc, &closestModeDesc, d3dDevice);
if you want to create the swap chain in a specific mode you can either enum the adapters->outputs->modes and use one of the modes as it is (or tweaked).
or you can use IDXGIOutput::FindClosestMatchingMode() instead.
but don't forget to check the enumed adapters for DX10 support:
bool canDX10 = SUCCEEDED(dxgiAdapter->CheckInterfaceSupport(__uuidof(ID3D10Device), NULL));
Quote:Original post by wavetable
however, i tried D3D10CreateDeviceAndSwapChain() and it *only* works with a valid DXGI_SWAP_CHAIN_DESC here. does your code work without it?
if it works, how does the DXGI_SWAP_CHAIN_DESC look like? is it in current mode or in first enumed mode (smallest dimension), i am just interested..?
Nah, thats what I thought your were suggesting. As I figured that creating a swapchain requires you to set the format. I was looking for way to get the format of the users current display mode.
Thx for trying anyway. any other suggestions? Or do i have to use brute force and guess work??
Raj
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement