I am just studing the picking mechanism in opgl now. After reading the redbook and studing the sample codes in it I still don’t know why should we use a projection after glupickmatrix(). In my code (I use this code to pick some points and lines drawn on the screen) I used projection like this
glOrtho(-viewwidth,viewwidth,
-viewheight,viewheight,
nearplane,farplane)
when I render the origin scene.I also used this after glupickmatrix() function when I enter the pick mode,but when I click near the targets no hit occurs. The following is my mouse function:
glSelectBuffer(50,SelectBuf);
glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix (x,y,10.0,10.0,Viewport);
glOrtho(0,viewwidth,0,viewheight,fNearPlane,fFarPlane);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glRotatef (RotateDegree,0.0,0.0,1.0);
DrawTemplate(GL_SELECT,m_Pathline);
glPopMatrix();
glMatrixMode(GL_PROJECTION); glPopMatrix();
// Somebody can tell me what’s wrong? Thanks1