class classOne
{
ILuint id;
unsigned char* data()
{
ilBindImage(id);
return ilGetData();
}
}
class classTwo
{
void method(classOne& some)
{
(...)
glTexStorage2D(GL_TEXTURE_2D, 8, GL_RGB8, w, h);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_BGR, GL_UNSIGNED_BYTE, some.data());
glGenerateMipmap(GL_TEXTURE_2D);
}
}
I get an "access violation" error when my program comes to glTexSubImage2D. What am i doing wrong?
i've set GL_PIXEL_UNPACK_ALIGNMENT to 1. Though if I try this
auto pdata = new unsigned char[some.dataSize()];
memcpy(data,some.data(),some.dataSize())
and then pass pdata to glTexSubImage2D - everything seems to be okay...
It seems i've set incorrect image format - GL_RGBA8/GL_BGRA, while it must be GL_RGB8/GL_BGR as in my code sample. I've tricked myself.