Part of the Khronos Group
OpenGL.org

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

Hybrid View

  1. #1
    Intern Newbie
    Join Date
    Nov 2010
    Posts
    40

    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);
    glBindVertexArrayOES(_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));
    glEnableVertexAttribArray(GLKVertexAttribNormal);
    glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(12));
    glEnableVertexAttribArray(GLKVertexAttribTexCoord0 );
    glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(24));
    glBindVertexArrayOES(0);



    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

    glActiveTexture(GL_TEXTURE0);
    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?

    Thanks!
    Bob

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,191
    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?
    No.

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
  •