Opengl design...multiple viewports or just a single view port

Hi

I am in the process of building a tool to view levels graphically and meta data associated with that level, to keep things simple I will describe a very simple screen layout.

Menu at the top
2d Meta panel on the left
3d scene viewer for the remainder of the scene

This is pretty simple to draw in a single view port, the 2d panel and menu would over lap and hide the 3d scene when they are drawn and menu open clicks would generate a drop down menu which would again over lap the 3d scene.

If I wanted to have multiple view ports (ie displaying multiple 3d scenes on the same screen) it would make sense to have multiple view ports so each view port doesn’t interfere with the other. If you do this the 2d panel and menu might as well be in their own view port too. The problem with this is the menu drop down would fall out side its designated view port space when it opens and wouldn’t be able to overlap the 3d scene.

I might be misunderstanding view ports (as I haven’t gone down that road yet) but, is there a clever way to handle the menu problem so I can have multiple view ports? Or should I stick with a single view port and force everything to work there?

Any help here would be great

Did you design your menu system? If you’re using JMenu and the like this shouldn’t be a problem. Also, if you’re using a JFrame you can built a layout (gridbag might be the way to go) so create multiple areas to put your viewports in.

the whole thing is opengl so I won’t be using swing, I have all my own components.

You could use one view port and give the menu, 2D, and 3D areas their own matricies and do it in one draw call.

You could also use a scissor/stencil tests and have 3 separate draw calls.

Point is don’t use 3 different view ports that doesnt make any sense, that is what scissor and stencil test is for.

You could also make use of FrameBuffers for this, but using glScissor is a better idea if you need more performance. (Or is it?)
If you need a lot of control over your ‘viewports’, use framebuffers at the cost of a bit of performance.
If you need a lot of performance, and no über-complex masterpiece of a viewport-system, use glScissor.

I might be wrong, and Framebuffers may actually be the better and more performant tool for the job here, but since I never did a multi-view kind of thing…

Have a nice day!

  • Longor1996

cool, yeah use the stencil buffer to deal with the menus, that way you don’t have to worry about the overlap when you resize your components.

Thanks, lots of useful information here. I have never used glScissor before so I will take a look at this (together with stencils)

Longor1996 - What strategy do you have in mind when using FrameBuffers (You mean FBO’s Iam assuming)?