In OpenGL, how to pick an object by name stack when I use the VAO to draw objects?

177 views Asked by At

I'm dealing with an old large project using fixed rendering pipeline, and the current project used the name stack to pick an object.

Now I need to change one object in the project to the VAO (glDrawElements...) mode, while the other objects remain to draw by glBegin/glEnd. As a result, the original picking mechanism cannot pick the VAO object anymore.

Now I'm wondering whether the name stack method can be used to pick an VAO object? If not, how to pick it without disturbing the rendering and selection of other objects.

1

There are 1 answers

3
Nicol Bolas On

I don't see anything in the compatibility profile of the OpenGL specification that prevents selection from working in the presence of arrays pulled from buffers. So it should just work.

Obviously, performance will be impacted. Also, rendering time "is too long" because you're using selection mode, not because glBegin/End are too slow. They're not fast, but selection mode kills all hope of performance regardless of how you render. So using buffers and a VAO isn't going to help (and will probably hurt).

It'd be better to just not use selection mode to render.