在我的程序中,如果使用QOpenGLTexture,我可以像这样设置256层纹理:
texture= new QOpenGLTexture(QOpenGLTexture::Target2DArray);
texture->create();
texture->setSize(24,24);
texture->setLayers(256);
texture->setFormat(QOpenGLTexture::RGB8_UNorm);
texture->allocateStorage();并为每一层设置数据(mem_texture为空*其中存储纹理数据):
for(int i=0;i<256;i++)
{
texture->setData(0,i,QOpenGLTexture::RGBA,QOpenGLTexture::UInt8,((const char*)((uint)mem_texture+offset)));
offset+=0x900;
}如果我像这样使用原始接口,结果是good.But:
GLuint colorPattern;
glGenTextures(1, &colorPattern);
glBindTexture(GL_TEXTURE_2D_ARRAY, colorPattern);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGB8, 24, 24,256);
glTexSubImage3D(GL_TEXTURE_2D_ARRAY,0,0,0,0,24,24,256,GL_RGBA,GL_UNSIGNED_BYTE,mem_texture);
free(mem_texture);我发现我只能在most.What中使用128层纹理,这两种方法有什么不同?如何使用原OpenGL接口设置256层纹理?
发布于 2020-05-23 12:04:28
当设置纹理线的z值时,我使用GL_BYTE,实际上我应该使用GL_UNSIGNED_BYTE。
https://stackoverflow.com/questions/61958353
复制相似问题