PDA

View Full Version : Multiple VIewports and Mouse



Ramzy Darwish
08-16-2005, 09:55 AM
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.
ramzy

Arkion
08-17-2005, 06:16 AM
Just use multiple RC's and remember to make the viewport's rendering context current each time before calling gluUnProject. wglMakeCurrent/glXMakeCurrent should be the first thing to do in the mouse event handler function.

This is how I got it working.

knackered
08-17-2005, 01:25 PM
Yeah, good advice Arkion. Genius.
Aren't there moderators anymore?

Ramzy Darwish
08-17-2005, 02:11 PM
Please don't flame me if this is an idiotic question, but when you say use multiple RCs, do you mean to go back to multiple windows instead of just spearate glViewport calls, or is there a way to bind an RC to a viewport.

I hope I am understanding correctly. Thanks so much for answering.

I hope that this is my problem. I think I am assuming that Qt is calling make current for me and I know that it does when you get into a pain callback, but i didn't think about it when i get to a mouse callback. slipped my mind.

thanks so much

ramzy

Arkion
08-18-2005, 12:46 AM
Please don't flame me if this is an idiotic question, but when you say use multiple RCs, do you mean to go back to multiple windows instead of just spearate glViewport calls, or is there a way to bind an RC to a viewport. Yes. As an added benefit, each RC/viewport will have it's own GL state, so you don't need to swap certain GL settings forth and back when rendering each of time. E.g. take wireframe and textured viewport for an example.

I've never used multiple glViewport calls on single RC, so I can't assist on that.

knackered
08-18-2005, 04:05 AM
Originally posted by Arkion:
Yes. As an added benefit, each RC/viewport will have it's own GL state, so you don't need to swap certain GL settings forth and back when rendering each of time.Yes, instead OpenGL will have to swap *every* state back and forth, rather than just the ones your application cares about.
Don't use multiple RC's, it's the best way of bringing a GL application to it's knees. It's appauling advice. That's not a flame by the way, it's a correction of misinformation. Important to know the difference.
Ramzy, this post belongs in the beginners forum - it's basic stuff. Nothing wrong with asking this kind of question there, just not here in the 'advanced' forum. I won't even attempt to answer your initial question here, as it will just encourage others to post basic questions in the advanced forum. Incidentally, this is probably why your 2 day old question has so far received replies from 2 people, one person telling you it's in the wrong forum, and another person feeding you information that will destroy your applications performance.