Is there any way to do this in a condensed form?
GLfloat coordinates[8];
...
coordinates[0] = 1.0f;
coordinates[1] = 0.0f;
coordinates[2] = 1.0f;
coordinates[3] = 1.0f;
coordinates[4] = 0.0f;
coordinates[5] = 1.0f;
coordinates[6] = 0.0f;
coordinates[7] = 0.0f;
return coordinates;
Something like coordinates = {1.0f, ...};
?
If you really to assign values (as opposed to initialize), you can do it like this:
The old-school way:
If you are doing these same assignments a lot in your program and want a shortcut, the most straightforward solution might be to just add a function
and then simply call
Exactly, you nearly got it:
You can use:
but this is a compile-time initialisation - you can't use that method in the current standard to re-initialise (although I think there are ways to do it in the upcoming standard, which may not immediately help you).
The other two ways that spring to mind are to blat the contents if they're fixed:
or provide a function that looks like your initialisation code anyway:
keeping in mind those ellipses (
...
) are placeholders, not things to literally insert in the code.