I wrote these code in my program:
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
LPDIRECT3D9 D3D = NULL;
D3D = Direct3DCreate9( D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp,sizeof(d3dpp));
d3dpp.Windowed = true;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = 640;
d3dpp.BackBufferHeight = 480;
d3dpp.hDeviceWindow = hwnd;
long result = D3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,&g_pd3dDevice);
But everytime i got result : D3DERR_INVALIDCALL~~
Could anybody help me ?
thx
CreateDevice Error~Help
Started by Frente, Sep 04 2005 11:10 AM
3 replies to this topic
#1
Posted 04 September 2005 - 11:10 AM
#2
Posted 04 September 2005 - 05:41 PM
Are you checking that "D3D" is not NULL after you call Direct3DCreate9(D3D_SDK_VERSION)?
The values you are specifying for you d3dpp object seem fine to me.
[edit]
Your program would most probably crash if D3D was NULL, so forget that.
Could you turn on the debug runtime for d3d (from the control panel), the debug your applciation. Then look in the output pane and see what Direct3D complains about.
[/edit]
The values you are specifying for you d3dpp object seem fine to me.
[edit]
Your program would most probably crash if D3D was NULL, so forget that.
Could you turn on the debug runtime for d3d (from the control panel), the debug your applciation. Then look in the output pane and see what Direct3D complains about.
[/edit]
- TripleBuffer
- Me blog
- Me blog
#3
Posted 04 September 2005 - 07:05 PM
You have to specify what you want for the depth buffer. Either set d3dpp.AutoDepthBuffer to FALSE and it won't create a depth buffer for you, or set it to TRUE and also specify a valid format for d3dpp.AutoDepthStencilFormat.
Actually that can't be the problem because you zero the D3DPRESENT_PARAMETERS structure, but still, its good practice to set all fields...
Actually that can't be the problem because you zero the D3DPRESENT_PARAMETERS structure, but still, its good practice to set all fields...
#4
Posted 04 September 2005 - 07:14 PM
I tested your code, and it works fine, except when hwnd is an invalid window handle. :excl: Could you check that it's not zero or any other invalid value? How do you retrieve it?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











