problem with picking

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

Hi !

It look’s pretty ok to me (after a quick browse), you said that you don’t get any hits “near” the points, does this mean that you do get hits somewhere ?

You do have the Y coodrinate correct (default OpenGL is 0,0 in lower left corner) the mouse coordinate is upper left corner. ?

Mikael

Thank you very much, I corrected my code just as you said and it works well. When I assume the x-y coordinates with its origin located in the center of the viewport and also modify the projection area like gluOrtho2D
(0,viewwidth,0,viewheight) it is fine too. So I wonder the relationship between the projection I use and the coordinates used in the glupickmatrix() function. Thanks Again.