1

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.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Ray
  • 61
  • 4
  • You don't need a VAO to use `glDrawElements()`. – genpfault May 20 '21 at 03:15
  • @genpfault You mean the vertex array (glEnableClientState) ? The reason why I change the object from the glBegin/glEnd to VAO is that the object is too large. It takes a lot of time to draw the object in the old way. I have tried all the three ways to draw it: glBegin/glEnd, the vertex array, the VAO. The first two method can be picked successfully, but the rendering time is too long. The VAO method is very fast, but the object can not be picked by name stack. This is a contradiction... – Ray May 20 '21 at 06:46

1 Answers1

1

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.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • The selection mode impact the performance indeed. The object is drawn normally until the mouse is pressed and the scene is rendered in selection mode. Each time I click the mouse, there will be some laggings for a few seconds. That's why I change the object from glBegin/glEnd to VAO method. After that, the software can run fluently when I click the mouse. But when I click the VAO object, the hit record is always zero. Meanwhile, the other objects drawn by glBegin/glEnd can be picked normally. That's why I say that the name stack cannot pick the VAO object. Could you give me some advice? – Ray May 21 '21 at 01:22
  • @Ray: "*Could you give me some advice?*" You mean, besides "stop using selection"? – Nicol Bolas May 21 '21 at 06:49
  • Yeah...that's what I mean. I have already find a way to pick an object drawn by glBegin/glEnd and VAO. Thanks all the same! – Ray May 23 '21 at 08:14