我的 OpenGL 游戏关闭了 Aero DWM Glass

发布于 2024-08-29 10:39:07 字数 1509 浏览 13 评论 0原文

几年前我写了一个免费游戏:http://www.walkover.org。对于大厅和菜单,它使用像 win32 这样的普通对话框。当实际游戏开始时,它使用 OpenGL。

现在,在 Windows 7 上,当实际游戏开始时,它会关闭 Windows Aero Glass,并在游戏结束时重新打开。

我可以做些什么来防止这种情况发生吗?如果玻璃打开的话,有一些特殊的标志可以让玻璃保持打开状态吗? (对于较新的人,我一直在使用 DirectX,但这种情况不会发生。)也许我必须在某处指定一些(新)标志?

我正在使用这个像素格式描述符:

    static PIXELFORMATDESCRIPTOR pfd =
    {
        sizeof(PIXELFORMATDESCRIPTOR),  // size of this pfd
        1,                              // version number
        PFD_DRAW_TO_WINDOW |            // support window
          PFD_SUPPORT_OPENGL |          // support OpenGL
          PFD_DOUBLEBUFFER,             // double buffered
        PFD_TYPE_RGBA,                  // RGBA type
        32,                             // 24-bit color depth
        0, 0, 0, 0, 0, 0,               // color bits ignored
        0,                              // no alpha buffer
        0,                              // shift bit ignored
        0,                              // no accumulation buffer
        0, 0, 0, 0,                     // accum bits ignored
        0,                              // 32-bit z-buffer
        0,                              // no stencil buffer
        0,                              // no auxiliary buffer
        PFD_MAIN_PLANE,                 // main layer
        0,                              // reserved
        0, 0, 0                         // layer masks ignored
    };

I wrote a free game a few years ago: http://www.walkover.org. For the lobby and menus, it uses normal dialogs like win32. When the actual game starts it uses OpenGL.

Now, on Windows 7, when the actual game starts, it switches windows aero glass off and switches it back on when the game is over.

