【问题标题】:The max count of layers in QOpenGLFunctions and QOpenGLFunctions_4_3_CoreQOpenGLFunctions 和 QOpenGLFunctions_4_3_Core 中的最大层数
【发布时间】:2020-05-22 15:23:20
【问题描述】:

在我的程序中,如果使用 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 是 void* 存储纹理数据的地方):

for(int i=0;i<256;i++)
    {
        texture->setData(0,i,QOpenGLTexture::RGBA,QOpenGLTexture::UInt8,((const char*)((uint)mem_texture+offset)));
        offset+=0x900;
    }

结果很好。但是如果我使用这样的原始API:

    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);

我发现我最多只能使用128层纹理。这两种方法有什么区别?如何使用原始 OpenGL API 设置 256 层纹理?

【问题讨论】:

    标签: c++ qt opengl


    【解决方案1】:

    设置纹理线的z值时,我使用GL_BYTE,实际上我应该使用GL_UNSIGNED_BYTE。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-26
      • 2013-04-24
      相关资源
      最近更新 更多