multiple GUIs on different viewports

akem321

17-12-2007 02:22:54

Hi,

First of all, QuickGUI looks cool, very lightweight, common GUI widgets and cross-plateforms, and looks like you are also working on editor tools/skins etc, nice, nice :)

ok, so here s my question:

would it be possible to use different GUI systems on different viewports at the same time, like having 2 windows with completly separated GUI(both windows would have their own separate input sub-system too), i saw that the GUIManager and MouseCursor, were singletons, wonder if this would be a pblm a not. I guess that all the sessions would be handled via the GUIManager then.

i wonder if it s possible to do this using QuickGUI in it s actual state?

Thx!

kungfoomasta

17-12-2007 02:45:28

They are no longer singletons, you must be referring to an older version. :)

Each GUIManager uses a viewport, but I don't think its been tried, having multiple viewports in the same render window, each with its own guimanager. There was a problem mentioned a while back, regarding multiple viewports in the same render window, QuickGUI was rendering over all the viewports. (if I remember correctly)

I do know that QuickGUI works fine on multiple viewports in multiple Render Windows, maybe you're referring to that? That's what I use in my own personal project.

akem321

17-12-2007 03:22:02

hey

ha ok, yep i was refering to an older version, didn t try svn yet

yea multiple viewports in multiple Render Windows exactly :)
then it s just what i need hehe

thx for the quick reply

glaciedge

03-04-2009 03:14:04

Hi,

I am trying to implement QuickGUI on multiple render windows. However, I got an exception about "Failed to setRenderTarget," when I open multiple render windows. (It works fine if I only open one window)

Here is my code. I am following the Example Application framework and the QuickGUI beginner's tutorial, and wrote this part in the constructor of my FrameListener.

mCamera1=mSceneMgr->getCamera("PlayerCam1");
mCamera2=mSceneMgr->getCamera("PlayerCam2");

QuickGUI::Root* guiRoot = new QuickGUI::Root();
QuickGUI::SkinTypeManager::getSingleton().loadTypes();
QuickGUI::GUIManagerDesc d;
d.sceneManager = mSceneMgr;
d.viewport = mCamera1->getViewport();
d.queueID = Ogre::RENDER_QUEUE_OVERLAY;
mGUIManager = guiRoot->getSingletonPtr()->createGUIManager(d);

mSheetFromFile = new QuickGUI::Sheet("Test.sheet",true);
mGUIManager->setActiveSheet(mSheetFromFile);


QuickGUI::GUIManagerDesc d2;
d2.sceneManager = mSceneMgr;
d2.viewport = mCamera2->getViewport();
d2.queueID = Ogre::RENDER_QUEUE_OVERLAY;
mGUIManager2 = guiRoot->getSingletonPtr()->createGUIManager(d2);
mSheetFromFile2 = new QuickGUI::Sheet("Test2.sheet",true);
mGUIManager2->setActiveSheet(mSheetFromFile2);


Here is how I create my viewports in my application.
Viewport* vp1 = mWindow->addViewport(mCamera1);
vp1->setBackgroundColour(ColourValue(0,0,0));

RenderWindow* pCurWindow = mRenderWindows[0];
Viewport* vp2 = pCurWindow->addViewport(mCamera2);
vp2->setBackgroundColour(ColourValue(0,0,0));


and here is the OGRE log
12:26:24: D3D9 : WARNING - disabling VSync in windowed mode can cause timing issues at lower frame rates, turn VSync on if you observe this problem.
12:26:24: D3D9 device: 0x[0360AA80] lost. Releasing D3D9 texture: Sheet.RenderTarget
12:26:24: Released D3D9 texture: Sheet.RenderTarget
12:26:24: D3D9 device: 0x[0360AA80] lost. Releasing D3D9 texture: Sheet.AutoName.0.RenderTarget
12:26:24: Released D3D9 texture: Sheet.AutoName.0.RenderTarget
12:26:24: Recreating D3D9 default pool texture: Sheet.RenderTarget
12:26:24: Recreated D3D9 default pool texture: Sheet.RenderTarget
12:26:24: Recreating D3D9 default pool texture: Sheet.AutoName.0.RenderTarget
12:26:24: Recreated D3D9 default pool texture: Sheet.AutoName.0.RenderTarget
12:26:24: D3D9 device: 0x[0360AA80] was reset
12:26:24: OGRE EXCEPTION(3:RenderingAPIException): Failed to setRenderTarget : Invalid call in D3D9RenderSystem::_setViewport at d:\trunk\rendersystems\direct3d9\src\ogred3d9rendersystem.cpp (line 2709)


