Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

carb

CreateDevice Fails - Why?

This topic is 5608 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m getting IDirect3D9::CreateDevice to fail ... It''s returning D3DERR_INVALIDCALL, but I can''t figure out why. I''ve even reduced my code to the following simple little thing, but the same problem still occurs. // begin code // error checking if (hWnd = NULL) return false; // initialize Direct3D if((m_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) return false; ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; // create the Direct3D object if (m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &m_pD3DDevice) == D3DERR_INVALIDCALL) { printf("Fail\n"); return false; } // end code I''m wondering if not including some library or header file could screw this up - I mean, this is right out of the SDK docs. Any help would be very much appreciated. - Ben

Share this post


Link to post
Share on other sites
Advertisement
I''m an idiot. Really.

if (hWnd = NULL) return false;

Fabulous piece of code there.

- Ben

Share this post


Link to post
Share on other sites
Erp, I fixed that, but something''s still wrong. I mean, now it returns D3DERR_NOTAVAILABLE instead. I''m more than sure my computer supports software vertex processing and software lighting.

Any help, please?

- Ben

Share this post


Link to post
Share on other sites
Hi - I''m not sure if you can set d3dpp.backbufferformat to D3DFMT_UNKNOWN.

Try the following (in VB/DX8.1, but I''m sure you can convert it):

'' Get The current Display Mode format
Dim mode As D3DDISPLAYMODE
d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, mode
D3DPP.BackBufferFormat = mode.Format

hope this helps-

BM

Share this post


Link to post
Share on other sites
According to the docs, D3DFMT_UNKNOWN defaults to the current display settings ... those lines were taken right from a tutotial.

- Ben

Share this post


Link to post
Share on other sites
first off, you were entirely correct to return false if HWND==NULL;

Also, you should tell DX what the presentation INterval is::


here is a general code for setting the PresentParameters in windowed mode, before you attempt to create a device:

ZeroMemory(&Parms,sizeof(D3DPRESENT_PARAMETERS));
Parms.Windowed=true;
Parms.BackBufferWidth=Display.Width;
Parms.BackBufferHeight=Display.Height;
Parms.SwapEffect=D3DSWAPEFFECT_DISCARD;
Parms.PresentationInterval=D3DPRESENT_INTERVAL_IMMEDIATE;
Parms.BackBufferFormat=Display.Format;
Parms.EnableAutoDepthStencil=true;
Parms.AutoDepthStencilFormat=D3DFMT_D24S8;

Share this post


Link to post
Share on other sites
quote:
Original post by RhoneRanger
first off, you were entirely correct to return false if HWND==NULL;



Heheheh. You didn''t read that carfully.
He did: hwnd = NULL, not hwnd == NULL.

Thats why you should do: NULL == hwnd. So if you forget the other = it will cause a compile error rather than creating a difficult to track bug.



Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!