mouse picking

Thanks to everybody for all the help I have been given with this forum. I have come along way, but there are still areas I am in need of help.

I have an image I am rendering using Display Lists or the classic glBegin() … glEnd() that consists of sets of Triangles. I would like to allow the user to select a vertex with the mouse (for latter manipulation).
Being a newbie, I have to ask (even though I think the answer is no), can I use Display Lists for mouse picking (i.e., chosing a vertex in the currently displayed image) and if so, how (simple code, hints, link to info)?

If I can’t use Display Lists for mouse picking what is the simplest way to pick a vertex in a displayed image (using immediate mode rendering such as glBegin() … glEnd() for basic Triangular or Quadrilateral Shapes)?

Thanks in advance.

As far as I’m concerned, most vertex selection algorithms work entirely on CPU without any use of OpenGL. Some vector/matrix math and you’re done.

If you need simplicity then render all your vertices using GL_POINTS in GL_FEEDBACK mode. Put a token before each vertex so you can identify it later.
Now search the feedback buffer and see which vertices ended up nearby mouse pointer.

If you need to select entire polygons/objects then you’ll need GL_SELECTION mode.

Thank you k_szczech for the information.

Being a newbie, I would like to go for simplicity at this point. I only need to select a vertex, so I will try and use the GL_POINTS in GL_FEEDBACK mode. Does this mean that I can use Display Lists for this method (I appologize ahead of time if this is an ignorant question) or does only immediate mode rendering work for this?

It should work, no matter if you use display lists, immediate mode or vertex arrays.
The feedback mode works exactly the same way that normal rendering does, but instead of drawing polygons it returns all vertices of polygons that would be rendered (returned values are in viewport coordinates).

Thanks k_szczech.
Do you know of a simple example using mouse picking and Display Lists that you can direct me to?

Once again, thank you for all your help.

Why don’t you google for one?
As for feedback mode - read documentation for glRenderMode, glFeedbackBuffer and glPassThrough functions - these are only three you need.
Pay attention to available formats of returned data. When rendering points everything will be quite simple.
As for display lists - you can use them to store objects that are rendered so you should follow this scheme:

GLuint selectList;
glGenLists(1, &selectList);
glNewList(selectList, GL_COMPILE);
for (int i = 0; i < vertexCount; i++)


int dataSize = glRenderMode(GL_RENDER);

I believe that’s all you need.

THANKS - that is exactly what I needed.