LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: glBindBuffer -- a buffer named 0?  (Read 460 times)

Gojira

  • Newbie
  • *
  • Offline Offline
  • Posts: 22
glBindBuffer -- a buffer named 0?
« on: March 05, 2017, 16:13:27 »

I'm following this tutorial here:

https://lwjglgamedev.gitbooks.io/3d-game-development-with-lwjgl/content/chapter5/chapter5.html

In several places, the author passes a buffer name without obtaining it from glGenBuffers.  Like for example,

            glBindBuffer(GL_ARRAY_BUFFER, 0);

gets called in several places with the buffer name of 0 hard coded.  I've printed out the names of the buffers that are generated and those names are always an integer greater than 0, i.e., 1, 2, etc.

How does the author know to use buffer 0?  Is 0 some sort of scratch buffer that's always available?  As long as no other part of the code is using 0 concurrently then 0 is always available for general use?  Or am I missing some other concept here?

Logged

Kai

  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 925
Re: glBindBuffer -- a buffer named 0?
« Reply #1 on: March 05, 2017, 16:30:15 »

For questions regarding the behaviour and parameters of a GL function, the official reference documentation should always be the first to consult:
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindBuffer.xhtml
Quote
Buffer object names are unsigned integers. The value zero is reserved, but there is no default buffer object for each buffer object target. Instead, buffer set to zero effectively unbinds any buffer object previously bound, and restores client memory usage for that buffer object target (if supported for that target).
Logged

Gojira

  • Newbie
  • *
  • Offline Offline
  • Posts: 22
Re: glBindBuffer -- a buffer named 0?
« Reply #2 on: March 05, 2017, 17:09:03 »

OK, so that clears the bound buffer.  Thanks for pointing that out, I should have read that myself.
Logged