2
\$\begingroup\$

So this is probably a simple question:

But how come sometimes I see it like this:

GLuint vbuffer;
glGenBuffers(1, &vbuffer);
glBindBuffer(GL_ARRAY_BUFFER, vbuffer);

but when done in multiples:

GLuint VBOs[2]
glGenBuffers(2, VBOs);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[0]);

Im curious why glGenBuffers has a & in the first one, and not in the second case. Is it because arrays are always passed by reference? and is vbuffer a POINTER to something or just a simple data structure (GLint in this case).

\$\endgroup\$
  • \$\begingroup\$ In C or C++, in this context, VBOs is short for &VBOs[0]. You could write &VBOs[0] if it confuses you. \$\endgroup\$ – user253751 Nov 5 '15 at 23:10
1
\$\begingroup\$

In C++ the deceleration of an array holds nothing more then a pointer/reference to the memory address where the first piece of data in that array is stored.

The subscript is simply used as offset to the address to read the following memory.

So yes basically an array deceleration is just a reference/pointer.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.