GenerateMipMaps Method

Texture.GenerateMipMaps Method

Request generation of mipmap sublevels for a render target texture.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public void GenerateMipMaps (
         TextureFilter filterType


Determines how the texture will be filtered for each mipmap level.

Exception typeCondition
NotSupportedException GenerateMipMaps is not supported on Xbox 360.

This method is valid only if TextureUsage.AutoGenerateMipMap is set when calling the constructor for a render target texture. Setting this flag indicates that mip levels should be generated, but not when they should be generated. For this case, GenerateMipMaps hints to the driver that it should generate sublevels if it has not done so already.

Only the top texture level is accessible to the application, and as a result LevelCount will not be changed after a call to GenerateMipMaps. The texture sublevels are not accessible since the driver creates them only when needed.

In this example, a new Texture2D is created for use as a render target, the data is initialized with a call to ResolveBackBuffer, and the generation of mipmaps for the resolved render target is requested.

ResolveTexture2D renderTargetTexture;
    renderTargetTexture = new ResolveTexture2D(

    renderTargetTexture.GenerateMipMaps( TextureFilter.Linear );

Xbox 360, Windows XP SP2, Windows Vista

Community Additions

© 2015 Microsoft