Looking through the code I can see ....
template <typename T>
TexturePtr createTextureArray(const std::vector<typename T::ConstPtr> &textures, int mipmap_levels = 0)
{
static_assert(std::is_same<typename T::ComponentType, unsigned char>::value);
assert(!textures.empty());
assert(textures[0]);
const int texture_width = textures[0]->w();
const unsigned texture_size = texture_width * texture_width * T::BYTES_PER_PIXEL;
std::vector<const unsigned char*> texture_data(textures.size());
for (unsigned i = 0; i < textures.size(); i++)
{
assert(textures[i]);
assert(textures[i]->w() == texture_width);
assert(textures[i]->h() == texture_width);
assert(textures[i]->dataSize() == texture_size);
texture_data[i] = textures[i]->data();
}
return createTextureArray(texture_data, mipmap_levels, texture_width, T::BYTES_PER_PIXEL);
}
This code is throwing the assert.
Looking through the rest of the code (quickly) I can see on place I am worried about.
bool render_util::loadImageFromMemory(const std::vector<char> &data_in,
int num_channels,
std::vector<unsigned char> &data_out,
int &width,
int &height)
{
int actual_channels = 0;
unsigned char *image_data =
stbi_load_from_memory(reinterpret_cast<const unsigned char*>(data_in.data()),
data_in.size(),
&width,
&height,
&actual_channels,
num_channels);
if (image_data)
{
data_out.resize(width * height * num_channels);
memcpy(data_out.data(), image_data, data_out.size());
stbi_image_free(image_data);
image_data = 0;
return true;
}
else
{
std::cout << "error loading image: " << stbi_failure_reason() << std::endl;
return false;
}
}
You can see that you are using the variable num_channels to create the output array, and ignoring the variable actual_channels which is read from the image.
So if num_channels is not equal to actual_channels, you are going to have a problem.