issue with selection

I am having an issue with my simple selection of a box. Here is an illustration of my problem. The white box is where it is in my opengl screen, yet the yellow outline is where my hit is registered.
selection of box

Here is the code that I use to make the selection. Thank you anyone for your help

code for selection

I think your problem is in this lines:



it sould be:
5.0f, //here you can try a grater value - it’s the size of picking region in screen cords(pixels?)
5.0f, //here you can try a grater value also

also for
(GLfloat)(viewport[2]-viewport[0])/(GLfloat)(viewport[3]-viewport[1]),0.1f, 150.0f);

keep the same values used in your SizeOpenGLScreen function.

I think that OGL will report a hit when the mouse
is over the white rectangle, but not necessary when the mouse is in the CENTER of the rectangle.
Also you can play with gluPickMatrix’s 3rd and 4th parameters. By increaseing them the rectangle will be picked when the mouse is close to the rectangle, but does not touch it.

thank you, I put those values in for a reason for another program and just copied it into this one without really looking. Thanks again