7

How can I get the name of the currently bound Vertex Array Object?

I looked in the manual but couldn't find an enum to use with glGet().

Justin Meiners
  • 9,345
  • 6
  • 44
  • 90
bwroga
  • 4,711
  • 2
  • 20
  • 25
  • What are you trying to do? Normally you would bind it yourself in order to draw it. Why can't you just store it when you do that? – Andreas Haferburg Jun 05 '13 at 21:46
  • 2
    @AndreasHaferburg I want to bind a VAO, but after I'm done using it, I want to rebind the VAO that was bound before. – bwroga Jun 05 '13 at 21:49
  • I would suggest using a stack instead. But I'm still not sure why you need that. Assuming you call a function where you do something with a temporary VAO, can't you just bind the original VAO when the function returns (i.e. use the call stack as your VAO stack)? – Andreas Haferburg Jun 05 '13 at 22:03
  • 4
    @AndreasHaferburg: That's very fragile. It puts the onus on the caller to keep global state safe. This way, it is each function's responsibility to maintain the integrity of the global state. If it changes some global state, that function is the best to know, and therefore that function should repair it. According to some design ideals, at any rate. – Nicol Bolas Jun 05 '13 at 22:12

1 Answers1

11

Try glGetIntegerv() with GL_VERTEX_ARRAY_BINDING.

See page 652 ("Table 23.8. Vertex Array Data (not in Vertex Array objects)") in the OpenGL 4.3 spec.

If you haven't spec-dived before note they omit the gl prefix from functions and the GL_ prefix from enums.

genpfault
  • 47,669
  • 9
  • 68
  • 119