[3.2] Viewport considerations

jdxsolutions

14-10-2011 12:33:53

Firstly, I've noted that MyGUI doesn't take viewport dimension into account when you inject mouse events, e.g adjusting mouse position based on viewport position within the RenderWindow. Is this a bug or a feature - and do I simply roll my own code or is there a utility already in MyGUI?

Secondly, [how] can I control which viewport MyGUI is using by default?

jdxsolutions

14-10-2011 15:09:03

OK, so OgreRenderManager::setActiveViewport() lets me tell it what viewport to use, neat.

How should one use MyGUI to apply a GUI in a multi-viewport application though - say I have 4 VPs splitting the screen into quarters and each should have some buttons - I need to handle both rendering and input to each viewport properly.

Altren

15-10-2011 09:43:52

Why not draw GUI in main viewport above everything else, and place your controls properly above each quarter.

You can render gui in 4 viewports, but this require GUI rendered into 4 different textures for each viewport, and I see no reason how could this be useful.

jdxsolutions

15-10-2011 10:19:06

You can have a viewport on top of another with transparency - e.g set alpha=0 on background-color? If so I guess you could have one full-screen viewport used only for GUI.

But that leads to bad design - your central app has to know about all the viewports and manage each viewport's associated GUI. Conceptually it's better each viewport keeps track of its own GUI - I'm using viewports in more dynamic way.

Not sure why you'd have to use 4 separate textures - although if you can point to any example/sample using multiple textures, I'd like to see it! It seems each viewport could just have a frame-listener which calls OgreRenderManager::setActiveViewport() and handles showing/hiding correct widgets, just before rendering. But this is an ugly hack. It's a shame multi-viewport support isn't built in really. It would make MyGUI much more useful for non-game applications :)

jdxsolutions

17-10-2011 11:59:50

Why not draw GUI in main viewport above everything else, and place your controls properly above each quarter.
What I'm looking at now is using 4 Canvas controls, each taking 1/4 of the screen. Then I can easily use GUI on top, and even wrap Canvas in a parent Window so I can have GUI for each 'view'.

My main issue here is, I only want Ogre to render MyGUI into the main viewport. The Canvas objects have 3D rendering but I don't want to be rendering the 3D scene as well into the main viewport as it will be hidden by the 4 Canvas objects. I wonder what the easiest setup for that is?

e.g:
int width = renderWindow.getWidth(), height=renderWindow.getHeight();
int viewWidth=width/2, viewHeight=height/2;

for(int x=0;x<2;++x)
for(int y=0;y<2;++y)
{
widget = Gui::getInstance().createWidget<Widget>("PanelSkin",viewWidth*x,viewHeight*y,viewWidth,viewHeight);
IntCoord clientRect = widget->getClientCoord();
canvas = widget->createWidget<Canvas>("Canvas",0, 0, clientRect.width,clientRect.height,Align::Stretch);
...
}
So I have my 4 views which can have different cameras, etc, and I can have my GUI... but I don't want to render anything under the GUI.

edit - since MyGUI uses Ogre Overlays, I think that question can be rephrased as "how can I make Ogre render just the overlays for a viewport and nothing else".

Altren

19-10-2011 09:21:31

edit - since MyGUI uses Ogre Overlays, I think that question can be rephrased as "how can I make Ogre render just the overlays for a viewport and nothing else".MyGUI don't use overlays, but use same rendering order though. And what about your question - isn't viewport that see nothing render only overlays?

jdxsolutions

19-10-2011 09:29:15

If MyGUI doesn't use overlays,why does disabling overlays on an Ogre viewport make MyGUI disappear?

Altren

19-10-2011 10:55:40

Because, as I just said, MyGUI use same rendering queue group, and disabling overlays is just skipping that queue group in render process.