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);
}