Drawing for Picking

Sorry to post a beginner question here, but nobody in the other forum could solve my problem.

When I draw my objects with glRecti() picking with gluPickMatrix() works fine. But when I draw them with glBegin(GL_TRIANGLES)glVertex()…glEnd(), it seems like all the objects that are drawn are selected independently from where I click on the screen (slightly modified example 13-3 red book).

Why cant I pick the things drawn with glBegin()… correctly?
What does glRecti do that the the other drawing routine does not?

a small complete working example is posted in this thread: http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/007564.html

(only the function named process-Hits() got censored to proces****s())

thanks in advance


class Triangle{
Triangle( GLuint name, int pos ):m_name(name),m_pos(pos){}
void draw()const{
glLoadName (m_name);
glRecti (m_pos, m_pos, m_pos + 10, m_pos + 10); //works

/* glBegin(GL_POLYGON); //does not work
glVertex3f(9 + m_pos, 10,0);
glVertex3f(14 + m_pos,10,0);
glVertex3f(11 + m_pos,5,0);
GLuint m_name;
int m_pos;