I am learning OpenGL from this tutorial. My question is about the specification in general, not about a specific function or topic. When seeing code like the following:
Binding a buffer to a target is something like setting a global variable. Subsequent function calls then operate on that global data. In the case of OpenGL all the "global variables" together form a GL context. Virtually all GL functions read from that context or modify it in some way.
The glGenBuffers()
call is sort of like malloc()
, allocating a buffer; we set a global to point to it with glBindBuffer()
; we call a function that operates on that global (glBufferData()
) and then we set the global to NULL
so it won't inadvertently operate on that buffer again using glBindBuffer()
.