1
\$\begingroup\$

When my game window is hidden say by minimising it or hitting Ctrl, Alt, Del. I get the DXGI error:

0x087A0001 : The Present operation was invisible to the user.

I've tried wrapping the present function inside an if statement to check whether the window is visible, this comes from: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-iswindowvisible

And looks like this in my code:

bool Graphics::WindowVisible() const
{
    if (IsWindowVisible(hWnd) == TRUE)
    {
        return true;
    }
    return false;
}

I've created the function in my window object too, and applied it to my EndFrame() call but this doesn't work either.

The function never seems to return false. Any ideas on the best way forward would be gratefully received. If using a check for visibility isn't on the cards, Is there a way to simply disregard the DXGI error and simply throw the frame away and would that be a good idea.

\$\endgroup\$
2
  • \$\begingroup\$ During my testing, Ctrl+Alt+Del invokes a loss of focus event, and minimizing/restoring invokes a window resize event with the subevent of restoring (i.e., not minimizing and not maximizing). Are you handling these events? Mine fails because I'm not properly restoring lost resources. \$\endgroup\$ – Casey Dec 2 '20 at 23:19
  • \$\begingroup\$ Might not be the right call, I checked the documentation (docs.microsoft.com/en-us/windows/win32/api/winuser/…) and it states -> Because the return value specifies whether the window has the WS_VISIBLE style, it may be nonzero even if the window is totally obscured by other windows. I also note, this might not tell you if the window is minimised also. Maybe check if it does. in c#, I check the windowstate for Minimised, there maybe a corresponding GDI check. \$\endgroup\$ – ErnieDingo Dec 2 '20 at 23:53
1
\$\begingroup\$

Well, after some checking and some help from some more tenured practitioners, I have learned that this 'error' is actually a status.

I was doing some pretty wrong (so wrong) hresult checking which was throwing this result as an error. However the recommended error check for present:

if (FAILED(hr = pSwapChain->Present(1u, 0)))

just passes this by and doesn't throw a hissy fit which is what we probably all want.

Thanks to those who commented!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.