PDA

View Full Version : Drawing for Picking



Peter_1
03-01-2002, 10:36 PM
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
peter

Example:

class Triangle{
public:
Triangle( GLuint name, int pos ):m_name(name),m_pos(pos){}
void draw()const{
glColor3f(1,0,0);
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);
glEnd();
//glFlush();
*/
}
private:
GLuint m_name;
int m_pos;
};