Exemple #1
0
        public void Apply()
        {
            bool applyTextures = false;

            if (_lastEffectPass != _pass)
            {
                GL.UseProgram(_pass.ProgramID);
                _lastEffectPass = _pass;
            }

            unsafe
            {
                fixed (byte* ptr = &_owner.ParameterData[0])
                {
                    foreach (EffectParameter parameter in _owner.Parameters)
                    {
                        if (parameter.Parameter.Slot == -1)
                            continue;

                        if (_lastEffect != _owner || parameter.Dirty)
                            parameter.Apply(ptr);

                        if (parameter.Class == EffectParameterClass.Sampler && parameter.Textures != null)
                        {
                            for (int i = 0; i < parameter.Textures.Length; i++)
                            {
                                _pass.GraphicsDevice.Textures[parameter.Parameter.TextureUnit + i] = parameter.Textures[i];
                                applyTextures = true;
                            }
                        }
                    }
                }
            }

            if (applyTextures)
                _pass.GraphicsDevice.Textures.Apply();

            _pass.GraphicsDevice.ActiveShader = _owner.Shader;
            _lastEffect = _owner;
        }
Exemple #2
0
 public static void ResetActiveProgramCache()
 {
     _lastEffect = null;
     _lastEffectPass = null;
 }
Exemple #3
0
 internal EffectPass(Effect owner, ShaderPass pass)
 {
     _owner = owner;
     _pass = pass;
 }