Create Device Problem in MFC application
Hi!
I am developing a MFC based DirectX application. In the initialization, the
code cannot create device.
I do not know what the problem is. I am enclosing the part of the code
below. Any help is highly
appreciated.
Regards.
[SDI MFC CLASS CChildView MEMBER METHOD START]
HRESULT CChildView::InitializeDirectX()
{
HWND hWnd = GetSafeHwnd();
if(NULL == (_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
{
return E_FAIL;
}
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
if(FAILED(_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &_pDXDevice)))
{
return E_FAIL;
}
return S_OK;
}
[SDI MFC CLASS CChildView MEMBER METHOD END]
Debug tells that DirectX object is created. However, the code fails at the
CreateDevice statement.
[DEBUG ERROR MESSAGE START]
Direct3D9: (INFO) :HalDevice Driver Style 9
Direct3D9: (ERROR) :Failed to create driver surface
Unhandled exception at 0x7c901230 in Visualizer.exe: User breakpoint.
The program '[1316] Visualizer.exe: Native' has exited with code -2147483645
(0x80000003).
Disassembly Code : 7C901230 int 3
[DEBUG ERROR MESSAGE END]
System Information : DELL Dimension 4600, Intel Pentium 4, 512 MB RAM, XP
Professional, 128MB DDR ATI Radeon 9800 Pro.
Thank you very much for your attention.
date: Thu, 11 May 2006 15:16:03 -0700
author: Millennium Falcon