View Full Version : Get mipmap levels of a texture?
Hollis
12-15-2011, 05:51 AM
Is it possible to get the amount of mipmaps a texture currently has?
V-man
12-15-2011, 07:55 AM
Perhaps glGetTexParameter(****, GL_TEXTURE_BASE_LEVEL, ****)
glGetTexParameter(****, GL_TEXTURE_MAX_LEVEL, ****)
thokra
12-15-2011, 10:32 AM
The spec says that for any non-rectangular texture(i.e. GL_TEXTURE_RECTANGLE etc.), the number of levels is equal to
num_levels = log_2(maxsize) + 1
where (for 2D tex, array, cube and cube array)
maxsize = max(width, height)
Oddly enough, NVidia doesn't seem to honor the constraints of the spec when it comes to the actual computation of th ei-th level of a mipmap for NPOTs. It appears they take a NPOT texture and convert the 0-th level to a the POT where the dimensions are equal
level_1 = 2 ^ floor(log_2(min(width,height)))
From there, they proceed as usual for POT textures.
Hollis
12-16-2011, 01:49 AM
Perhaps glGetTexParameter(****, GL_TEXTURE_BASE_LEVEL, ****)
glGetTexParameter(****, GL_TEXTURE_MAX_LEVEL, ****)
Unfortunately max level seems to just return default or what you've previously set it to. I'm not sure what max level even affects.
It would still be great if I can get an absolute value back from opengl, for example after using glGenerateMipmaps, but I think I can solve my specific problem another way for now. Thanks.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.