Urgent : Problems in picking

hey guys,

I have a problem in picking. I read the tutorials at lighthouse website and i did exactly what they had taught. Well heres my code :

My renderScene code :

GLvoid RenderScene()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;	
	glLoadIdentity() ;
	
	gluLookAt(CameraObj.mPosition.x , CameraObj.mPosition.y , CameraObj.mPosition.z ,
		CameraObj.mView.x , CameraObj.mView.y , CameraObj.mView.z ,
		CameraObj.mUp.x , CameraObj.mUp.y , CameraObj.mUp.z) ;
	

	//Draw the x , y , z Axis and the grid initially.
	DrawAxis() ;
	Draw3DGrid() ;

	DrawGrid(GL_RENDER) ;	

	glScalef(0.030f , 0.030f , 0.030f) ;

	glRotatef(180.0 , 0.0f , 1.0f , 0.0f) ;
	
	DrawObject() ;

	glFlush() ;

	glutSwapBuffers() ;
}

Heres my DrawGrid code. This is made of points which I must pick…

GLvoid DrawGrid(int mode)
{
	if(mode == GL_SELECT)
	{
      glInitNames();
      //glPushName(0);
	}
	
	int i , j ;
	glDisable(GL_LIGHTING) ;
	glPointSize(6.0f) ;
	

	//Draw the line segments
	glColor3f(1.0f , 1.0f , 0.0f) ;
	for(i = 0 ; i < 8 ; i++)
	{
		for(j = 0 ; j < 8 ; j++)
		{
			glBegin(GL_LINE_STRIP) ;
			
			glVertex3f(ControlPoints[i][j][0] , ControlPoints[i][j][1] , ControlPoints[i][j][2]) ;
			glVertex3f(ControlPoints[i + 1][j][0] , ControlPoints[i + 1][j][1] , ControlPoints[i + 1][j][2]) ;
			glVertex3f(ControlPoints[i + 1][j + 1][0] , ControlPoints[i + 1][j + 1][1] , ControlPoints[i + 1][j + 1][2]) ;
			glVertex3f(ControlPoints[i][j + 1][0] , ControlPoints[i][j + 1][1] , ControlPoints[i][j + 1][2]) ;
			glVertex3f(ControlPoints[i][j][0] , ControlPoints[i][j][1] , ControlPoints[i][j][2]) ;
			glEnd() ; 

		}
	}

	//Draw the control vertices.
	glColor3f(0.0f , 1.0f , 0.0f) ;
	
	int k = 1 ;
	for(i = 0 ; i < 10 ; i++)
	{
		if(mode == GL_SELECT)
			glPushName(i) ;

		for(j = 0 ; j < 10 ; j++)
		{
		  if(mode == GL_SELECT)
			glPushName(j);
		
		    glBegin(GL_POINTS) ;
			glVertex3f(ControlPoints[i][j][0] , ControlPoints[i][j][1] , ControlPoints[i][j][2]) ;
			glEnd() ; 

			glPopName() ;
		}
		glPopName() ;
	}
	

	glLineWidth(1.0f) ;
	glEnable(GL_LIGHTING) ;

}

and heres the code to initialize the selection mode:

GLvoid MouseFunc(int Button , int State , int x , int y)
{
	int Viewport[4] , Hits ;

	if(Button == GLUT_LEFT_BUTTON && State == GLUT_DOWN)
	{
		glGetIntegerv(GL_VIEWPORT , Viewport) ;
		
		glSelectBuffer(512 , ObjectList) ;
		
		glRenderMode(GL_SELECT) ;

		//Enter the projection mode, save the matrix and then load the identity.
		glMatrixMode(GL_PROJECTION) ;
		
		glPushMatrix() ;

		glLoadIdentity() ;

		gluPickMatrix((GLdouble)x , (GLdouble)(Viewport[3] - y) , 4 , 4 , Viewport) ;
		glOrtho(-6.0f , 6.0f , -6.0f , 6.0f , -400.0f , 400.0f) ;
		
		glMatrixMode(GL_MODELVIEW) ;

		DrawGrid(GL_SELECT) ;

		//After drawing , pop back the projection matrix and reset to the modelview matrix.
		glMatrixMode(GL_PROJECTION) ;
		glPopMatrix() ;
		glMatrixMode(GL_MODELVIEW) ;
		glFlush() ;

		Hits = glRenderMode(GL_RENDER) ;
		processHits(Hits , ObjectList) ;
		glutPostRedisplay() ;
	}
}

I cant figure out whats wrong…everytime i click on a vertex i get that the no. of hits is zero.

Plz plz help me out…

Thanx

Yours

Siddharth`

And hey another thing is , I tried to debug it by not changing the viewing voluma after gluPickMatrix(), just to see what is being rendered. The particular vertex is being rendered within the scene but i have a doubt. I have kept my point size as 4 and my viewing volume also as 4 by 4. I see that even in a smaller viewing volume, the point size is the same as it were in a bigger viewing volume. Is this supposed to happen or shoudl the point fill up the entire space in the smaller viewing volume?

I still cant figure out why the vertices are not getting a hit record as they definitely fall within the smaller viewing volume…

Plz help.

Yours

Siddharth