简体   繁体   English

opengl glTexSubImage 纹理 arrays

[英]opengl glTexSubImage for texture arrays

For 1D and 2D Textures we have an single image and to get the image at an specific mipmap we can adjust the level parameter对于 1D 和 2D 纹理,我们只有一个图像,并且要在特定的 mipmap 上获取图像,我们可以调整 level 参数

But for 1D and 2D Arrays even though the docs specify that you can use these array flags as valid parameter they haven't told us how to use it to read images from an 1D and 2D array但是对于 1D 和 2D Arrays,即使文档指定您可以使用这些数组标志作为有效参数,他们也没有告诉我们如何使用它从 1D 和 2D 数组中读取图像

Let's say i specify an mipmap level of 5假设我将 mipmap 级别指定为 5

by using
glTexParameteri(GL_TEXTURE_1D_ARRAY,GL_TEXTURE_BASE_LEVEL,0);
glTexParameteri(GL_TEXTURE_1D_ARRAY,GL_TEXTURE_MAX_LEVEL,5);

and i auto generate the mipmaps using我使用自动生成 mipmap

glGenerateMipmap(GL_TEXTURE_1D_ARRAY);

and i have 5 1D images for my texture1D array which would give me 5 * 5 = 25 images[5 mip map levels for each image in the array]我的 texture1D 数组有 5 个 1D 图像,这将给我 5 * 5 = 25 个图像[数组中每个图像的 5 mip map 级别]

How do i read an image at an specific array Index & mipmap level using glGetTexImage()?如何使用 glGetTexImage() 读取特定数组索引和 mipmap 级别的图像? Lets say i want to read the 3rd mip map level for the 2nd image in the array how would i do that?假设我想读取阵列中第二个图像的第三个 mip map 级别,我该怎么做?

1D array textures are basically 2D textures, and 2d array textures are basically 3D textures when it comes to OpenGL API functions giving you x, y, z offsets and width, height, depth parameters.一维数组纹理基本上是二维纹理,二维数组纹理基本上是 3D 纹理当涉及到 OpenGL API 函数给你 x,深度偏移参数和高度,z

So, in order to access the fourth mip-level of the eighth array layer on a 1d array texture, starting at x-offset = 50 texels and reading a 800 texels wide row, you would use the following call:因此,为了访问一维数组纹理上第八个数组层的第四个 mip 级别,从 x-offset = 50 texels 开始并读取 800 texels 宽的行,您将使用以下调用:

glGetTextureSubImage(
 texture,
 3,  // <- we want the fourth mip-level
 50, // <- there, we want to start at x-offset = 50 texels
 7,  // <- we want the eighth array layer
 0,  // <- irrelevant for 1D array textures
 800,// <- we want to read 800 texels (starting from 50)
 1,  // <- we want 1 array layer
 1,  // <- must use 1
 format,
 type,
 bufSize,
 pixels)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM