在模态对话框/打开主菜单期间继续渲染 3D 窗口? [英] Keep rendering a 3D window during modal dialogs/opening main menu?

查看:25
本文介绍了在模态对话框/打开主菜单期间继续渲染 3D 窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我使用 Ogre3D 进行渲染,但问题应该是通用的.)

(I use Ogre3D for the rendering but the question should be generic.)

问题:大多数 3D 应用程序使用循环来迭代渲染帧并检查消息并处理它们.但是如果打开一个对话框(MessageBox 或类似的),它会阻塞线程的执行并运行它自己的消息循环,但它显然不会调用其中的 3D 渲染函数.

The problem: most 3D aplications use a cycle which iterates rendering a frame and checking for messages and processing them. However if a dialog is opened (MessageBox or similar), it blocks the execution of the thread and is running it's own message cycle, but it obviously does not call the 3D rendering function in it.

即使在对话框打开时保持渲染 3D 场景的首选或最佳"方式是什么?普通应用程序不会遇到这个问题,因为它们的重新渲染是由 WM_PAINT 消息和类似消息处理的,并且由于模式对话框确实具有内部消息循环,因此在需要时会调用 window proc get 并且一切看起来都很好.然而,在我的 3D 项目中,需要时"一直是,因为窗口必须更新,即使没有 WM_PAINT 消息.

What is the preferred, or "best" way of keeping rendering the 3D scene even when dialogs are open? The normal applications do not suffer from this problem, because their re-rendering is handled by WM_PAINT messages and similar, and since modal dialogs do have internal message loop, the window proc get's called when needed and everything looks fine. In my 3D project however, "when needed" is all the time, because the window has to be updated, even without WM_PAINT messages.

想到的简单解决方案是为对话框打开的时间注册一个计时器,并从 WindowProc 渲染 3D 场景,但这真的是最好的吗?看起来很脏...

The simple solution that comes to mind is to register a timer for the time when dialogs are open, and render 3D scene from the WindowProc, but is it really the best? Seems very dirty...

推荐答案

我不知道这是最好的方法,但我认为它会奏效.

I don't know that this is the best way, but I think it will work.

添加处理程序WM_ENTERIDLE 使用 PeekMessage 执行以下操作:

Add a handler for WM_ENTERIDLE that uses PeekMessage to do something like:

case WM_ENTERIDLE:
    while (!PeekMessage())
    {
        DoYourRendering();
    }
    return 0;

这篇关于在模态对话框/打开主菜单期间继续渲染 3D 窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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