Higher z-order viewports covered by gui viewport

trs79

02-11-2007 23:09:07

Hi,

Thanks for such a great gui library. I have a picture-in-picture kind of a setup, such that I have 4 viewports that I want to display on top of the main scene viewport (that I passed into the QuickGUI::Manager constructor).

The problem is, even though the additional 4 viewports have higher z levels then the QuickGui viewport, they get hidden behind it. Is this related to something in the vertexbuffer QuickGUI uses (like a hardcoded z order)? Thanks!

kungfoomasta

02-11-2007 23:27:40

By default the GUI gets rendered in the RenderQueueGroupID::RENDER_QUEUE_OVERLAY group.

For reference, here is the various ID's:


enum RenderQueueGroupID
{
/// Use this queue for objects which must be rendered first e.g. backgrounds
RENDER_QUEUE_BACKGROUND = 0,
/// First queue (after backgrounds), used for skyboxes if rendered first
RENDER_QUEUE_SKIES_EARLY = 5,
RENDER_QUEUE_1 = 10,
RENDER_QUEUE_2 = 20,
RENDER_QUEUE_WORLD_GEOMETRY_1 = 25,
RENDER_QUEUE_3 = 30,
RENDER_QUEUE_4 = 40,
/// The default render queue
RENDER_QUEUE_MAIN = 50,
RENDER_QUEUE_6 = 60,
RENDER_QUEUE_7 = 70,
RENDER_QUEUE_WORLD_GEOMETRY_2 = 75,
RENDER_QUEUE_8 = 80,
RENDER_QUEUE_9 = 90,
/// Penultimate queue(before overlays), used for skyboxes if rendered last
RENDER_QUEUE_SKIES_LATE = 95,
/// Use this queue for objects which must be rendered last e.g. overlays
RENDER_QUEUE_OVERLAY = 100,
/// Final possible render queue, don't exceed this
RENDER_QUEUE_MAX = 105
};


I don't have access to the code currently, but I believe GUIManager has a function to allow specifying a different Render Group ID. If this is not the case let me know and I'll add it. If you can't find it, I can look into it, but I remember making this a configurable parameter at one point.

And to make it clear, I do believe the GUIManager is rendering with higher zOrder, even though its on the background viewport. Depending on your scenario, you can either set the 4 top viewports to render on RENDER_QUEUE_OVERLAY or higher, or change the GUIManager to render on a group rendered before the top viewports. (they probably use RENDER_QUEUE_MAIN)

Let me know if it works out! :)

trs79

07-11-2007 21:27:54

Thanks for the response and info, however unfortunately I'm still having problems. First, I called guiManager->setRenderQueueID(Ogre::RENDER_QUEUE_BACKGROUND) to try to put the gui as far back as possible, but it still overlaps the 4 smaller viewports on top of the QuickGUI viewport.

Also, just for testing purposes I put the gui into one of the smaller viewports, and if I set the gui to RENDER_QUEUE_BACKGROUND, the other 3 viewports went totally blank (filled with their background color) for some reason. If I didn't mess with the gui render queue, the other 3 small viewports rendered just fine through the cameras like normal.

So in the end I just used Photoshop and punched 4 rectangular areas out of the gui background so the alpha channel would let the viewports through, but I'm sure there must be some other way to do it, any more help would be greatly appreciated.

kungfoomasta

07-11-2007 21:55:32

Interesting, thanks for posting your results. Maybe there is a problem with the setRenderQueueID function, I haven't tested it. This weekend I'll find time to try and repro this. Can you provide any snippets for creation of the viewports? If not, I'm sure I can figure it out. I think I need to create 4 other cameras and create viewports with them via the render window or something..

trs79

10-11-2007 16:09:46

No problem, glad to help. Yes, we are just using the renderWindow to create the viewports, and at the moment I'm using one camera for the larger vieport and just using another camera for the others. Here is the initial code to crete the viewports:

// this is the viewport that fills the screen, also used by QuickGUI
_viewport = _window->addViewport(_sceneMgr->createCamera("PlayerCamera"), 1, 0, 0, 1, 1);
_viewport->setBackgroundColour(Ogre::ColourValue(0.8, 0.8, 0.8));

#define PIC1_X 0.5921875
#define PIC1_Y 0.25390625
#define PIC_WIDTH 0.1875
#define PIC_HEIGHT 0.173828125
#define PIC_HORIZONTAL_SPACING 0.0015625
#define PIC_VERTICAL_SPACING 0.001953125


Ogre::Viewport *vp = _window->addViewport(_camera, 5, PIC1_X, PIC1_Y, PIC_WIDTH, PIC_HEIGHT);
vp->setBackgroundColour(Ogre::ColourValue(0.5, 0.5, 0.5));
vp->setShadowsEnabled(false);
vp->setMaterialScheme("pip");


vp = _window->addViewport(_camera, 7, PIC1_X+PIC_HORIZONTAL_SPACING+PIC_WIDTH, PIC1_Y, PIC_WIDTH, PIC_HEIGHT);
vp->setBackgroundColour(Ogre::ColourValue(0.5, 0.5, 0.5));
vp->setShadowsEnabled(false);
vp->setMaterialScheme("pip");

vp = _window->addViewport(_camera, 8, PIC1_X, PIC1_Y+PIC_VERTICAL_SPACING+PIC_HEIGHT, PIC_WIDTH, PIC_HEIGHT);
vp->setBackgroundColour(Ogre::ColourValue(0.5, 0.5, 0.5));
vp->setShadowsEnabled(false);
vp->setMaterialScheme("pip");

vp = _window->addViewport(_camera, 10, PIC1_X+PIC_HORIZONTAL_SPACING+PIC_WIDTH, PIC1_Y+PIC_VERTICAL_SPACING+PIC_HEIGHT, PIC_WIDTH, PIC_HEIGHT);
vp->setBackgroundColour(Ogre::ColourValue(0.5, 0.5, 0.5));
vp->setShadowsEnabled(false);
vp->setMaterialScheme("pip");

// and then later on...
QuickGUI::registerScriptParser();
QuickGUI::GUIManager *m = new QuickGUI::GUIManager(_viewport)
m->setRenderQueueID(Ogre::RENDER_QUEUE_BACKGROUND);

QuickGUI::SkinSetManager::getSingleton().loadSkin("qgui", "General");
m->setSceneManager(_sceneMgr );



Thanks! (oh, I'm using svn too by the way, rev. 241 I think)

kungfoomasta

12-11-2007 02:56:20

:?

I see the same issue also, and I don't know what could be the problem. I'd have to dive into Ogre to see how viewports, render queues, and zOrdering works. :(

My only use of the viewport is the following line of code:

mRenderSystem->_setViewport(mGUIManager->getViewport());

Basically, I send all my rendered quads to the following viewport, the rest is done in Ogre.

This is how the Render Queue is used for rendering:


void GUIManager::renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue)
{
if(mQueueID == id)
{
mActiveSheet->render();
mMouseCursor->render();
}
}


I get notified when the RenderQueue has started rendering, and render my quads then. How this relates to other viewports... no idea. I tried changing the RenderQueue, even at the lowest queue, the gui is drawn over the viewport. :?

If I find more time I can look into this, but seeing as you have an alternative route that works, I'd probably push this back, maybe for the v0.9.8 or so. It's either some configuration setting, or something with Ogre's render system, is my guess.. sorry I can't help more!