I am using this multiple screen patch http://www.ogre3d.org/forums/viewtopic.php?f=11&t=47621
Is it a problem?
I guess I need to assign the second GUI manager for my second window's viewport, so I just simply follow the tutorial to create another GUI manager and inject input to both GUI managers.
Did I do anything wrong? :cry:

kungfoomasta

03-04-2009 07:04:55

If you comment out all the QuickGUI code, does the error still occur? In my own project, I have multiple RenderWindows, I've tested 3 of them, all running at the same time, with different GUIManager's associated with them. Also check to make sure the Sheet's have different names, if two Sheets have the same name, they might try to create a Texture with the same name, and cause some sort of issue there. The log suggests there is some issue related to the viewport, so I'm not really sure whats going on here, or if its related to QuickGUI at all. Are you able to step through the code? If you can provide a callstack that would be helpful in seeing the last executed statements.

glaciedge

03-04-2009 07:38:30

I didn't get any error when I comment out all the QuickGUI code..
I also gave the sheets different names, but it's still the same.

I checked the code in original OgreD3D9RenderSystem.cpp and the patched code.
The code in void D3D9RenderSystem::_setViewport( Viewport *vp ) function is different due to the patched code support the DirectX multihead
Original code:
for(uint x=0; x<count; ++x)
{
hr = mpD3DDevice->SetRenderTarget(x, pBack[x]);
if (FAILED(hr))
{
String msg = DXGetErrorDescription9(hr);
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to setRenderTarget : " + msg, "D3D9RenderSystem::_setViewport" );
}
}
hr = mpD3DDevice->SetDepthStencilSurface(pDepth);
if (FAILED(hr))
{
String msg = DXGetErrorDescription9(hr);
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to setDepthStencil : " + msg, "D3D9RenderSystem::_setViewport" );
}


Patched code:

for(uint x=0; x<count; ++x)
{
hr = getActiveD3D9Device()->SetRenderTarget(x, pBack[x]);
if (FAILED(hr))
{
String msg = DXGetErrorDescription9(hr);
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to setRenderTarget : " + msg, "D3D9RenderSystem::_setViewport" );
}
}
hr = getActiveD3D9Device()->SetDepthStencilSurface(pDepth);
if (FAILED(hr))
{
String msg = DXGetErrorDescription9(hr);
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to setDepthStencil : " + msg, "D3D9RenderSystem::_setViewport" );
}


The mpD3DDevice was changed to getActiveD3D9Device() to get the multi render devices.

Do you think this is a problem?

and sorry.... I don't know how to provide a callstack.... :oops:

kungfoomasta

03-04-2009 08:35:52

I'm not familiar enough with that code to know the effects of the changes that come with the patch. Are you able to step through the code? Can you create 1 GUIManager without any problems? What IDE/OS are you using?

glaciedge

06-04-2009 02:07:31

I can use 1 GUIManager when I only open one render window. If I open more than one window, the same error will occur.
I also can use 2 GUIManager for one render window.
(That's why I guess the problem is related to multiple screen patch.)
I am using Visual Studio 2008 on a Vista machine.

Because of my project's schedule, I need to find the solution ASAP. Therefore, I probably have to give up the multiple screen patch.

Thank you for your help anyway~~ :)

kungfoomasta

06-04-2009 18:03:03

It does sound related to the patch. Sorry I couldn't help much with this issue. :(