admin管理员组

文章数量:1304152

I have an application that uses DirectX 9. However, when I resize the window from the edge with the mouse, I cannot successfully reset the device. I am getting a D3DERR_INVALIDCALL error. I am comparing the parameters that were first created when the application was opened with the parameters after the window is resized, and everything looks the same (LogD3DPresentParameters(d3dpp)).

What could I be missing?

void OnSizeChange(int width, int height){
    if (!createdDevice)
        return;

    HRESULT hr;

    RECT rcWnd;
    GetClientRect(&rcWnd);
    UINT uWidth = rcWnd.right - rcWnd.left;
    UINT uHeight = rcWnd.bottom - rcWnd.top;

    IDirect3DDevice9& rkD3DDev = *STATEMANAGER.GetDevice();
    HWND currentHWND = m_grpDevice.GetDeviceParameter().hDeviceWindow;

    d3dpp.BackBufferWidth = uWidth;
    d3dpp.BackBufferHeight = uHeight;
    hr = STATEMANAGER.GetDevice()->TestCooperativeLevel();
    if (FAILED(hr))
    {

        if (hr == D3DERR_DEVICELOST)
            return;

        if (hr == D3DERR_DEVICENOTRESET)
        {
            m_grpDevice.DestroyPDTVertexBufferListtt();

            if (FAILED(hr = rkD3DDev.Reset(&d3dpp)))
            {
                LogD3DPresentParameters(d3dpp);

                char szError[512];
                snprintf(szError, sizeof(szError),
                    "Cihaz sıfırlama hatası! HRESULT: 0x%08X\nHata: %s\nAçıklama: %s",
                    hr,
                    DXGetErrorString(hr),
                    DXGetErrorDescription(hr));

                MessageBox(NULL, szError, "Hata", MB_OK | MB_ICONERROR);
                return;
            }

            STATEMANAGER.SetDefaultState();
            if (!m_grpDevice.CreatePDTVertexBufferListtt())
                TraceError("m_grpDevice.CreatePDTVertexBufferListtt() - ERROR!");
        }
    }
}

本文标签: cHow can I reset the device after resizing the window with DirectX 9Stack Overflow