Results 1 to 2 of 2

Thread: Vertex Array Object question

  1. #1
    Member Contributor
    Join Date
    May 2010
    Posts
    66

    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
    Join Date
    Oct 2004
    Posts
    4,654
    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.

Similar Threads

  1. Vertex array object
    By gwartney in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-24-2016, 03:51 AM
  2. Vertex Array Object and vertex buffer object
    By Xxacero in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-23-2015, 05:13 AM
  3. Vertex Array Object vs. Vertex Buffer Object
    By michaelglaz in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-26-2014, 02:52 PM
  4. Vertex Array Object Question
    By bug343 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-25-2013, 08:52 AM
  5. vertex array object question
    By _arts_ in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 02-04-2011, 04:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean