Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7762981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:32:58+00:00 2026-06-01T14:32:58+00:00

I was certain that if you bind a buffer via glBindBuffer() , you can

  • 0

I was certain that if you bind a buffer via glBindBuffer(), you can safely assume that it stays bound, until the target is rebound through another call to glBindBuffer(). I was therefore quite surprised when I discovered that calling glBindVertexArray() sets the buffer bound to the GL_ELEMENT_ARRAY target to 0.

Here’s the minimal C++ sample code:

GLuint buff;
glGenBuffers(1, &buff);
std::cout << "Buffer is " << buff << "\n";
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buff);
GLuint vao;
glGenVertexArrays(1, &vao);

GLint bound_buff;
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &bound_buff);
std::cout << "Bound before glBindVertexArray: " << bound_buff << "\n";

glBindVertexArray(vao);    
  // ^- an implicit glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0); ?

glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &bound_buff);
std::cout << "Bound after glBindVertexArray: " << bound_buff << "\n";

I run this code immediately after initializing an OpenGL 3.2 device context and get the following output:

 Buffer is 1
 Bound before glBindVertexArray: 1
 Bound after glBindVertexArray: 0

The GL_ARRAY_BUFFER on the other hand is not changed by the call. I checked the OpenGL 3.2 spec (2.10) for glBindVertexArray and found no mention of that unexpected side effect.

  1. Is this behavior compliant with the Spec?
  2. If so, what other side effects can be expected from a call to glBindVertexArray?
  3. What is the rationale behind this?

I tested this on an nvidia card on a Win XPx64 machine with the 296.10 WHQL driver.
A quick test on OS X Lion with an nvidia GT330M gave the same results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:33:00+00:00Added an answer on June 1, 2026 at 2:33 pm

    Vertex Array Objects encapsulate all of the state* necessary to render vertex data. Therefore, they must encapsulate what buffers you associated with attributes (via glVertexAttribPointer), GL_ELEMENT_ARRAY_BUFFER (needed for glDrawElement* calls), and so forth.

    However, I still feel a little puzzled by the fact that I couldn’t find any mention of this side-effect in the docs.

    The specification clearly explains this, though it requires understanding how the spec works to see how.

    OpenGL is a collection of state, which means that all OpenGL functions (except those that actually render something) modify OpenGL state. When you call glVertexAttribPointer, this function conceptually modifies some piece of internal OpenGL state.

    OpenGL objects 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.

    The ARB_vertex_array_object 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):

    OpenGL 3.3 specification, section 2.10:

    The resulting vertex array object is a new state vector, comprising all the state values listed in tables 6.4 and 6.5.

    I’m not going to reprint tables 6.4 and 6.5; you can look them up yourself. But they clearly include GL_ELEMENT_ARRAY_BUFFER_BINDING and the various GL_VERTEX_ATTRIB_ARRAY_BUFFER_BIDNING (which are buffer objects).

    * Note: VAOs do not contain the state set by the glVertexAttrib functions. These can affect the rendering if an attribute array is not enabled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are certain conditions that can cause stack overflows on an x86 Linux system:
Can I have certain settings that are universal for all my users?
Is there a way to temporarily unbind event handlers that were bound via a
Suppose that it is only necessary to bind a value to a certain datamember
I've had a good look around and am certain that there's no matching question
I despise the PHP language, and I'm quite certain that I'm not alone. But
Systems demand that certain primitives be aligned to certain points within the memory (ints
Basically I’ve heard that certain conditions will cause .NET to blow past the finally
I often see people saying that certain software is very opinionated or that Microsoft
My current thinking: I need a certain module that will let me access the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.