Hi,
I seem to be having a problem when I try to create a Directx9 device for fullscreen. It works fine in windowed mode. Here is how I am setting up the D3DPRESENT_PARAMETERS structure:
D3DPRESENT_PARAMETERS d3dpp;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferHeight = 640;
d3dpp.BackBufferWidth = 480;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.Flags = 0;
d3dpp.hDeviceWindow = hwnd;
d3dpp.MultiSampleQuality = 0;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.PresentationInterval = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
#if defined (FULLSCREEN)
d3dpp.Windowed = FALSE;
d3dpp.FullScreen_RefreshRateInHz = 60;
#else
d3dpp.Windowed = TRUE;
d3dpp.FullScreen_RefreshRateInHz = 0;
#endif
Creating the device:
HRESULT hr = g_d3d9->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_d3d9Device);
The Output from Debug:
Quote:
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Direct3D9: (INFO) :======================= Hal SWVP device selected
Direct3D9: (INFO) :HalDevice Driver style 9
Direct3D9: :Subclassing window 000e066e
Direct3D9: :StartExclusiveMode
Direct3D9: (ERROR) :The specified mode is unsupported. CreateDevice/Reset Fails
Direct3D9: (ERROR) :Unable to set the new mode. CreateDevice/Reset Fails
Direct3D9: (ERROR) :Failed to initialize primary swapchain
Direct3D9: (ERROR) :Failed to initialize Framework Device. CreateDevice Failed.
Direct3D9: :DoneExclusiveMode
Direct3D9: :INACTIVE: 00000a70: Restoring original mode (1440x900x22x60) at adapter index 0
Direct3D9: :Unsubclassing window 000e066e
D3D9 Helper: IDirect3D9::CreateDevice failed: D3DERR_INVALIDCALL
First-chance exception at 0x00411279 in small.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00411279 in small.exe: 0xC0000005: Access violation reading location 0x00000000.
The program '[2672] small.exe: Native' has exited with code 0 (0x0).
I am new to DirectX, so I am not sure how to interpret some of this. I googled around for a few hours yesterday and today, and know that this is a common problem when an incorrect value is specified as part of the D3DPRESENT_PARAMETERS structure.
I checked the settings I am using with the DXCapsViewer utility, and they all appear to be valid modes. I also tried setting the Device Type to D3DDEVTYPE_REF, but that didn't help either.
I have also read, that when using Fullscreen, that the HWND being past in must be a top level window, so I have also specified that.
Actually, here's the Window creation code:
HWND hwnd = CreateWindowEx (WS_EX_OVERLAPPEDWINDOW | WS_EX_TOPMOST, "STATIC", "Small",
WS_POPUP | WS_VISIBLE,
0, 0,
640, 480,
0, 0, hInstance, 0);
This whole thing is a very bare bones application, as I am working on producing a sub 4kb executable. So I am also not linking to any common libs other than kernel32.lib and user32.lib, as well as d3d9.lib, just in case that has something to do with it.
Thanks,
caseyd