Resetting the D3D Device Causing Crashes and Frustration!

Started by
12 comments, last by BrianMJC 20 years ago
psykr -- Thanks.
Advertisement
Say, I'm not out it yet!

My DrawPrimitiveUP calls fail, returning D3DERR_INVALIDCALL. Only happens after resetting.

The Reset method succeeds, I successfully delete and set to NULL all textures, and recreate them without errors after resetting, and set the render states correctly. The SetTexture, SetTransform and SetMaterial calls prior to DrawPrimitiveUP work fine (return D3D_OK). My custom vertex array (the memory address parameter 'aVertex' to DrawPrimitiveUP, below) is valid and setup correctly, I verified this.

Here's my method code to display quad textures (triangle strips of 2 triangles / 4 vertices), which are my font character textures:

// D I S P L A Y ///////////////////////////////////////////////////////////////// Display texture onscreen.//// return value - success or failure// fptDst - destination origin (up-left) point to render to screen, in pixels// td - texture descriptor//inline estate ctexture::Display (fpoint &fptDst, stexdesc &td)    {    // Set texture to render.    hr = g_pd3dDev->SetTexture (0, pd3dTexture);    if (FAILED (hr))        {        sReport = "ctexture::Display -- Failed to set texture: ";        sReport += D3DError (hr);        Log (sReport);        return g_ceSError;        }    // Set world transformation matrix.    D3DXMatrixIdentity (&g_d3dxMatrix);    g_d3dxMatrix._11 = 1.0 / g_cfVideoWidthD2;    g_d3dxMatrix._41 = fptDst.x * g_d3dxMatrix._11;    g_d3dxMatrix._22 = -1.0 / g_cfVideoHeightD2;    g_d3dxMatrix._42 = fptDst.y * g_d3dxMatrix._22;    hr = g_pd3dDev->SetTransform (D3DTS_WORLD, &g_d3dxMatrix);    if (FAILED (hr))        {        sReport = "ctexture::Display -- Failed to set world transform matrix: ";        sReport += D3DError (hr);        Log (sReport);        return g_ceSError;        }    // Setup material to reflect desired color.    ZeroMem (d3dMaterial);    d3dMaterial.Ambient.r = td.fc.r;    d3dMaterial.Ambient.g = td.fc.g;    d3dMaterial.Ambient.b = td.fc.b;    d3dMaterial.Ambient.a = td.fc.a;    hr = g_pd3dDev->SetMaterial (&d3dMaterial);    if (FAILED (hr))        {        sReport = "ctexture::Display -- Failed to setup material: ";        sReport += D3DError (hr);        Log (sReport);        return g_ceSError;        }        // Draw texture.    hr = g_pd3dDev->DrawPrimitiveUP (D3DPT_TRIANGLESTRIP, 2, aVertex, sizeof (cvertex));    if (FAILED (hr))        {        sReport = "ctexture::Display -- Failed to draw texture: ";        sReport += D3DError (hr);        Log (sReport);        return g_ceSError;        }    return g_eState;    }


Also...

DrunkenHyena -- I reinstalled the debug runtime version of DX, but how is it utilized? Automatically, or do I have to launch something or set some settings in MSVC? These MS help files are kinda skimpy to say the least!

Also, also...

P.S. Does anyone know how to use the debugger when your app goes to fullscreen mode? It would be helpful if I could trace my game as it runs in fullscreen without having to resort to writing variable values to a log file.

[edited by - BrianMJC on April 6, 2004 9:29:57 PM]
I just recovered from a similar problem after losing the device. Bottom line, RELEASE everything after a device lost, and re-init everything to get it back.
2dcoder -- Yep, I''m going to have to do exactly that. I''m already way behind schedule, not to mention well beyond my tolerance limits for staring uselessly at my monitor for days on end! Thanks.

This topic is closed to new replies.

Advertisement