Results 1 to 3 of 3

Thread: Multiple glViewports and mouse interaction

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2005
    Posts
    4

    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.
    ramzy

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    569

    Re: Multiple glViewports and mouse interaction

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2005
    Posts
    4

    Re: Multiple glViewports and mouse interaction

    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,
    ramzy

Similar Threads

  1. strange mouse interaction
    By yoseph in forum OpenGL: Windows
    Replies: 0
    Last Post: 12-08-2007, 08:01 PM
  2. Opengl mouse interaction problem
    By Mirko in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-17-2006, 12:21 PM
  3. Mouse Interaction
    By legendkiller in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-15-2004, 09:56 AM
  4. Mouse Interaction
    By melmiligui in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-28-2002, 02:28 AM
  5. mouse interaction
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-28-2001, 05:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean