Jump to content
  • Advertisement
Sign in to follow this  

DirectX7 CreateDevice error

This topic is 4832 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

Hi there. I've got a problem with the CreateDevice command in DirectX 7 under visula c++. It returns an error code(-2005532079) but i can't resolve this code to anything readable. Some parts from my code:
------- Create DirectDraw ------------------------------------------------------


    if (uiFlags & CUBE_DDRAW_D3DENABLE

  // Create DDraw object
  if ((hErr = DirectDrawCreateEx((GUID *)/*DDCREATE_HARDWAREONLY,*/ NULL,
      ) != DD_OK) KILLME("CCubeDDraw::CCubeDDraw | DirectDrawCreateEx");
  // Set cooperative lavel
  if ((hErr = this->DDraw->SetCooperativeLevel(this->hWnd,
											      			             DDSCL_EXCLUSIVE |
															                   DDSCL_FULLSCREEN |
      ) != DD_OK) KILLME("CCubeDDraw::CCubeDDraw | SetCooperativeLevel");
  // Set display mode
	if ((hErr = this->DDraw->SetDisplayMode(this->uiResX, this->uiResY,
      ) != DD_OK) KILLME("CCubeDDraw::CCubeDDraw | SetDisplayMode");
  // Create primary surface
	DDSURFACEDESC2 ddSurfaceDesc;
  ZeroMemory(&ddSurfaceDesc, sizeof(ddSurfaceDesc));
	ddSurfaceDesc.dwSize            = sizeof(ddSurfaceDesc);
	ddSurfaceDesc.dwFlags           = DDSD_CAPS;
	ddSurfaceDesc.ddsCaps.dwCaps    = DDSCAPS_PRIMARYSURFACE |

  if (uiFlags & CUBE_DDRAW_BACKBUFFER) {
    ddSurfaceDesc.dwFlags          |= DDSD_BACKBUFFERCOUNT;
    ddSurfaceDesc.ddsCaps.dwCaps   |= DDSCAPS_FLIP |
    ddSurfaceDesc.dwBackBufferCount = 1;

  if (uiFlags & CUBE_DDRAW_D3DENABLE)
    ddSurfaceDesc.ddsCaps.dwCaps   |= DDSCAPS_3DDEVICE;

	if ((hErr = this->DDraw->CreateSurface(&ddSurfaceDesc,
      ) != DD_OK) KILLME("CCubeDDraw::CCubeDDraw | CreateSurface (Primary)");
  // create back buffer surface
  if (uiFlags & CUBE_DDRAW_BACKBUFFER) {
	  ddSurfaceDesc.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;

    if (uiFlags & CUBE_DDRAW_D3DENABLE)
      ddSurfaceDesc.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;

	  if ((hErr = this->ddsPrimary->GetAttachedSurface(&ddSurfaceDesc.ddsCaps,
        ) != DD_OK) KILLME("CCubeDDraw::CCubeDDraw | GetAttachedSurface (BackBuffer)");

------- CreateDirect3D ---------------------------------------------------------
  ddsTarget = BackBufferSurface();


  if (EnumZBufferCallback == NULL)
    EnumZBufferCallback = DefaultEnumZBufferCallback;

  this->ddsTarget       = ddsTarget;
  this->CubeDDraw       = CubeDDraw;
  // Capture DDraw object
  IDirectDraw7	*DDraw = NULL;
  if ((DDraw = this->CubeDDraw->getDDraw()
    ) == NULL) KILLME("CCubeD3D::CCubeD3D | DDraw is NULL");

  // Create D3D object
  if ((hErr = DDraw->QueryInterface(IID_IDirect3D7,
                                    (void **)&this->D3D)
      ) != DD_OK) KILLME("CCubeD3D::CCubeD3D | QueryInterface");

  // Create ZBuffer
  if (uiFlags & CUBE_D3D_ZBUFFER) {
	  DDSURFACEDESC2 ddSurfaceDesc;
	  ZeroMemory(&ddSurfaceDesc, sizeof(ddSurfaceDesc));
	  ddSurfaceDesc.dwSize          = sizeof(ddSurfaceDesc);
	  ddSurfaceDesc.dwFlags         = DDSD_CAPS |
                                      DDSD_WIDTH |
                                      DDSD_HEIGHT |
	  ddSurfaceDesc.ddsCaps.dwCaps  = DDSCAPS_ZBUFFER |
	  ddSurfaceDesc.dwWidth         = this->CubeDDraw->getResX();
	  ddSurfaceDesc.dwHeight        = this->CubeDDraw->getResY();

    // Call PixelFormat - Enum
    if ((hErr = this->D3D->EnumZBufferFormats(IID_IDirect3DHALDevice,
      ) != DD_OK) KILLME("CCubeD3D::CCubeD3D | EnumZBufferFormats");

    // Create ZBuffer surface
	  if ((hErr = DDraw->CreateSurface(&ddSurfaceDesc,
        ) != DD_OK) KILLME("CCubeD3D::CCubeD3D | CreateSurface(ZBuffer)");

    // Attache it
	  if ((hErr = this->ddsTarget->AddAttachedSurface(this->ddsZBuffer)
        ) != DD_OK) KILLME("CCubeD3D::CCubeD3D | AddAttachedSurface(ZBuffer)");

  // Create D3DDevice
	if ((hErr = this->D3D->CreateDevice(IID_IDirect3DHALDevice, //IID_IDirect3DTnLHalDevice,
      ) != DD_OK) KILLME("CCubeD3D::CCubeD3D | CreateDevice");

After that: D3DDevice is NULL. I hope somebody can help me! edit: added [source] tags. -SiCrane

Share this post

Link to post
Share on other sites
Original post by LJSilver
It returns an error code(-2005532079) but i can't resolve this code to anything readable.

I'm at work now, so don't have the SDK to hand, but there's a DX Error Lookup in the utilities folder, stick that number in and see what it gives you.

If that doesn't work (not 100% sure that tool is in DX7SDK) you can check the C/C++ header files for the various DDERR_ or D3DERR_ type constants. It's a bit more hard work, but it can be done [smile]

Once you have the name of the error, look it up in the SDK - it should be one of the listed error codes / return values for the CreateDevice() function. If thats not helping, post the error name back here and we might be able to give you some clues.

As a wild guess... CreateDevice calls tend to fail for 2 common reasons - invalid parameters (the config you've specified is wrong) or unsupported features (you're requesting a feature your system/hardware doesn't have).


Share this post

Link to post
Share on other sites

There is no Error Lookup tool in the dx7sdk. and i can't find the error code in the h file (I've written a very long switch case function which looks up the error codes with all error codes from d3d.h but this one isn't in it.)

Original post from Microsoft DirectX 7 SDK
Return Values
If the method succeeds, the return value is D3D_OK.

If the method fails, the return value is an error. The method returns DDERR_INVALIDPARAMS if one of the arguments is invalid.

But DDERR_INVALIDPARAMS is not -2005532079!?!

And my hardeware supports a simple HAL-Device (P3 - 1GHZ - Radeon 7200).
And it works in other projects.

It would be nice to know ther readable version of the error code...

Share this post

Link to post
Share on other sites
I had to wait till I got home to check it out, but I can't find that error number in any references I have.

The DX9 error look-up says "unknown", my DX8-VB6 code says "unknown", google says "unknown", MSDN says "unknown".

Are you absolutely sure that -2005532079 is the correct value being reported via the HRESULT? It strikes me as odd that the value doesn't seem to be appearing anywhere [oh]


Share this post

Link to post
Share on other sites
The VisualC++ debug tels me that it is -2005532079.

There is something very strange in the source, because after i have installed the last updates from microsoft (some securety stuff) i cant create surfaces. I've fixed this problem (don't ask me how) after that i've got this problem.

But -2005532079 looks like a "right" error code.

Share this post

Link to post
Share on other sites
Ok, i've got it *g*.

CreateDevice crashs becaus the ZBuffer-BitDepth was set to 16. i've set it to 32 and it would work.

Thanx alot

P.S.: But i can't find out what Err -2005532079 means...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!