picking things with a mouse

whats wrong with this code? - its mostly is nehe’s

void SelectionL(void) // This Is Where Selection Is Done
{
GLuint buffer[512]; // Set Up A Selection Buffer
GLint hits; // The Number Of Objects That We Selected

// The Size Of The Viewport. [0] Is <x>, [1] Is <y>, [2] Is <length>, [3] Is <width>
GLint	viewport[4];

// This Sets The Array <viewport> To The Size And Location Of The Screen Relative To The Window
glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(1024, buffer);								// Tell OpenGL To Use Our Array For Selection

// Puts OpenGL In Selection Mode. Nothing Will Be Drawn.  Object ID's and Extents Are Stored In The Buffer.
(void) glRenderMode(GL_SELECT);

glInitNames();												// Initializes The Name Stack
glPushName(0);												// Push 0 (At Least One Entry) Onto The Stack

glMatrixMode(GL_PROJECTION);								// Selects The Projection Matrix
glPushMatrix();												// Push The Projection Matrix
glLoadIdentity();											// Resets The Matrix

// This Creates A Matrix That Will Zoom Up To A Small Portion Of The Screen, Where The Mouse Is.
gluPickMatrix((GLdouble) mouse_x, (GLdouble) (viewport[3]-mouse_y), 1.0f, 1.0f, viewport);

// Apply The Perspective Matrix

// gluPerspective(45.0f, (GLfloat) (viewport[2]-viewport[0])/(GLfloat) (viewport[3]-viewport[1]), 0.1f, 100.0f);
glOrtho(viewport[2]-viewport[0]-2,viewport[2]-viewport[0]+2,viewport[3]-viewport[1]-2,viewport[3]-viewport[1]+2,-10.0f,10.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix

DrawMenuButtons();												// Render The Targets To The Selection Buffer

glMatrixMode(GL_PROJECTION);								// Select The Projection Matrix
glPopMatrix();												// Pop The Projection Matrix
glMatrixMode(GL_MODELVIEW);									// Select The Modelview Matrix
hits=glRenderMode(GL_RENDER);								// Switch To Render Mode, Find Out How Many
															// Objects Were Drawn Where The Mouse Was
if (hits > 0)												// If There Were More Than 0 Hits
{
	PlaySound("data/shot.wav",NULL,SND_ASYNC);
	int	choose = buffer[3];									// Make Our Selection The First Object
	int depth = buffer[1];									// Store How Far Away It Is 

	for (int loop = 1; loop < hits; loop++)					// Loop Through All The Detected Hits
	{
		// If This Object Is Closer To Us Than The One We Have Selected
		if (buffer[loop*4+1] < GLuint(depth))
		{
			choose = buffer[loop*4+3];						// Select The Closer Object
			depth = buffer[loop*4+1];						// Store How Far Away It Is
		}       
	}

	/*if (!object[choose].hit)								// If The Object Hasn't Already Been Hit
	{
		object[choose].hit=TRUE;							// Mark The Object As Being Hit
		score+=1;											// Increase Score
		kills+=1;											// Increase Level Kills
		if (kills>level*5)									// New Level Yet?
		{
			miss=0;											// Misses Reset Back To Zero
			kills=0;										// Reset Level Kills
			level+=1;										// Increase Level
			if (level>30)									// Higher Than 30?
				level=30;									// Set Level To 30 (Are You A God?)
		}
	}*/
}

}

void DrawMenuButtons()
{

glLoadIdentity();
glEnable(GL_TEXTURE_2D);

for (int loop1=0; loop1<=7; loop1++)
{
	if(/*cliked*/0)
		glColor3f(1.0f,0,0);
	else glColor3f(1.0f,1.0f,1.0f);
		
	glEnable(GL_TEXTURE_2D);


	texture[loop1+2].Bind();
	glLoadName(loop1);

	glBegin(GL_QUADS);				
		glTexCoord2d(0,0);		glVertex2d(60,loop1*70);
		glTexCoord2d(1,0);		glVertex2d(260,loop1*70);
		glTexCoord2d(1,1);		glVertex2d(260,loop1*70+76);          
		glTexCoord2d(0,1);		glVertex2d(60,loop1*70+76);
	glEnd();
}
glPopMatrix();

}

[This message has been edited by bobertperry (edited 06-30-2001).]

[This message has been edited by bobertperry (edited 06-30-2001).]

Never mind i figured it out.