Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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
)

Parameters

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(
        graphics.GraphicsDevice,
        graphics.GraphicsDevice.PresentationParameters.BackBufferWidth,
        graphics.GraphicsDevice.PresentationParameters.BackBufferHeight,
        1,
        graphics.GraphicsDevice.PresentationParameters.BackBufferFormat);

    graphics.GraphicsDevice.ResolveBackBuffer(renderTargetTexture);
    renderTargetTexture.GenerateMipMaps( TextureFilter.Linear );
Xbox 360, Windows XP SP2, Windows Vista
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.