예제 #1
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);
        }
예제 #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>
        private 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)
예제 #3
0
        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);
        }