A good way to apply RenderSystem options?

Problems building or running the engine, queries about how to use features etc.
matches81
Greenskin
Posts: 116
Joined: Tue Jun 12, 2007 10:28 am

A good way to apply RenderSystem options?

Post by matches81 »

Hello there!
Is there a nice way to apply basic RenderSystem options such as VSync, Antialiasing and such on runtime?
Seemingly I'm unable to do that properly.

I use setConfigOption(...) to set the new options. After that I would tend to call RenderSystem::reinitialise().
It seems reinitialise() just calls shutdown and initialise(true). So I exchanged the call to reinitialise with a call to shutdown() and then initialise(false), since I don't want an automatically created RenderWindow.
However that screws up my RenderWindow* (the pointer I keep is invalid after calling shutdown() it seems). That indicates shutdown() deletes the RenderTargets. That is a problem for me. I want to keep my RenderWindow since I have CEGUI and OIS attached to it.
I could just reinitialise OIS with the new window, but I seem unable to do that with CEGUI, so I would really like to keep my RenderTarget.

So I guess after all my question is:
Is it possible to apply new RenderSystem options without shutting the RenderSystem or at least without killing the RenderTargets?

If not: Is there any how-to about the process involved on changing RenderSystem options on runtime? Should I perhaps create my own window and use that as an external render window? How exactly does that work?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

VSync and FSAA are window-specific options, setConfigOption just contains them to deal with the auto-window. See Root::createRenderWindow for how to specify them in the NamedValuePairList.

FSAA and VSync cannot be changed without recreating the window, both fundamentally change the buffer structure on some render systems (either the count or format of them). You don't need to reinitialise the whoe render system, just recreate the window. Since the first window is 'special' in that it holds all the GPU driver resources, if you want to do this at runtime you should create a 1x1 background window first, then create a second window afterwards which can be destroyed and recreated to your hearts content.
User avatar
FrameFever
Platinum Sponsor
Platinum Sponsor
Posts: 414
Joined: Fri Apr 27, 2007 10:05 am

Post by FrameFever »

sinbad wrote:VSync and FSAA are window-specific options, setConfigOption just contains them to deal with the auto-window. See Root::createRenderWindow for how to specify them in the NamedValuePairList.

FSAA and VSync cannot be changed without recreating the window, both fundamentally change the buffer structure on some render systems (either the count or format of them). You don't need to reinitialise the whoe render system, just recreate the window. Since the first window is 'special' in that it holds all the GPU driver resources, if you want to do this at runtime you should create a 1x1 background window first, then create a second window afterwards which can be destroyed and recreated to your hearts content.
so can you please poste a code snippet, how to recreate a window with activated FSAA?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Oh come now, don't be lazy, the documentation is not far away and I already pointed you at it above ;)

In case you still need hand-holding:

Code: Select all

NameValuePairList params;
params["FSAA"] = "4";
params["vsync"] = "true";
RenderWindow* win = Root::getSingleton().createRenderWindow("blah", 1600, 1200, true, params);
matches81
Greenskin
Posts: 116
Joined: Tue Jun 12, 2007 10:28 am

Post by matches81 »

sinbad wrote:VSync and FSAA are window-specific options, setConfigOption just contains them to deal with the auto-window. See Root::createRenderWindow for how to specify them in the NamedValuePairList.

FSAA and VSync cannot be changed without recreating the window, both fundamentally change the buffer structure on some render systems (either the count or format of them). You don't need to reinitialise the whoe render system, just recreate the window. Since the first window is 'special' in that it holds all the GPU driver resources, if you want to do this at runtime you should create a 1x1 background window first, then create a second window afterwards which can be destroyed and recreated to your hearts content.
Great! Thx!
I will give that a try tomorrow :)

[edit]
Tried it already, works like a charm. If someone else (Nash, for example) tries it, don't forget to recreate the viewport for the new window. Don't know if you _have_ to clean up the old viewport and the old window, but I did and didn't have a problem with it, so it might be a good idea, too.

[edit2]
Well... my happiness is gone again... using a secondary render window works great while in windowed mode, but fullscreen doesn't work, because seemingly a secondary window can't be fullscreen. Which brings me back to my initial problem, sadly. Obviously I can change the settings for FSAA and anything else for the secondary window, but as this only applies to windowed mode, it doesn't help me too much.
User avatar
FrameFever
Platinum Sponsor
Platinum Sponsor
Posts: 414
Joined: Fri Apr 27, 2007 10:05 am

Post by FrameFever »

hehe you was to happy...

What I definitly know, is it is possible to set FSAA dynaicly during runtime, also in Fullscreen Mode, I seen this in a Quest3D demo.

maybe this works only for D3D. maybe Sinbad has an answer to this?

what I need is something like

Code: Select all

updateCurrentRenderWindow(params);
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

It's technically possible, but we determine compatible buffer structured at window creation time, so you can't do it yet. There's actually a lot of released games that are like this too.
matches81
Greenskin
Posts: 116
Joined: Tue Jun 12, 2007 10:28 am

Post by matches81 »

sinbad wrote:It's technically possible, but we determine compatible buffer structured at window creation time, so you can't do it yet. There's actually a lot of released games that are like this too.
So, this means, currently there's no other way in Ogre to change FSAA and VSync in fullscreen mode without shutting the render system, reinitialising it and reloading all the resources needed, right?
If there is:
How?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Just recreate the window. I already mentioned creating a 1x1 dummy window to hold the device contexts to avoid having to restart the render system (see my first response)
User avatar
stoneCold
OGRE Expert User
OGRE Expert User
Posts: 867
Joined: Fri Oct 01, 2004 9:13 pm
Location: Carinthia, Austria
x 1

Post by stoneCold »

Five posts above...
sinbad wrote:... You don't need to reinitialise the whole render system, just recreate the window. Since the first window is 'special' in that it holds all the GPU driver resources, if you want to do this at runtime you should create a 1x1 background window first, then create a second window afterwards which can be destroyed and recreated to your hearts content.
:wink:

[edit]: ehm, too slow :)
my tweets | www.fuse-software.com | home of vektrix (Flash GUI for Ogre3D) and caspin (ActionScript 3 Virtual Machine Wrapper)
matches81
Greenskin
Posts: 116
Joined: Tue Jun 12, 2007 10:28 am

Post by matches81 »

sinbad wrote:Just recreate the window. I already mentioned creating a 1x1 dummy window to hold the device contexts to avoid having to restart the render system (see my first response)
Yes, I know you already suggested that 1x1 background window. I did that. And I returned saying that I can't do fullscreen with that solution, because I then get an exception saying that only the primary window may be fullscreen.
Also I have 2 tasks in the taskbar when creating two RenderWindow. So it's not a really nice solution... well, it might be, if I
a) get rid of the second task in the windows taskbar
b) somehow manage to use the primary window (my "background" window I created first) for fullscreen.

If I can do that I'm still back to the old problem: If I am already in fullscreen mode, i.e. using the primary window, how do I change FSAA or VSync without destroying the primary window and therefore the device, which would require reloading my resources?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Ah ok. In that case you can't, without enhancing OGRE right now since those 2 options require more re-initialisation than OGRE supports on the fly right now. Like I said, we're far from alone in this, there are lots of commercial titles that require a restart to change some settings.
matches81
Greenskin
Posts: 116
Joined: Tue Jun 12, 2007 10:28 am

Post by matches81 »

okay. Thx for confirming my guess. I already thought that this probably is the case. Knowing that now for sure is a good thing and will probably (hopefully) help me redesigning my GfxSystem class (my class containing everything Ogre related)