View Full Version : Performing Color Picking when using Vertex arrays

07-22-2009, 04:02 AM
I'm using vertex arrays to draw a Mesh. Additionally I want to be able to select any triangle of the mesh.
Before switching to Vertex arrays I was painting each triangle of the mesh with a different colour and then using glReadPixels to pick a triangle.
By switching to vertex arrays, I tried to use a colour array but from what is see this approach paints individual vertices instead of the whole facet. This results in blended colour on the facet and incorrect picking. Changing to the shading model to GL_FLAT is also wrong.

Is there a way to colour the facets instead of the vertices while using vertex arrays?

Thank you.

07-22-2009, 05:12 AM
Flat shading can work for his, you just need to understand that the final vertex that completes each triangle is the one that determines the solid color.

07-22-2009, 02:14 PM
Indeed it worked (thank god I already kept a list with the facets each vertex participates in)!!! Although for some reason my Ray-Triangle intersection point seems little off...

Anyway, I thank you dorbie :)

10-08-2010, 12:06 AM
I have a related but more basic question:

Is Color picking the only method for picking objects when using Vertex Arrays/VBO?

Is there any way to adapt the Names Buffer method to use with VAs?

I have a general 3D Visualizer already implemented using Vertex Arrays. I need to add picking to it as efficiently as possible.