Пример #1
0
        private static void DetectSupportedEffectLanguage(GraphicsDevice graphicsDevice, Type effectType)
        {
            CustomEffectBase.SystemEffectLanguage = EffectLanguage.Unknown;

            foreach (EffectLanguage language in Enum.GetValues(typeof(EffectLanguage)))
            {
                if (language == EffectLanguage.Unknown)
                {
                    continue;
                }

                byte[] effectByteCode;
                Effect temporaryEffect;
                try
                {
                    effectByteCode  = CustomEffectBase.GetEmbeddedByteCode(effectType, language);
                    temporaryEffect = new Effect(graphicsDevice, effectByteCode);
                    if (temporaryEffect == null)
                    {
                        continue;
                    }
                    else
                    {
                        temporaryEffect.Dispose();
                        temporaryEffect = null;
                        CustomEffectBase.SystemEffectLanguage = language;
                        break;
                    }
                }
                catch (Exception e)
                {
                    continue;
                }
            }
        }
Пример #2
0
        private static byte[] GetEffectByteCode(GraphicsDevice graphicsDevice, Type effectType)
        {
            if (CustomEffectBase.SystemEffectLanguage == EffectLanguage.Unknown)
            {
                CustomEffectBase.DetectSupportedEffectLanguage(graphicsDevice, effectType);
            }

            if (CustomEffectBase.SystemEffectLanguage == EffectLanguage.Unknown)
            {
                throw new InvalidOperationException("Could not find any bytecode in a system compatible shader language for effect \"" + effectType.Name + "\"");
            }

            return(GetEmbeddedByteCode(effectType, CustomEffectBase.SystemEffectLanguage));
        }
Пример #3
0
 internal CustomEffectBase(GraphicsDevice graphicsDevice, Type effectType) : base(graphicsDevice, CustomEffectBase.GetEffectByteCode(graphicsDevice, effectType))
 {
 }