在 Direct3D 9 中进入窗口模式

发布于 2024-12-10 14:01:03 字数 545 浏览 3 评论 0原文

我正在制作一个 Direct3D 应用程序,我可以使用带有新演示参数的 IDirect3DDevice9::Reset 轻松从窗口模式转到全屏模式。但是,当我使用相同的技巧从全屏模式转到窗口模式时,窗口现在失去了边框。

如果我尝试执行 SetWindowLong 将窗口样式设置为 WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU(然后使用 SWP_FRAMECHANGED SetWindowPos),窗口现在获得其边框,但 direct3d 设备不再工作。再次重置设备不起作用,而不是 Reset(), 执行 Release() 然后 SetWindowLong() 然后 CreateDevice () 再次,当然会失败,因为我的托管资源依赖于我的设备。

在创建带边框的窗口时,如何使 IDirect3DDevice9::Reset 返回窗口模式?

I'm making a Direct3D app, and I can easily go from Windowed to Fullscreen mode using IDirect3DDevice9::Reset with new presentation parameters. However, when I use the same trick to go from fullscreen to windowed mode, the window has now lost its borders.

If I try doing SetWindowLong to set the window style to WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU (and then SetWindowPos with SWP_FRAMECHANGED), the window now gets its border, but the direct3d device no longer works. Resetting the device again doesn't work, and instead of Reset(), doing Release() then SetWindowLong() then CreateDevice() again, of course fails, as my managed resources are dependent on my device.

How do I make IDirect3DDevice9::Reset to go back to windowed mode, while creating a bordered window?

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

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

发布评论

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

评论(1

清泪尽 2024-12-17 14:01:03

首先,您需要更改窗口的属性:

SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);

if (new_pos_size)
{
    // if you want new position (pos_x, pos_y) and size (width, height)
    UINT flags = SWP_FRAMECHANGED | SWP_SHOWWINDOW;
    SetWindowPos(hWnd, HWND_NOTOPMOST, pos_x, pos_y, width, height, flags);
}
else
{
    UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW;
    SetWindowPos(hWnd, 0, 0, 0, 0, 0, flags);
}

接下来,您必须释放您在默认池 - D3DPOOL_DEFAULT 中创建的所有资源(如果可能,最好使用 D3DPOOL_MANAGED)。如果不这样做,IDirect3DDevice9::Reset 将失败。
然后您可以重置设备,最后根据需要重新创建任何资源。确保您正确设置 IDirect3DDevice9::ResetD3DPRESENT_PARAMETERS

First, you need to change the properties of the window:

SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);

if (new_pos_size)
{
    // if you want new position (pos_x, pos_y) and size (width, height)
    UINT flags = SWP_FRAMECHANGED | SWP_SHOWWINDOW;
    SetWindowPos(hWnd, HWND_NOTOPMOST, pos_x, pos_y, width, height, flags);
}
else
{
    UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW;
    SetWindowPos(hWnd, 0, 0, 0, 0, 0, flags);
}

Next you have to release any resources you created in default pool - D3DPOOL_DEFAULT (it's better to use D3DPOOL_MANAGED if possible). If you don't, IDirect3DDevice9::Reset will fail.
Then you can reset the device and finally recreate any resources if needed. Make sure you set up D3DPRESENT_PARAMETERS for IDirect3DDevice9::Reset correctly.

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