public static TWTexture FromTexture2D(Texture2D texture2D)
        {
            TWTexture tex = new TWTexture();

            tex.xnaTexture = texture2D;

            return(tex);
        }
Beispiel #2
0
        }     // SetValue(param, lastUsedValue, newValue)

        /// <summary>
        /// Set value helper to set an effect parameter.
        /// </summary>
        /// <param name="param">Param</param>
        /// <param name="lastUsedValue">Last used value</param>
        /// <param name="newValue">New value</param>
        protected void SetValue(EffectParameter param,
                                ref TWTexture lastUsedValue, TWTexture newValue)
        {
            if (param != null &&
                lastUsedValue != newValue)
            {
                lastUsedValue = newValue;
                param.SetValue(newValue.XnaTexture);
            } // if (param)
        }     // SetValue(param, lastUsedValue, newValue)
Beispiel #3
0
        public void SetParameter(string parameterName, TWTexture value)
        {
            EffectParameter parameter = GetParameter(parameterName);

            if (parameter == null)
            {
                throw new InvalidOperationException("Given parameter does not exist!");
            }
            parameter.SetValue(value.XnaTexture);
        }
        public static TWTexture FromImageFile(IXNAGame game, IGameFile imageFile, TextureCreationParameters parameters)
        {
            TWTexture tex = new TWTexture();

            try
            {
                tex.xnaTexture = Texture2D.FromFile(game.GraphicsDevice, imageFile.GetFullFilename(), parameters);
            }
            catch
            {
                System.Diagnostics.Debug.WriteLine("Couldn't load texture at path '" + imageFile.GetFullFilename() + "' in TWTexture.");
                tex.xnaTexture = null;
            }
            return(tex);
        }