# OpenGL Vertex Array Object + Direct State Access

This topic is 2133 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

As a disclaimer I am really not versed in OpenGL. I am trying to convert the following to use DSA:

glBindVertexArray(vao);

glBindBuffer(GL_ARRAY_BUFFER, vertex_attrib_buffers[0]);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);

glBindBuffer(GL_ARRAY_BUFFER, vertex_attrib_buffers[1]);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, NULL);

glBindBuffer(GL_ARRAY_BUFFER, vertex_attrib_buffers[2]);
glVertexAttribPointer(2, 3, GL_UNSIGNED_BYTE, GL_TRUE, 0, NULL);

glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);


I have found the following functions:

glVertexArrayBindVertexBufferEXT()
glVertexArrayVertexAttribBindingEXT()
glVertexArrayVertexAttribFormatEXT()
glEnableVertexArrayAttribEXT()


but I am unsure of how to use them. I can find almost nothing about them online.

Edited by Chris_F

##### Share on other sites

These are described in the actual DSA extension: http://www.opengl.org/registry/specs/EXT/direct_state_access.txt

You can get arguments and their names from that site.

If you are unsure, the usual approach is that whatever you call in a Bind function (BindVertexArray, BindTexture) becomes the first parameters of the DSA call. The other parameters are then the exact same parameters that you would use in a non-DSA function.

Also take a look at this: http://www.g-truc.net/post-0363.html

Keep in mind that when working with vertex array objects, there is one thing you cannot do with DSA and must use the old way: http://stackoverflow.com/questions/3776726/how-to-bind-a-element-buffer-array-to-vertex-array-object-using-direct-state-a

##### Share on other sites

These are described in the actual DSA extension: http://www.opengl.org/registry/specs/EXT/direct_state_access.txt

You can get arguments and their names from that site.

Yes, I read that. It is not complete. There is no mentioning at all of the first three functions I listed anywhere in that document.

##### Share on other sites

but I am unsure of how to use them.

Move back to VBO’s.

L. Spiro

##### Share on other sites

Keep in mind that when working with vertex array objects, there is one thing you cannot do with DSA and must use the old way: http://stackoverflow.com/questions/3776726/how-to-bind-a-element-buffer-array-to-vertex-array-object-using-direct-state-a

Wow, that is strange. I take it they accidentally left something like this out of the spec for some reason?

void glVertexArrayBindElementArrayBufferEXT(GLuint vao, GLuint buffer)


I guess it would be easy enough to implement on your own...

Move back to VBO’s.

OK, I'm confused now. I thought that VAOs were not optional in modern OpenGL. By "don't use VAOs," do you mean only use a single VAO and just keep modifying that one? Also, is it "vertex attribute object" or "vertex array object," or are those actually two distinct things?

Edited by Chris_F

##### Share on other sites

I'm confused as well.

I have 300 VBOs, give or take, that all have the same attributes. Hence why I chose VAOs because they remember my attribute bindings.

My reasoning is that I only end up with 2 calls to render something:

glBindVertexArray(vao);

glDraw...();

What is the correct course of action here?

Edited by Kaptein

##### Share on other sites

do you mean only use a single VAO and just keep modifying that one?

I definitely don’t mean that; that would be the worst-case scenario possible.

And they are not required as far as I know; the very fact that they appear in your list of functions as extensions means in any case you definitely are not strictly required to use them, and since they build on top of basic VBO functionality I doubt they will ever be strictly required.

Also, is it "vertex attribute object" or "vertex array object,"

Vertex Array Objects.

Hence why I chose VAOs because they remember my attribute bindings.

Or you could just set the attribute states once manually and render all of your VBO’s; that would be faster, especially if you are re-binding the VAO for each draw.

What is the correct course of action here?

Until VAO performance meets standards, the generally accepted course is to use raw VBO’s.
And if you emulate VAO functionality manually with a layer to remove redundant state changes (something you should be doing no matter what) a VAO will likely never be as fast as your manual setup calls.

L. Spiro Edited by L. Spiro

##### Share on other sites

I definitely don’t mean that; that would be the worst-case scenario possible.

And they are not required as far as I know;

I am even more confused now. Can you point me to an example of how to render with just VBOs and no VAO?

Edit: Are you talking about using functions like glVertexPointer in conjunction with VBOs? If so I should point out that all of that has been deprecated and is not even available in core profile as far as I know.

the very fact that they appear in your list of functions as extensions means in any case you definitely are not strictly required to use them, and since they build on top of basic VBO functionality I doubt they will ever be strictly required.

DSA is an extension, not VAOs. VAOs are core functionality.

Edited by Chris_F

##### Share on other sites
VAOs are certainly NOT a requirement for OpenGL... god, if it was, the horror... something you HAD to use with a bind-to-edit model... sweet jesus.

The commands you'd be after, based on the GL4.4 reference card, are those such as glVertexAttribPointer and friends ( http://www.opengl.org/wiki/Category:Core_API_Ref_Vertex_Arrays ) which allow you to setup buffer input via attributes on the shaders.

##### Share on other sites

VAOs are certainly NOT a requirement for OpenGL... god, if it was, the horror... something you HAD to use with a bind-to-edit model... sweet jesus.

The commands you'd be after, based on the GL4.4 reference card, are those such as glVertexAttribPointer and friends ( http://www.opengl.org/wiki/Category:Core_API_Ref_Vertex_Arrays ) which allow you to setup buffer input via attributes on the shaders.

Then how do you render in GL 3.3/4.x core profile without a VAO? I was under the impression that glVertexAttribPointer was only for VAOs.

EDIT: Just removed my VAO, bound my buffers, called glVertexAttribPointer and all I have is a black screen.

Edited by Chris_F

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 11
• 9
• 24
• 47