Reputation: 1198
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
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
Let's say i specify an mipmap level of 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
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]
How do i read an image at an specific array Index & mipmap level using glGetTexImage()? Lets say i want to read the 3rd mip map level for the 2nd image in the array how would i do that?
Upvotes: 0
Views: 440
Reputation: 5796
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.
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:
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)
Upvotes: 2