Results 1 to 5 of 5

Thread: Do I have to call glDisableVertexAttribArray?

  1. #1
    Member Newbie
    Join Date
    Dec 2010
    Posts
    40

    Do I have to call glDisableVertexAttribArray?

    I found a page somewhere that was saying that I have to call glDisableVertexAttribArray when I call glEnableVertexAttribArray. However I couldn't find that much about that, not even in the specification (I'm talking about OpenGL 3.3). So I'm not sure of how things are supposed to work.
    In general it makes kind of sense, since I couldn't find a meaning for this method.

    Actually, making the question a bit more generic: why do I have to enable and disable vertex attribute arrays in the first place?

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,673

    Re: Do I have to call glDisableVertexAttribArray?

    why do I have to enable and disable vertex attribute arrays in the first place?
    In order to tell OpenGL which attribute arrays are valid and which are not.

    Remember: OpenGL is a state machine. When you call glVertexAttribPointer, that basically sets fields in a struct. And state always has a value. There's no way to call glVertexAttribPointer and say, "This attribute doesn't matter anymore; don't use it."

    That's what the enable/disable calls are for. To tell OpenGL whether or not it should use the state for that attribute.

  3. #3
    Member Newbie
    Join Date
    Dec 2010
    Posts
    40

    Re: Do I have to call glDisableVertexAttribArray?

    I have been waiting online for an answer. I knew it would come soon . Thanks a lot Alfonse.
    OopenGL documentation is a bit difficult sometimes, but this forum is awesome.

    now, back on topic.

    Quote Originally Posted by Alfonse Reinheart
    why do I have to enable and disable vertex attribute arrays in the first place?
    In order to tell OpenGL which attribute arrays are valid and which are not.

    Remember: OpenGL is a state machine. When you call glVertexAttribPointer, that basically sets fields in a struct. And state always has a value. There's no way to call glVertexAttribPointer and say, "This attribute doesn't matter anymore; don't use it."

    That's what the enable/disable calls are for. To tell OpenGL whether or not it should use the state for that attribute.
    But don't I say that with glBindAttribLocation? With that I tell a program where to find the attribute I prepared with glVertexAttribPointer, and the various operations before that used to prepare the buffer,
    If I bind an attribute array to a variable, which will be used by a program, I automatically tell the program that it can use that attribute array.

    I must be missing something.

  4. #4
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,673

    Re: Do I have to call glDisableVertexAttribArray?

    But don't I say that with glBindAttribLocation?
    That tells OpenGL which attributes your shader uses. What the shader uses and what attributes you provide with arrays do not have to agree. If your attribute arrays don't provide an attribute (ie: it is disabled), then the value comes from a default value (set with glVertexAttrib* calls).

  5. #5
    Member Newbie
    Join Date
    Dec 2010
    Posts
    40

    Re: Do I have to call glDisableVertexAttribArray?

    Got it. So that also means that I don't necessarily have to call glDisableVertexAttribArray, unless I want the default value to be used. Correct?

Similar Threads

  1. glDisableVertexAttribArray not working?
    By RedPuma in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 03-14-2012, 07:48 AM
  2. glEnableVertexAttribArray - when to call?
    By PeTeAR in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-08-2011, 02:26 PM
  3. Replies: 0
    Last Post: 07-23-2009, 05:50 AM
  4. When a call is really a redundant call...
    By scratt in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 01-30-2009, 10:11 AM
  5. Link Call
    By BwB in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 03-28-2001, 07:07 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