diff --git a/MUNGA_L4/L4VIDEO.cpp b/MUNGA_L4/L4VIDEO.cpp index 94aed2e..03aee1a 100644 --- a/MUNGA_L4/L4VIDEO.cpp +++ b/MUNGA_L4/L4VIDEO.cpp @@ -1746,6 +1746,15 @@ DPLRenderer::DPLRenderer( //} //DEBUG_STREAM<<"**************************"<CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &mPresentParams, &mDevice)); - if (FAILED(hr)) - { - PostQuitMessage(1); - } + } + + // + // PostQuitMessage is a message, not a return. The fallback used to + // post one and then carry straight on into the Clear below, which + // dereferenced a device that was never created - so a machine that + // could not give us the mode we asked for died on an access + // violation instead of saying so. + // + // What was asked for goes in the line, because that is the question + // this failure raises: the back buffer is the requested size now, + // windowed as well as full-screen, so a request the adapter will not + // meet is the thing to look at first. + // + if (FAILED(hr) || mDevice == NULL) + { + DEBUG_STREAM << "DPLRenderer: no D3D device for a " + << mPresentParams.BackBufferWidth << "x" + << mPresentParams.BackBufferHeight + << (mPresentParams.Windowed ? " windowed" : " full-screen") + << " back buffer (hr=0x" << std::hex << hr << std::dec + << ") - giving up\n" << std::flush; + PostQuitMessage(1); + return; } mDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0xFF000000, 0.0f, 0);