How to get the currently bound Vertex Array Object?
Asked Answered
E

1

8

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().

Equate answered 5/6, 2013 at 21:32 Comment(4)
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?Clap
@AndreasHaferburg I want to bind a VAO, but after I'm done using it, I want to rebind the VAO that was bound before.Equate
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)?Clap
@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.Armorer
C
13

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.

Conversant answered 5/6, 2013 at 21:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.