Multiple glViewports and mouse interaction

Hello All,
I hope someone can help me. I am trying to build a 3D modeling application and am having trouble getting my different views to work correctly.

At first, I tried creating four separate windows with separate gl RCs, but I had problems when I would click the mouse in one viewport, i would get a different point in the others.

before I go back to that and try to see what I was doing wrong, I decided to try using multiple viewports (i.e. multiple calls to glViewport) and see how that goes as all of the stuff i have read seems to imply that this is how max and maya do it themselves.

so, I got the different viewports set up correctly, but now my mouse click code does not work and i don’t really see how I should go about fixing it.

Does anybody know of a tutorial or book that goes into multiple viewports in some depth?

I need to know how I interact with the different viewports. Do I have to figure out what viewport I am in before I use gluUnProject? Should I be using gluUnProject at all?

If someone could tell me what I need to do to get multiple viewports and then be able to click in each viewport and have that point be regeistered correctly, I would greatly appreciated.

Even if you could just give m a keyword or somethign that I am missing so I know where to look.

I have tried searching through the mailing lists, but could not find anything.

I would find people who wnated to know how to use multiple viewports, but they never discussed mouse interaction and i wonder how they all fared later on.

I am using Qt for my GUI toolkit and don’t think that is the problem. I am writing on Linux, but I had the same problems under windows as well.

Any help would be appreciated.

thanks in advance.

One possible solution I came up with a while ago:

When you render your scene for selection (via glRenderMode(GL_SELECT)) - render it full screen (i.e. the window’s entire client area).

When the user clicks inside any viewport, you must map that point from the viewport to a full screen point (i.e. map it to the client area) and you use that point to set up your selection area.

There’s no need to use glUnproject for anything if you’re using OpenGL’s GL_SELECT method for selection.

…You’re performing selection on a full size viewport behind the scenes.

Thanks a lot Aeluned,
I will read up on selection mode and give it a try.

Fixed it. I didn’t use selection mode (although I will implement that later on), but my problem was that I was still using the viewport height to calculate my corrected y position when getting paramters to call gluUnProject. I read in another post, that you need to use the total window/RC height instead and now it works just fine.

Thanks again

Thanks again,