/// <summary> /// Called when the effect technique and parameter bindings should be initialized. /// </summary> /// <param name="graphicsService">The graphics service.</param> /// <param name="opaqueData">The opaque data. Can be <see langword="null"/>.</param> /// <remarks> /// <para> /// <strong>Notes to Inheritors:</strong> Derived classes can override this method to create /// custom parameter bindings. If the derived class does not initialize all parameter bindings /// then it should call the base implementation of <see cref="OnInitializeBindings"/> to /// initialize the remaining bindings. /// </para> /// <para> /// The method is called by the constructor of the base class. This means that derived classes /// may not be initialized yet! /// </para> /// </remarks> protected virtual void OnInitializeBindings(IGraphicsService graphicsService, IDictionary <string, object> opaqueData) { if (TechniqueBinding == null) { TechniqueBinding = EffectEx.TechniqueBinding.Clone(); } EffectHelper.InitializeParameterBindings(graphicsService, EffectEx, opaqueData, ParameterBindings); }
/// <summary> /// Initializes the <see cref="EffectEx"/>. /// </summary> /// <param name="graphicsService">The graphics service.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="graphicsService"/> is <see langword="null"/>. /// </exception> protected override void Initialize(IGraphicsService graphicsService) { if (graphicsService == null) { throw new ArgumentNullException("graphicsService"); } var effect = Resource; // When an Effect is used the original values of the effect parameters, as // specified in the .fx file, are lost. --> Store values in dictionary. OriginalParameterValues = EffectHelper.GetParameterValues(effect); TechniqueDescriptions = new EffectTechniqueDescriptionCollection(graphicsService, effect); TechniqueBinding = EffectHelper.CreateTechniqueBinding(graphicsService, effect); ParameterDescriptions = new EffectParameterDescriptionCollection(graphicsService, effect); ParameterBindings = new EffectParameterBindingCollection(EffectParameterHint.Any); EffectHelper.InitializeParameterBindings(graphicsService, this, null, ParameterBindings); }