Indeed. The vector is fine with OpenGL.
you can declare an array without specifying the size,
int arr[] = {1, 2}; |
Note, technically you do specify the exact size in that statement, even though you don't write a verbatim number. The size is implicit in the initializer; easy for compiler to count and use.
Note 2: There is no array in:
void foo( float arr[] );
The above declaration is an alias syntax for:
void foo( float* arr );
The rationale is that you don't want to make a copy of an array. The language does not support that anyway.
The std::vector does know how to copy itself. Passing by reference avoids that performance penalty.
OpenGL, it does not take vectors as paremeters, it wants arrays |
Now it should be obvious that OpenGL does not take "arrays"; it takes pointers and I bet that it takes the "size" (might be called "element count") as an additional parameter.
Note 3: Even if one has an array by reference parameter:
void foo( float (&arr)[18] );
then one still does not "pass the size" into the function. The function has its "hardsized array" (reference) no matter what the callers have. The side-effect is that such function cannot be called with arbitrary array.