Sorry, I like a little organization in my code:
#include <vector>
// Not a very good idea in C++, but ok for this example
#define X_RES 800
#define Y_RES 600
/////////////////////////////////
// Store a RGB structure so you don’t have to
// “think” about where you are in the array.
typedef struct {
float r;
float g;
float b;
} RGB;
int main()
{
std::vector<RGB> rgbArray;
rgbArray.resize(X_RES * Y_RES);
// do something cool… but now, you
// can index the array with meaning!
// rgbArray[0].r = some red value for the first pixel;
// rgbArray[0].g = some green value for the first pixel;
// rgbArray[0].b = some blue value for the first pixel;
rgbArray.resize( 0 );
return 0;
}
-M