按下 Alt-Enter 时会调用什么函数?
我有一个游戏应用程序,可以在按下 Alt-Enter 时进入全屏并返回窗口。但是,当它进入全屏时,我从 DirectX 收到以下警告:
DXGI 警告:IDXGISwapChain::Present:由于应用程序未正确使用 IDXGISwapChain::ResizeBuffers、指定 IDXGIOutput::GetDisplayModeList 中不可用的 DXGI_MODE_DESC,或未使用 DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH,导致全屏显示效率低下。
我已经排除了通过测试第二种可能性,所以我知道弹出警告的唯一原因是 IDXGISwapChain::ResizeBuffers 没有正确使用,或者 Windows 只是有 bug。由于我无法调试第二种可能性,因此我坚持解决 ResizeBuffers 问题。为了调试这个问题,我想看看当按下 Alt-Enter 从窗口到全屏时会发生什么。但是,该应用程序似乎没有调用我的 ResizeDXGIBuffers 方法;事实上,Alt-Enter 似乎嵌入到 Windows 或 DirectX 的某个地方,而且我不知道如何找到按下它时关闭的函数调用链。编辑:当我的方法放入 WM_ACTIVATEAPP 处理程序时,它会被调用,但这不是我的意思。如果我将其从该消息处理程序中取出,窗口仍然会进入全屏,即使我自己没有调用任何函数来使窗口全屏显示。因此 Alt+Enter 必须自动调用一些内部函数来执行此操作。
这就是我的问题:有谁知道按下 Alt-Enter 时 Windows 和/或 DirectX 11 会调用什么函数?
编辑:正如这个问题的标签所说,我在 Windows 计算机上使用 DirectX 11。具体来说,Windows 7 64 位。
编辑 2:我现在完全吃掉了 Alt+Enter 击键,并手动存储按下 Alt+Enter 的状态,以便我确定只有我的代码被调用。然而,我上面提到的警告仍然存在。我遵循 MSDN 最佳实践 也是如此,所以我不知道从这里去哪里。
I have a game app that has the ability to go fullscreen and back to windowed when Alt-Enter is pressed. However, when it goes fullscreen, I get the following warning from DirectX:
DXGI Warning: IDXGISwapChain::Present: Fullscreen presentation inefficiencies incurred due to application not using IDXGISwapChain::ResizeBuffers appropriately, specifying a DXGI_MODE_DESC not available in IDXGIOutput::GetDisplayModeList, or not using DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH.
I've already ruled out the second two possibilities through testing, so I know the only reasons left for the warning to pop up are either IDXGISwapChain::ResizeBuffers isn't being used right, or Windows is just bugged. Since I can't debug the 2nd possibility, I'm sticking with the ResizeBuffers problem. To debug this, I want to look at what happens when Alt-Enter is pressed going from windowed to fullscreen. However, the app does not seem to be calling my ResizeDXGIBuffers method; in fact, it seems that Alt-Enter is embedded into windows or DirectX somewhere, and I don't know how to find the chain of function calls that go off when it is pressed. EDIT: When my method is put in the WM_ACTIVATEAPP handler, it is called, but this is not what i meant. If i take it out of that message handler, the window STILL goes to fullscreen, even though I am not calling any functions to make the window fullscreen myself. So Alt+Enter must be automatically calling some internal function to do this.
So that is my question: Does anyone know what function is called by windows and/or DirectX 11 when Alt-Enter is pressed?
EDIT: As the tags for this question say, I am using DirectX 11 on a Windows machine. Specifically, Windows 7 64-bit.
EDIT 2: I now completely eat the Alt+Enter keystroke and manually store the state of Alt+Enter being pressed so that I know for certain only my code is being called. The warning I spoke of above persists, however. I am following the MSDN best practices as well, so I don't know where to go from here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试处理
WM_ACTIVATEAPP消息。
我不知道你使用哪个框架来创建你的窗口,所以我不知道如何具体处理这个消息。
Try handling the
WM_ACTIVATEAPP
message.I do not know which framework you use to create your windows, so I can't tell how to concretely handle this message.
查看 MSDN 最佳实践页面并重新编写代码以反映所描述的所有实践后,警告消失了。我希望这可以帮助其他有同样问题的人。
另外,感谢汉斯·帕桑特提供的链接。当你发布它时我已经修复了它,但无论如何还是谢谢你。
After looking at the MSDN best practices page and re-working my code to reflect all of the practices described, the warning has disappeared. I hope this helps anyone else that has the same problem.
Also, thanks to Hans Passant for the link. I already fixed it by the time you posted it, but thanks anyways.