Number of texture object LOD

I know how to calculate texture object LOD (number of mipmaps) according the size of the base texture, but does GL allow to get the number of LOD of the current texture object through a simply function call ?

Sorry, but what is wrong with my question unless it’s caused by my poor english?

Originally posted by Sancho:
I know how to calculate texture object LOD (number of mipmaps) according the size of the base texture, but does GL allow to get the number of LOD of the current texture object through a simply function call ?

I don’t remember well but you should take a look in the OpenglSpecs 1.2.1 under texturing/mipmaping section (it’s something like glGetIntegeri(GL_MAX_LOD…)

If you know the texture object ID, what prevents you from storing this in a small structure which contains the size of the LOD 0 and thereby the number of LODs?

Well, you could also call void glGetTexLevelParameterfv with GL_TEXTURE_WIDTH and _HEIGHT.

My goal was to write a getMemoryLoad() method which return the size (in octet) of resident textures without storing any structure to maintain datas. So i would like to know for each texture bind, if more than one level of texture have been load (i.e. mipmaps have been generated).
I wrote something like this:

int getMemoryLoad()
{

int lId = 1;
int lTotal = 0;
int lLevel;

while
(glIsTexture(lId))
{
lId++;
glBindTexture(GL_TEXTURE_2D, lID);

// Get image size of the base texture

// What i want to know:
glGetInteger(GL_MAX_LEVEL_…???, &lLevel);

if
(lLevel > 0)
{
// I know that mipmaps have been generated
// so, calcul the amount of used memory
// according to the image size

}

}

That won’t work reliably. The only thing you can calculate is how many texture data you provided from user’s side.
You don’t know the memory requirements of textures on different implementations. That is, after the glTexImage call you don’t know how big the texture is in onboard or AGP or PCI or system memory and how many copies are held for what purpose.