Sdílet prostřednictvím


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)

Syntax

public void GenerateMipMaps (
         TextureFilter filterType
)

Parameters

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

Exceptions

Exception type Condition
NotSupportedException GenerateMipMaps is not supported on Xbox 360.

Remarks

This method is valid only if ResourceUsage.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.

Example

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.

Texture2D renderTargetTexture;

renderTargetTexture = new Texture2D(
    graphics.GraphicsDevice, 
    graphics.GraphicsDevice.PresentationParameters.BackBufferWidth,
    graphics.GraphicsDevice.PresentationParameters.BackBufferHeight, 
    0, 
    ResourceUsage.ResolveTarget | ResourceUsage.AutoGenerateMipMap, 
    graphics.GraphicsDevice.PresentationParameters.BackBufferFormat,
    ResourceManagementMode.Manual 
    );

graphics.GraphicsDevice.ResolveBackBuffer( renderTargetTexture );
renderTargetTexture.GenerateMipMaps( TextureFilter.Linear );

See Also

Reference

Texture Class
Texture Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista