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);
}
}
当我的程序涉及 glTexSubImage2D 时,我收到“访问冲突”错误。我究竟做错了什么?
我已将 GL_PIXEL_UNPACK_ALIGNMENT 设置为 1。虽然如果我尝试这个
auto pdata = new unsigned char[some.dataSize()];
memcpy(data,some.data(),some.dataSize())
然后将 pdata 传递给 glTexSubImage2D - 一切似乎都很好......