Jump to content
  • Advertisement
Sign in to follow this  
Dario Oliveri

OpenGL Query number of mipmap levels

This topic is 2441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!