DirectX应用程序中Alt-Tab支持的最佳做法? [英] Best practices for Alt-Tab support in a DirectX app?

查看:83
本文介绍了DirectX应用程序中Alt-Tab支持的最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写DirectX应用程序时,显然希望支持用户通过 Alt - Tab 快速且无错误的方式暂停应用程序。确保这一点的最佳做法是什么?需要解决的问题包括:


  1. 检测应用程序何时被交替制表和何时被制表的最佳方法返回。

  2. 当用户Alt-tab时丢失了哪些DirectX资源,以及解决此问题的最佳方法。

  3. 主要要做的事情

  4. DirectX主要版本之间的任何显着差异,都适用于上述应用。

  5. ol>

    有趣的技巧和陷阱也很好听。

    解决方案

    I会假定您正在使用C ++来回答我的问题,但是,如果您有能力使用C#,则XNA( http:// creators.xna.com/ )是一个出色的游戏平台,可以为您处理所有这些问题。



    1]



    本文对于处理procproc中的Windows事件很有帮助要检测窗口何时失去焦点或获得焦点,您可以在主窗口上进行处理: http:/ /www.functionx.com/win32/Lesson05.htm 。另外,在此处查看WM_ACTIVATEAPP消息: http:// msdn .microsoft.com / en-us / library / ms632614(VS.85).aspx



    2]





    3]



    我将确保永远不要禁用Alt-Tab 。您可能希望在应用程序不处于活动状态时将CPU负载降到最低,因为用户可能想通过Alt-Tabbed来执行其他操作,因此您可以完全暂停应用程序或减少每秒渲染的帧数。如果应用程序最小化,那么您当然也不需要渲染任何东西。在考虑了网络游戏之后,我最好的解决方案是您仍然应该减少每秒渲染的帧以及处理的网络数据包的数量,甚至可能丢弃许多传入的数据包,直到重新激活游戏。



    4]



    老实说,我只是坚持使用DirectX 9.0c(如果您想限制DirectX 10,您的目标操作系统为Vista及更高版本)(如果可能的话:)



    最后,DirectX sdk提供了许多教程和示例: http://www.microsoft.com/downloads/details.aspx? FamilyID = 24a541d6-0486-4453-8641-1eee9e21b282& displaylang = zh-CN


    When writing DirectX applications, obviously it's desirable to support the user suspending the application via Alt-Tab in a way that's fast and error-free. What is the best set of practices for ensuring this? Things that need to be addressed include:

    1. The best methods of detecting when your application has been alt-tabbed out of and when it has been returned to.
    2. What DirectX resources are lost when the user alt-tabs, and the best ways to cope with this.
    3. Major things to do and things to avoid in application architecture for purposes of alt-tab support.
    4. Any significant differences between major DirectX versions as they apply to the above.

    Interesting tricks and gotchas are also good to hear about.

    解决方案

    I will assume you are using C++ for the purposes of my answers, but if you can afford to use C#, XNA (http://creators.xna.com/) is an excellent game platform that handles all of these issues for you.

    1]

    This article is helpful for windows events in the window procedure to detect when a window loses or gains focus, you could handle this on your main window: http://www.functionx.com/win32/Lesson05.htm. Also, check out the WM_ACTIVATEAPP message here: http://msdn.microsoft.com/en-us/library/ms632614(VS.85).aspx

    2]

    3]

    I would make sure to never disable Alt-Tab. You probably want minimal CPU load while the application is not active because the user probably Alt-Tabbed because they want to do something else, so you could completely pause the application, or reduce the frames rendered per second. If the application is minimzed, you of course don't need to render anything either. After thinking about a network game, my best solution is that you should still reduce the frames rendered per second as well as the amount of network packets handled, possibly even throwing away many of the packets that come in until the game is re-activated.

    4]

    Honestly I would just stick to DirectX 9.0c (or DirectX 10 if you want to limit your target operating system to Vista and newer) if at all possible :)

    Finally, the DirectX sdk has numerous tutorials and samples: http://www.microsoft.com/downloads/details.aspx?FamilyID=24a541d6-0486-4453-8641-1eee9e21b282&displaylang=en

    这篇关于DirectX应用程序中Alt-Tab支持的最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