Results 1 to 3 of 3

Thread: gluPickMatrix

  1. #1
    Member Newbie
    Join Date
    Feb 2000
    Location
    Kingston, Ontario Canada
    Posts
    47

    gluPickMatrix

    I am trying to pick "named objects" using gluPickMatrix. Picking occurs but it does not (accurately) correspond to the shape of the named object that I have drawn -I get hits in some areas that I shouldn't and no hits in some areas that I should.

    I have completely redrawn the objects after calling gluPickMatrix (and have followed the sequence outlined in the red book p. 543).

    Why are my hits inaccurate?


    void CPick::PickObject(const CPoint &point)
    {
    m_pView->MakeRenderingContextCurrent();

    glLoadIdentity();

    // See "OpenGL Programming Guide 1.2" p. 543
    glGetIntegerv(GL_VIEWPORT, m_nViewPort);

    //Assign selection buffer
    glSelectBuffer(nSELECTION_BUFFER_SIZE, m_nSelectionBuffer);

    //Change into selection mode
    glRenderMode(GL_SELECT);

    glInitNames();

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();

    glLoadIdentity();

    gluPickMatrix( (double)( point.x), (double) (m_nViewPort[3]-point.y), dPIXEL_PICK_WIDTH_PIXELS, dPIXEL_PICK_HEIGHT_PIXELS, m_nViewPort);

    //Draw everything
    m_pView->GLDrawClean();

    glPopMatrix();
    glFlush();

    m_nHits = glRenderMode(GL_RENDER);


    //Release Windows Context
    wglMakeCurrent(NULL,NULL);

    //Call process hits
    Proces****s();

    //Invalidate the view
    m_pView->Invalidate(TRUE);
    }

  2. #2
    Member Contributor
    Join Date
    Mar 2000
    Location
    PA, USA
    Posts
    70

    Re: gluPickMatrix

    One thing you need to do before using the names stack is to put a zero (or some other name) onto the stack. You might be getting an underflow on the name stack.

    Also, I saw that you apply the gluPickMatrix to the projection matrix. Under non-selection mode, do you apply a different projection? If so, you should apply your usual projection after the pick matrix. You probably do this in your DrawClean function, but I thought I would mention it.

    Finally, try debugging this by turning off selection and drawing the scene with the gluPickMatrix. The net effect should be that your view is zoomed to the rectangle that you specified.

    Hope this helps
    -Ben

  3. #3
    Member Newbie
    Join Date
    Feb 2000
    Location
    Kingston, Ontario Canada
    Posts
    47

    Re: gluPickMatrix

    Thanks Ben. I didn't apply my original projection matrix after pick matrix. I'm going to give it a try now. Thanks again.

Similar Threads

  1. gluPickMatrix Implementation
    By chaikin in forum OpenGL: General
    Replies: 6
    Last Post: 06-09-2014, 05:10 PM
  2. Question about gluPickMatrix
    By ntraft in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-06-2009, 11:55 AM
  3. gluPickMatrix
    By devdept in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-21-2007, 03:06 PM
  4. gluPickMatrix
    By yaba in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 08-22-2002, 10:53 PM
  5. gluPickMatrix
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 09-23-2001, 11:30 PM

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