Though I've understood the state design of OpenGL enough to work with it, I've still struggled visualizing the inner workings on the CPU/GPU. Currently I'm stuck wondering how VBO's are copied onto the GPU using GL_ARRAY_BUFFER.
I previously understood the VBO's to be a 'state' of GL_ARRAY_BUFFER, this led me to 3 different options as to how that might work, shown below.
The top answer of the following thread explains: "The GL_ARRAY_BUFFER target for buffer objects represents the intent to use that buffer object for vertex attribute data" What does the GL_ARRAY_BUFFER target mean in glBindBuffer?
which, as I understand it, means that GL_ARRAY_BUFFER is sort of a 'state' of a VBO. It could have a different state, but it does require to have a state to be able to be copied onto 'the' GPU buffer/ a smaller allocated buffer on the GPU? Or am I misunderstanding it? does 'binding' mean something different from setting a state? (this 4th option is not visualized below).
Are any of these 4 ideas accurate? or is it something completely different? Apologies for the horrendous diagram. I hope it's clear enough though.
Any confirmation / correction would be greatly appreciated!
I also looked though this post What exactly is a VBO in OpenGL? which states
"Since you use GL_ARRAY_BUFFER here as the target parameter, this operation (glBufferData(...)) will affect the BO which is currently bound as GL_ARRAY_BUFFER.
After doing all that, the VBO now contains all the vertex data within.
Basically, yes."
this implies the VBO memory on the GPU is set through the GL_ARRAY_BUFFER, which is what I understood at first.
options 3 & 4 seem most logical to me. Could it be that VBO and GL_ARRAY_BUFFER are both states of eachother simultaneously, depending on the context?: which VBO is active / which target is active for the VBO
Frankly, it's not any of the options you listed. GL_ARRAY_BUFFER
is a client-side binding point that's used to name the active buffer that you operate on with other commands. It's used purely in communications with the driver. Furthermore, by means of DSA (direct state access, OpenGL 4.5+) you can fully set up a VBO without ever binding it to anything.
This is probably a better diagram to describe the situation:
Note the GL_ARRAY_BUFFER
binding point can be tracked either by the driver or the user-process libGL. It's really not essential.