Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://www.opengl.org/wiki/Vertex_Array_Object">Vertex Array Objects</a> encapsulate all of the state* necessary to render vertex data. Therefore, they must encapsulate what buffers you associated with attributes (via <code>glVertexAttribPointer</code>), GL_ELEMENT_ARRAY_BUFFER (needed for <code>glDrawElement*</code> calls), and so forth.</p> <blockquote> <p>However, I still feel a little puzzled by the fact that I couldn't find any mention of this side-effect in the docs.</p> </blockquote> <p>The specification clearly explains this, though it requires understanding how the spec works to see how.</p> <p>OpenGL is a collection of state, which means that all OpenGL functions (except those that actually render something) modify OpenGL state. When you call <code>glVertexAttribPointer</code>, this function conceptually modifies some piece of internal OpenGL state.</p> <p><a href="http://www.opengl.org/wiki/OpenGL_Object">OpenGL objects</a> are defined by which pieces of OpenGL state they encapsulate. Thus, if a function modifies the state encapsulated by an object, then that function modifies the object itself. Binding an object means replacing the current pieces of state that they encapsulate with the current state of that object.</p> <p>The <a href="http://www.opengl.org/registry/specs/ARB/vertex_array_object.txt">ARB_vertex_array_object</a> specification defines VAOs based on what state they encapsulate. It basically points at one of the OpenGL state tables and says, "VAOs are all of that." The core 3.x version of this functionality actually modifies the state tables to make it a bit more clear (same behavior, slightly different explanation thereof):</p> <blockquote> <p><strong>OpenGL 3.3 specification, section 2.10:</strong></p> <p>The resulting vertex array object is a new state vector, comprising all the state values listed in tables 6.4 and 6.5.</p> </blockquote> <p>I'm not going to reprint tables 6.4 and 6.5; you can look them up yourself. But they clearly include <code>GL_ELEMENT_ARRAY_BUFFER_BINDING</code> and the various <code>GL_VERTEX_ATTRIB_ARRAY_BUFFER_BIDNING</code> (which are buffer objects).</p> <p>* Note: VAOs do not contain the state set by the <a href="http://www.opengl.org/wiki/GLAPI/glVertexAttrib"><code>glVertexAttrib</code></a> functions. These can affect the rendering if an attribute array is not enabled.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload