Should I disable all attributes before deleting a vertex array object?

Hi,

I am currently writing c++ wrapper classes for all the commonly used OpenGl objects. At the moment I am working on the vertex array object class and I am asking myself about the correct way to deinitialize a VAO. Usually I just called glDeleteVertexArrays and thought this would be enough. Lately I just saw a tutorial where somebody calls glDisableVertexAttribArray before deleting the VAO. So my question is, is that really necessary?

I am asking because I want to avoid using heap memory to store all the active attributes (which aren’t necessarily in the range [0 … numActivatedAttribs-1]). Alternatively I can just store the number of active attributes and then query for each attribute number if it is enabled or not until I have found all of them. Would also be not optimal. Best thing would be if it is not necessary in the first place.

So my question is, is that really necessary?

No.

I am asking because I want to avoid using heap memory to store all the active attributes

Even if it were necessary, you could just disable all available attributes. That’s a well-defined number. No need to store anything or query anything.

[QUOTE=Alfonse Reinheart;1290900]No.

Even if it were necessary, you could just disable all available attributes. That’s a well-defined number. No need to store anything or query anything.[/QUOTE]

Thanks for your answer. So I will just skip that disabling ;). I know that the number is limited and I can query the number. I just wasn’t sure if every call to glDisableVertexArray causes some kind of synchronization overhead. Anyways, since there is no need for it, I don’t need to bother. Thanks again :slight_smile:

Just got another question, but don’t want to open a new thread for that:

I use direct state access in my small engine and for vertex array objects I use the following lines of code to enable an attribute:


    glEnableVertexArrayAttrib(mHandle, attributeIndex);
    glVertexArrayAttribFormat(mHandle, attributeIndex, numVertexValues, type, normalized, relOffset);
    glVertexArrayAttribBinding(mHandle, attributeIndex, bindingPoint);

So here is the thing. I get the relation between, binding points and attribute indices. The binding point applies the connection between a buffer and a vertex attribute by binding both to the same binding point. However, is there any occasion, where it does make sense to have a binding point that does use a different number than the attribute index? I am aware, that you can choose any combination as you like, but is there a practical use where it is beneficial to use different numbers?

First I thought I can link two attributes to the same binding point if they share the same buffer, but this does not work, because you can only bind one attribute to a binding point.

First I thought I can link two attributes to the same binding point if they share the same buffer, but this does not work, because you can only bind one attribute to a binding point.

What makes you think that?

Trying to do it, resulting in a white screen instead of seeing a triangle :stuck_out_tongue: - Works as long as I use different binding points. Maybe I did something wrong?

I’m not aware of any situation which requires the mapping between attribute indices and binding indices to be anything other than an identity mapping. However, if you want to change the data source for an attribute, changing the mapping between attributes and bindings may be simpler and/or cheaper than changing the mapping between bindings and buffers.

Thank you for your answer. If it is true what you are saying this might be a possible use case of different binding points and attribute indices. However, I don’t know how the binding works under the hood, but if it is just setting some pointers, there should not be any performance differences between binding an VAO to a binding point and binding a VBO to a binding point (except for memory access differences).