Skip to main content
GameDev.net gamedev.net
🔒 Locked

Query number of mipmap levels

Started by Dario Oliveri Mar 12, 2012 at 8:11 AM 2 replies 7.4k views
Original Post
Dario Oliveri
Dario Oliveri
I have a little problem. I want to know how many mipmap levels was generated using glGenerateMipmap().

So given the ID of a GL texture I want to ask it how many mipmap levels are present using opengl functionalities. thx
Peace and love, now I understand really what it means! Guardian Angels exist! Thanks!
Brother Bob
Brother Bob
It generates the mipmaps from the first after the base level down to the 1x1-texture, or the level defined by the GL_TEXTURE_MAX_LEVEL parameter. Thus, the number of additional mipmap levels it generates is n=min(floor(log[sub]2[/sub](size)), L[sub]max[/sub])-1, where size is the maximum dimension of the texture, and L[sub]max[/sub] is the value of the GL_TEXTURE_MAX_LEVEL parameter.

Since number of mipmaps that was generated depends on a parameter other than the texture ID, you cannot uniquely determine how many mipmaps it really generated from the texture ID alone. If you assume that the max level has not changed, you can query the size of the texture and calculate the number of mipmaps that was generated as n=floor(log[sub]2[/sub](size))-1.
Dario Oliveri
Dario Oliveri
so OpenGL has no function for query the number of mipmap levels? How can i know then if a texture mip pyramid was truncated by the user?
Peace and love, now I understand really what it means! Guardian Angels exist! Thanks!
Brother Bob
Brother Bob
No, there is no way to query the number of mimpaps in a texture as far as I remember. But since there is no way to remove individual mipmaps then there is no way to truncate the chain of mipmaps either. The only way to not have a full set of mipmaps down to the 1x1 texture though, is to limit the mipmap levels when creating the texture in the first place.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.