MSDN on IDirect3D9Ex::CreateDeviceEx
says:
If
BackBufferFormat
equals D3DFMT_UNKNOWN before the method is called, it will be changed when the method returns.
So this should print something other than format: 0
(nowadays usually format: 22
for D3DFMT_X8R8G8B8
):
#include <cstdio>
#include <d3d9.h>
#pragma comment(lib,"d3d9.lib")
#pragma comment(lib,"User32.lib")
int main(int argc, char **argv)
{
IDirect3D9* d3d = Direct3DCreate9(D3D_SDK_VERSION);
if (!d3d) {
printf("No d3d!\n");
return 0;
}
D3DPRESENT_PARAMETERS pp = {};
pp.BackBufferWidth = 1;
pp.BackBufferHeight = 1;
pp.BackBufferFormat = D3DFMT_UNKNOWN;
pp.BackBufferCount = 1;
pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
pp.Windowed = TRUE;
IDirect3DDevice9* device = NULL;
HRESULT hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetDesktopWindow(), D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, &device);
if (FAILED(hr)) {
printf("Failed!\n");
return 0;
}
printf("format: %i\n", pp.BackBufferFormat);
device->Release();
d3d->Release();
}
And this always worked in my experience. Now recently sometimes this does not work as expected anymore. It prints format: 0
. Why?
This was observed on some Windows 10 PCs for a few days recently. Later it magically started working again. Is this possibly related to the Windows 10 Anniversary update?