如何正确添加状态栏?

发布于 2024-08-21 19:52:47 字数 224 浏览 5 评论 0 原文

目前它漂浮在我渲染的窗口顶部,我认为这不好,原因如下: 1)我浪费渲染时间来渲染不可见的东西。 2)当我无论如何都不会每帧更新整个状态栏时,它必须再次渲染每一帧。

那么我如何创建一个窗口,为我的状态栏留出空间,并且我的 OpenGL 内容都无法在该区域渲染?

目前,我只是以一种为状态栏创建空白空间的方式调整我的视口,但这会导致我当前的处理方式出现一些问题。我必须让我的代码看起来更加混乱才能使其工作。

Currently it is floating on top of my rendered window, i dont think thats good for few reasons:
1) i waste rendering time for rendering stuff that isnt visible.
2) it must be rendered every frame again when i wouldnt be updating the whole statusbar every frame anyways.

So how i could create a window where it leaves space for my statusbar and none of my OpenGL stuff could be rendered in that area?

At this moment i just adjust my viewports in a way that creates empty space for statusbar, but it causes some problems in my current way of doing things. i would have to make my code look much more messier to make it work.

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

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

发布评论

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

评论(2

梦罢 2024-08-28 19:52:47

http://www.gamedev.net/community/forums/topic。 asp?topic_id=291682

编辑:这不是一个简单的问题。如果您不知道 Win32 下的子窗口是什么,那么您可能处于更好的位置。然而,要求某人对 Windows 窗口系统进行完整的解释并不是一件容易的事。

以下是概述:

基本上,您需要创建一个子窗口,可以使用 CreateWindow 创建一个具有 WS_CHILD 样式的窗口,并将其 hWndParent 参数设置为您希望新窗口成为其子窗口的窗口句柄。

创建窗口时,您必须创建一个 窗口过程 当您调用 DispatchMessage< /a> 来自消息泵(执行 Get/PeekMessage 然后分派消息的循环是消息泵)。然后,您可以在窗口过程中打开消息类型并处理发送到窗口的每条消息。

从这里您可以处理诸如设置之类的事情。您的初始窗口将具有 WM_CREATE 或a WM_INITDIALOG (取决于窗口类型你创造)。您需要从那里创建子窗口(不要忘记调用 ShowWindow 使它们可见!!)。从此时起,您可以设置要附加到子窗口句柄 (HWND) 的 DirectX 设备。

此外,如果您希望能够调整窗口大小,那么您还需要考虑WM_SIZE 消息。不过,我强烈建议您在开始研究此问题之前先尝试让其余部分正常工作,因为它会变得非常复杂,因为您需要销毁并重新创建 DirectX 设备,使其大小合适。

无论如何,这只是一个简单的概述。我希望它有帮助!

http://www.gamedev.net/community/forums/topic.asp?topic_id=291682

Edit: Its not a simple question to answer. If you don't know what a child window is under Win32 then you may be in a much better position. However asking someone to give you a full explanation of the windows windowing system is no mean feat.

Here is an overview:

Basically you need to create a child window which can be done using CreateWindow to create a window with the WS_CHILD style and with its hWndParent parameter set to the window handle you want the new window to be a child of.

When you created the window you will have, necessarily, create a window procedure When you call DispatchMessage from your message pump (The Loop that does a Get/PeekMessage and then dispatches the messages is the message pump). Inside the window procedure you can then switch on the message type and handle each message sent to your window.

From here you can handle things like setup. Your initial window will have either a WM_CREATE or a WM_INITDIALOG (Depending on what type of window you create). It is from there that you need to create the child windows (Don't forget to call ShowWindow to make them visible!!). From this point you can then set up the DirectX device to be attached to the child window handle (HWND).

Furthermore if you want to be able to re-size the window then you ALSO need to take into account the WM_SIZE mesage. However I'd strongly recommend trying to get the rest working before even beginning to look into this as it gets very complicated as you will need to destroy and re-create your DirectX device so that it is the right size.

Anyway thats just a simple overview. I hope it helps!

一抹淡然 2024-08-28 19:52:47

一种方法可能是使“渲染窗口”和“状态栏”都是包含窗口的子窗口,并为该包含窗口的 WM_SIZE 消息添加一些代码来定位子窗口,这样它们就不会'重叠。

One way may be to make your "rendered window" and "statusbar" both children of a containing window, and to add some code for the WM_SIZE message for that containing window to position the children so they don't overlap.

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