You are creating a vector of pointers to unsigned char (std::vector<unsigned char*>
, but what you want is just a vector to unsigned char (std::vector<unsigned char>
).
And in the call to SOIL_save_image
you don't have to give it rgbdata[0]
, which would be a single unsigned char (and with your incorrect vector type an uninitialized pointer, likely resulting in some memory access error), but a pointer to the complete data and thus rgbdata.data()
(or &rgbdata[0]
if you don't have C++11).