Is there something I can do to prevent this from happening? Some special flags that keep the glass on if it is on? (For newer, I have been using DirectX and this doesn#t happen there.) Maybe some (new) flag I have to specify somewhere?

I'm using this pixelformatdescriptor:

    static PIXELFORMATDESCRIPTOR pfd =
    {
        sizeof(PIXELFORMATDESCRIPTOR),  // size of this pfd
        1,                              // version number
        PFD_DRAW_TO_WINDOW |            // support window
          PFD_SUPPORT_OPENGL |          // support OpenGL
          PFD_DOUBLEBUFFER,             // double buffered
        PFD_TYPE_RGBA,                  // RGBA type
        32,                             // 24-bit color depth
        0, 0, 0, 0, 0, 0,               // color bits ignored
        0,                              // no alpha buffer
        0,                              // shift bit ignored
        0,                              // no accumulation buffer
        0, 0, 0, 0,                     // accum bits ignored
        0,                              // 32-bit z-buffer
        0,                              // no stencil buffer
        0,                              // no auxiliary buffer
        PFD_MAIN_PLANE,                 // main layer
        0,                              // reserved
        0, 0, 0                         // layer masks ignored
    };

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

软糯酥胸 2024-09-05 10:39:07

此问题是由以下所有原因引起的:

  • Windows 7
  • OpenGL
  • 创建一个与您的屏幕矩形完全匹配的窗口(全屏)
  • ​​第二次调用交换缓冲区
  • 旧显卡驱动程序

我有同样的问题,我测试了 2 个使用 AAA 游戏引擎OpenGL 并可以确认他们都有同样的问题。 DirectX 似乎不受影响。

这意味着您的窗口创建没问题,不是代码问题。

我建议更新您的显卡驱动程序来解决该问题。

我发现的一个短期解决方法是创建一个比屏幕分辨率(宽度或高度)大 1 像素的窗口,

这会欺骗窗口检测到您已进入全屏状态,并且不会触发问题。

This problem is caused by all of the following:

  • Windows 7
  • OpenGL
  • Creating a window that matches your screen rect exactly (Fullscreen)
  • Calling Swap Buffers for the second time
  • Old graphics card drivers

I have the same problem and I tested 2 AAA game engines that use OpenGL and can confirm they both had the same problem. DirectX seems unaffected.

This means your window create is fine, it is not a code problem.

I would recommend updating your graphics card drivers to solve the problem.

A short term work around I found was to create a window that is 1 pixel larger than your screen resolution (on either width or height)

This tricks windows into not detecting that you have gone into fullscreen and doesn't trigger the problem.

黯然#的苍凉 2024-09-05 10:39:07

我认为如果您创建与 Aero Glass 不兼容的 OpenGL 渲染上下文,就会发生这种情况。 IIRC 可能导致此问题的情况之一是您使用 16 位颜色创建窗口。 Aero Glass 无法以 16 位颜色渲染,因此出于某些技术原因,Windows 必须完全禁用 Aero Glass(即使只有您的应用程序在使用它)。尝试使用 32 位颜色。

可能还有其他设置会出于类似原因禁用它。简而言之,仔细检查您用于创建 OpenGL 的所有设置,并思考“如果桌面切换到此模式,Aero Glass 会关闭吗?”。

I think this can happen if you create an OpenGL rendering context that is incompatible with Aero Glass. IIRC one of the cases that can cause this is if you create a window using 16-bit colour. Aero Glass can't render in 16-bit colour, so for some technical reason, Windows has to completely disable Aero Glass (even though only your app is using it). Try using 32-bit colour.

There might be other settings that disable it for similar reasons. In short, double check all the settings you're creating OpenGL with, and think "would Aero Glass switch off if the desktop was switched to this mode?".

最舍不得你 2024-09-05 10:39:07

不确定你到底做了什么导致了这个问题,但也可能是这样——微软在 Windows 7 中的 OpenGL 实现并不完全完美,说得好点。事实上,在我的大部分 OpenGL 代码中,我已经明确关闭了 DWM。否则,微软实施中的错误基本上会阻止它工作。虽然我可以通过其他方式在某种程度上解决这个问题,但性能太差,以至于代码基本上无法使用(我还没有进行认真的测量,但我立即猜测我会说至少 5:1 的性能损失)。

Not sure exactly what you're doing that's causing this, but it's probably just as well -- Microsoft's OpenGL implementation in Windows 7 is not exactly perfect, to put it nicely. In fact, in most of my OpenGL code, I've taken to explicitly turning off the DWM. Otherwise, bugs in Microsoft's implementation basically stop it from working at all. Though I can work around that some extent in other ways, the performance is so poor it renders the code essentially unusable anyway (I haven't done serious measurements, but at an immediate guess I'd say at least 5:1 performance loss).

孤寂小茶 2024-09-05 10:39:07

我曾经在我的应用程序中遇到一个问题,当尝试从窗口 DC 执行 BitBlt 时,GDI 无法读取 OpenGL 渲染的窗口内容。那是Vista刚出来的时候。使用 PFD_SUPPORT_GDI 可以解决这个问题,但它也会禁用 Aero。我猜这个问题导致很多旧应用程序崩溃,所以他们在某些情况下强制它打开。不确定你这里是什么情况。我敢打赌是驱动程序存根问题。

只是我自己对 OpenGL、Aero 和 GDI 的有限经验。

I once encountered a problem in my application that GDI couldn't read OpenGL-rendered window contents when trying to do BitBlt from the window DC. This was back then when Vista just came out. Using PFD_SUPPORT_GDI would work around this, but it would also disable Aero. I guess this issue made a lot of old apps broken, so they forced it to be on in some cases. Not sure what's your case here. I would bet on a driver stub issue.

Just my own limited experience with OpenGL, Aero and GDI.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文