Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更新OpenGL mipmapped纹理_Opengl_Opengl 4 - Fatal编程技术网

更新OpenGL mipmapped纹理

更新OpenGL mipmapped纹理,opengl,opengl-4,Opengl,Opengl 4,关于OpenGL中的纹理更新,有一点我无法完全理解。假设我使用mipmap创建OpenGL纹理,如下所示: ///.. tex gen and bind here .... /// glTexStorage2D(GL_TEXTURE_2D,numMipMapLevels,GL_RGBA8,imageInfo.Width,imageInfo.Height); glTexSubImage2D(GL_TEXTURE_2D,0,0,0,Width,Hei

关于OpenGL中的纹理更新,有一点我无法完全理解。假设我使用mipmap创建OpenGL纹理,如下所示:

        ///.. tex gen and bind here .... ///

        glTexStorage2D(GL_TEXTURE_2D,numMipMapLevels,GL_RGBA8,imageInfo.Width,imageInfo.Height);
        glTexSubImage2D(GL_TEXTURE_2D,0,0,0,Width,Height,GL_BGRA,GL_UNSIGNED_BYTE,data);
        glGenerateMipmap(GL_TEXTURE_2D);
现在是第一个问题: 这是否意味着,当我要更新此纹理(包括所有mipmap级别)时,是否必须在每个级别上循环并使用适当的mipmap维度和图像字节调用glTexSubImage2D?如果答案是肯定的,则我有:

第二个问题: 如何检索要传递到纹理的每个mipmap维度和数据

或者,我可以只进行更新:

 glTexSubImage2D(GL_TEXTURE_2D,0,0,0,Width,Height,GL_BGRA,GL_UNSIGNED_BYTE,data);
然后立即重新生成mipmap

    glGenerateMipmap(GL_TEXTURE_2D);
对第一个问题的答复 对

对第二个问题的答复 每个mipmap级别的宽度和高度正好是其上方mipmap级别的一半。因此,对于mipmap级别n,维度是w·2-n和h·2-n,其中w和h是级别0的大小


通过调用该位移位(
>
正常,每个mipmap的像素数据应“修剪”,可以轻松编程还是偏移?@MichaelIV:如果修剪是指下采样,那么是的。但是如果使用mipmapping,那么下采样过滤器应该比稀疏盒或线性采样要好得多,因为使用GL_NEAREST或GL_linear可以免费获得。为了获得最佳视觉质量,应该使用Lancosz(又称sinc)进行下采样从原始信号中筛选。@datenwolf您是否有任何截图比较使用或不使用OHUT sinc过滤器的视觉质量(在这两种情况下都使用GL_LINEAR_MIPMAP_LINEAR)。我只是在谷歌上搜索,没有找到任何截图