PDA

View Full Version : Number of texture object LOD



Sancho
03-23-2001, 08:42 AM
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 ?

Sancho
03-25-2001, 11:52 PM
Sorry, but what is wrong with my question unless it's caused by my poor english?

andreiga
03-26-2001, 01:13 AM
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....)

Relic
03-26-2001, 02:11 AM
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. http://www.opengl.org/discussion_boards/ubb/wink.gif

Sancho
03-26-2001, 02:47 AM
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
...
}
...
}

Relic
03-26-2001, 06:50 AM
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.