Just Curious, How Many Mipmaps does glGenerateMipmap generate?

Hi Folks:

This texture lesson says glGenerateMipmap “will automatically generate all the required mipmaps for the currently bound texture.”

How many mipmaps does it generate?

  Thanks
  Larry

Just search for this API in the latest OpenGL spec (minus the “gl” prefix) at http://www.opengl.org/registry:

In it, you’ll find:

For details on how level[SUB]base[/SUB] and q are defined, see the spec.

To save you from having to rummage around the specification (§8.14.3):

maxsize =max(w[sub]s[/sub],h[sub]s[/sub],d[sub]s[/sub])
p = floor(log[sub]2/sub) + level[sub]base[/sub]
q = min(p,level[sub]max[/sub])

where level[sub]base[/sub] is the value of GL_TEXTURE_BASE_LEVEL, level[sub]max[/sub] is the value of GL_TEXTURE_MAX_LEVEL, and w[sub]s[/sub], h[sub]s[/sub] and d[sub]s[/sub] are the width, height and depth of the base level.

IOW, it generates all the levels from the one above the base level (i.e. the half-size level) up to either the 1x1x1 level or the configured maximum level, whichever is lower.