packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/UtilitiesLibrary/MeshLoader/Texturizer.cs
/// <summary>
/// Creates an alternate texture for a part
/// </summary>
/// <param name="partName">The name of the part to create the texture for.</param>
/// <param name="imagePath">The path to the image to be used for the texture.</param>
Creates an alternate texture for a part
Creates an alternate texture for a part
public void SwapTexture(string partName, string imagePath)
        {
            if (partName != null)
            {
                if (File.Exists(imagePath))
                {
                    FileStream stream = File.OpenRead(imagePath);
                    try
                    {
                        ShaderResourceView srv = TextureLoader.LoadTexture(this.manager.device, stream);
                        if (srv != null)
                            alternateTextures[partName] = srv;
                    }
                    catch (COMException)
                    {
                        System.Windows.MessageBox.Show("Not a valid image.");
                    }
                }
                else
                {
                    alternateTextures[partName] = null;
                }
            }
        }
public void SwapTexture ( string partName , string imagePath ) { if ( partName != null ) { if ( File . Exists ( imagePath ) ) { FileStream stream = File . OpenRead ( imagePath ) ; try { ShaderResourceView srv = TextureLoader . LoadTexture ( this . manager . device , stream ) ; if ( srv != null ) alternateTextures [ partName ] = srv ; } catch ( COMException ) { System . Windows . MessageBox . Show ( " " ) ; } } else { alternateTextures [ partName ] = null ; } } }
Creates an alternate texture for a part
Creates an alternate texture for a part
partName
string
The name of the part to create the texture for.
The name of the part to create the texture for .
imagePath
string
The path to the image to be used for the texture.
The path to the image to be used for the texture .