IDirect3DDevice8::CreateDevice problems

Started by
8 comments, last by CloudNine 20 years, 11 months ago
Hi, Just started with DirectX, and have been using Drunken Hyena''s tutorials. However, I''ve run into a fundemental problem, a problem creating the DX device. I''m using Dev C++ 4 with a ATi XPERT 99/00 (yup, I need to upgrade soon ) Here''s the initation of D3D:
  
iD3D=Direct3DCreate8(D3D_SDK_VERSION);

 if (!iD3D) FatalError("Fatal error getting D3D instance");

 hr=iD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&displaymode);

 if (FAILED(hr)) FatalError("Fatal error getting display mode");

 ZeroMemory(&d3dpp,sizeof(&d3dpp));

 d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD;
 d3dpp.hDeviceWindow=hWnd;
 d3dpp.Windowed=true;
 d3dpp.BackBufferFormat=displaymode.Format;
 d3dpp.AutoDepthStencilFormat = D3DFMT_D16;


 hr=iD3D->CreateDevice(D3DADAPTER_DEFAULT,
                       D3DDEVTYPE_REF,
                       hWnd,
                       D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                       &d3dpp,
                       &iDD);

 if (FAILED(hr))
 {
 FatalError("Error creating device");
 return hr;
 }
  
CreateDevice always fails, and I have tried a number of parameters. Any ideas?
Advertisement
You aren't setting backbuffer width and height.
Also why don't you switch to HAL?

Also to use ZBuffering as you state in your D3DPRESENT_PARAMETERS instance, you must set the EnableAutoDepthStencil to TRUE too. The format isn't enough.

[edited by - aker_jus on May 3, 2003 3:48:38 PM]
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
Do I still need to set the backbuffer width and height, even in windowed mode?
Yes.
Nah, I don't think you need to set backbufferheight & width for windowed mode...

At least I didn't need that, but you will need to set the BackBuffer.Format to the Format the current displaysettings use.
(which is what you did...)


[edited by - bilsa on May 3, 2003 7:01:59 PM]
I''ll see how setting the back buffer height and width goes.
Nope, no luck. Is it a problem with my graphics card or something?
Would creating it in fullscreen be any better?
Okay I dont think this is the problem but if you are using a ZBuffer then you need:

d3dpp.EnableAutoDepthStencil = TRUE;

i think.

Other than that it looks good, try stepping through the debugger to that line and check the values, im guessing hWnd is NULL.

Hope this helps
Cya.
Ash
Yup. Solved it now :D

This topic is closed to new replies.

Advertisement