Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Vertex Array Object question

  1. #1
    Intern Contributor
    Join Date
    Nov 2010

    Vertex Array Object question

    Hello again,

    I have a question about VAOs, how they work and what all they encapsulate. Like, you first create and bind a VAO, then make a bunch of calls to set the state, right? Like this:

    glGenVertexArraysOES(1, &_vertexArray);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
    glEnableVertexAttribArray(GLKVertexAttribPosition) ;
    glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(0));
    glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(12));
    glEnableVertexAttribArray(GLKVertexAttribTexCoord0 );
    glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(24));

    Then later you can just bind the VAO and it magically restores all those settings right?

    So my first question is, what if, while it is bound, you change one of those settings? Say I disable the normal attribute. Does that change become the new state of the VAO? Like, the next time I bind it, will the normal attribute be enabled like it was originally, or disabled?

    Second question -- do they store the active texture? Like, when I create and first bind my VAO, if I make these calls

    glBindTexture ( GL_TEXTURE_2D, texture ) ;
    glUniform1i(_textureUniform, 0);

    Which of these if any are stored as part of the 'state'? I am just unclear about what things are stored in the VAO and which things you need to do separately every time you change them.

    Also, what about the current shader program? Is that part of a VAO or set separately?


  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Quote Originally Posted by bsabiston View Post
    Then later you can just bind the VAO and it magically restores all those settings right?
    All the vertex array attribute bindings end enables, yes. Thus "vertex array object". And yes, if you modify the bindings while bound, it updates the VAO.

    Second question -- do they store the active texture?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts