ogre stops to render
-
- Hobgoblin
- Posts: 542
- Joined: Sun Jan 12, 2003 7:35 pm
- Location: Copenhagen, Denmark
ogre stops to render
Hi guys
Can someone tell me how I can prevent Ogre from stopping the rendering in a windowed rendering session when i switch to another window ?
- Kristian
Can someone tell me how I can prevent Ogre from stopping the rendering in a windowed rendering session when i switch to another window ?
- Kristian
-
- OGRE Expert User
- Posts: 1422
- Joined: Sat May 22, 2004 5:28 am
- Location: Bucharest
- x 8
i dont think it can be done! when switching to another window the render window becomes inactive and thus not something to render in...but i'm not 100% sure about this! why will u need to render on screen if the window is inactive and maybe covered by another window??
if u really need the frames when window inactive, use RenderTarget...this way u can have each rendered frame in a texture (u can do whatever u like with it, even save it on disk) !
if u really need the frames when window inactive, use RenderTarget...this way u can have each rendered frame in a texture (u can do whatever u like with it, even save it on disk) !
-
- OGRE Retired Team Member
- Posts: 1263
- Joined: Wed Sep 24, 2003 4:00 pm
- Location: Halifax, Nova Scotia, Canada
I do it in the material editor I am working on but there are some small changes you have to make to the Ogre renderers (d3d9, gl). I modified the windows message handling routines in OgreWin32Window.cpp (GL renderer) and OgreD3D9RenderWindow.cpp (D3D9 renderer).
This is what I have for both renderers:
The commented out code is the original code.
So the only time win->mActive is set to false is when the window is minimized which is handled lower down in the windows message handling routines by original code. I never understood why drawing to the window was stopped when the window was no longer active. Its only a problem for device context when the window is minimized or no longer visible (moved off screen) and the original code handles this.
I have been using these changes since Ogre 0.13 with no problems in DX9 or OGL and it works with Ogre 1.0 too
.
Maybe I should submit a patch?
This is what I have for both renderers:
Code: Select all
case WM_ACTIVATE:
//if( WA_INACTIVE == LOWORD( wParam ) )
// win->mActive = false;
//else
win->mActive = true;
break;
So the only time win->mActive is set to false is when the window is minimized which is handled lower down in the windows message handling routines by original code. I never understood why drawing to the window was stopped when the window was no longer active. Its only a problem for device context when the window is minimized or no longer visible (moved off screen) and the original code handles this.
I have been using these changes since Ogre 0.13 with no problems in DX9 or OGL and it works with Ogre 1.0 too

Maybe I should submit a patch?
-
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
If this is a patch, I think this should be added as a RenderWindow option, like
It's intentional that we stop rendering when losing the focus - for example in fullscreen mode it will fail anyway but otherwise you probably don't want Ogre hogging the machine whilst you're trying to write an email!
Code: Select all
virtual void setUpdateWhileInactive(bool upd);
-
- Greenskin
- Posts: 128
- Joined: Mon Jun 21, 2004 2:34 am
- Location: Victoria, Australia
I'm not entirely sure, but doesn't it do that anyway (hog even when inactive)? I know when Alt-F4 used to close the window but not exit Ogre, it was still chugging the system even though nothing at all was being rendered.
Myself, I'm using a custom main loop, with a Sleep(0) in it, so Ogre uses 100% if its available, but hands off as soon as anything else wants anything. Not cross-platform though.
Myself, I'm using a custom main loop, with a Sleep(0) in it, so Ogre uses 100% if its available, but hands off as soon as anything else wants anything. Not cross-platform though.
-
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
-
- Greenskin
- Posts: 125
- Joined: Mon Oct 20, 2003 8:25 pm
-
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
-
- OGRE Community Helper
- Posts: 198
- Joined: Sat Oct 02, 2004 9:11 am
- Location: San Francisco, California, USA
-
- Greenskin
- Posts: 125
- Joined: Mon Oct 20, 2003 8:25 pm
Me personally I don't mind it running through the main loop - writing a game I looked at implementing a custom render loop to keep the network system running until I noticed that only the rendering stops.
But still it might do hvy calcs inside the apps - although I firmly believe that a windowed application should do manual rendering and sleeping and not use the ogre main loop.

But still it might do hvy calcs inside the apps - although I firmly believe that a windowed application should do manual rendering and sleeping and not use the ogre main loop.
-
- Halfling
- Posts: 86
- Joined: Mon Dec 13, 2004 9:47 am
- Location: Oregon, United States
I was wondering if this ever made it into a build of ogre?sinbad wrote:If this is a patch, I think this should be added as a RenderWindow option, likeIt's intentional that we stop rendering when losing the focus - for example in fullscreen mode it will fail anyway but otherwise you probably don't want Ogre hogging the machine whilst you're trying to write an email!Code: Select all
virtual void setUpdateWhileInactive(bool upd);
From looking at the source files of the latest release, I don't think it has. Is this a planned feature?
Thanks
-
- OGRE Community Helper
- Posts: 198
- Joined: Sat Oct 02, 2004 9:11 am
- Location: San Francisco, California, USA
Some more work needs to be done to redefine what an "active" window is, and how this all works with multiple renderwindows. This will eventually make it in to the 1.1 (Dagon) series but is unlikely to hit the 1.0 branch.
Ogre 1.0 apps that care about this should use their own main loop and call Ogre to render one frame at a time.
Ogre 1.0 apps that care about this should use their own main loop and call Ogre to render one frame at a time.
-
- Gnoblar
- Posts: 11
- Joined: Thu Jun 30, 2005 12:47 am
@NFZ: My OgreWin32Window.cpp looks like this:
can I do this:
will this have the same effect that the render window doesnt stop rendering when it looses focus?
Thanks
Code: Select all
case WM_ACTIVATE:
if (win->mIsFullScreen)
{
if (LOWORD(wParam) == WA_INACTIVE)
{
win->mActive = false;
ChangeDisplaySettings(NULL, 0);
ShowWindow(hWnd, SW_SHOWMINNOACTIVE);
}
else
{
win->mActive = true;
ShowWindow(hWnd, SW_SHOWNORMAL);
DEVMODE dm;
dm.dmSize = sizeof(DEVMODE);
dm.dmBitsPerPel = win->mColourDepth;
dm.dmPelsWidth = win->mWidth;
dm.dmPelsHeight = win->mHeight;
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if (win->mDisplayFrequency)
{
dm.dmDisplayFrequency = win->mDisplayFrequency;
dm.dmFields |= DM_DISPLAYFREQUENCY;
}
ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
}
}
break;
Code: Select all
case WM_ACTIVATE:
if (win->mIsFullScreen)
{
/*if (LOWORD(wParam) == WA_INACTIVE)
{
win->mActive = false;
ChangeDisplaySettings(NULL, 0);
ShowWindow(hWnd, SW_SHOWMINNOACTIVE);
}
else*/
{
win->mActive = true;
ShowWindow(hWnd, SW_SHOWNORMAL);
DEVMODE dm;
dm.dmSize = sizeof(DEVMODE);
dm.dmBitsPerPel = win->mColourDepth;
dm.dmPelsWidth = win->mWidth;
dm.dmPelsHeight = win->mHeight;
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if (win->mDisplayFrequency)
{
dm.dmDisplayFrequency = win->mDisplayFrequency;
dm.dmFields |= DM_DISPLAYFREQUENCY;
}
ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
}
}
break;
Thanks