glGenerateMipmap
3G

# glGenerateMipmap

generate a complete set of mipmaps for a texture object

## C Specification

    		void glGenerateMipmap
    		GLenum target

## Parameters

`target`

  Specifies the texture target of the active texture unit to which the texture object is bound whose mipmaps will be generated. Must be one of the following symbolic constants: `GL_TEXTURE_2D` or `GL_TEXTURE_CUBE_MAP`.

## Description

`glGenerateMipmap` computes a complete set of mipmap arrays derived from the zero level array. Array levels up to and including the 1x1 dimension texture image are replaced with the derived arrays, regardless of previous contents. The zero level texture image is left unchanged.

The internal formats of the derived mipmap arrays all match those of the zero level texture image. The dimensions of the derived arrays are computed by halving the width and height of the zero level texture image, then in turn halving the dimensions of each array level until the 1x1 dimension texture image is reached.

The contents of the derived arrays are computed by repeated filtered reduction of the zero level array. No particular filter algorithm is required, though a box filter is recommended. glHint may be called to express a preference for speed or quality of filtering.

## Errors

`GL_INVALID_ENUM` is generated if `target` is not `GL_TEXTURE_2D` or `GL_TEXTURE_CUBE_MAP`.

`GL_INVALID_OPERATION` is generated if the texture bound to `target` is a cube map, but its six faces do not share indentical widths, heights, formats, and types.

`GL_INVALID_OPERATION` is generated if either the width or height of the zero level array is not a power of two.

`GL_INVALID_OPERATION` is generated if the zero level array is stored in a compressed internal format.

## See Also

glBindTexture, glFramebufferTexture2D, glHint, glTexImage2D, glTexParameter

## Copyright

Copyright 2008 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.