glBindBuffer -- a buffer named 0?

Started by Gojira, March 05, 2017, 16:13:27

Previous topic - Next topic

Gojira

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?


Kai

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
QuoteBuffer 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).

Gojira

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