Exemplo n.º 1
0
        internal EffectParameter(Effect owner, ShaderParameter parameter)
        {
            _owner = owner;

            Name = parameter.Name;
            Parameter = parameter;

            Dirty = true;
        }
Exemplo n.º 2
0
        protected override void LoadContent()
        {
            _effect = EffectManager.LoadEffect("Simple/Simple");

            int[] indices = new[] { 0, 1, 2 };
            VertexPositionNormalColor[] positions = new[]
                                                    {
                                                        new VertexPositionNormalColor(new Vector3(0.75f, 0.75f, 0.0f), new Vector3(), new Color(255, 0, 0)), new VertexPositionNormalColor(new Vector3(0.75f, -0.75f, 0.0f), new Vector3(), new Color(0, 255, 0)),
                                                        new VertexPositionNormalColor(new Vector3(-0.75f, -0.75f, 0.0f), new Vector3(), new Color(0, 0, 255)),
                                                    };

            _indices = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, indices.Length, BufferUsage.StaticDraw);
            _indices.SetData(indices);

            _vertices = new VertexBuffer(GraphicsDevice, typeof(VertexPositionNormalColor), positions.Length, BufferUsage.StaticDraw);
            _vertices.SetData(positions);
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
 public static void ResetActiveProgramCache()
 {
     _lastEffect = null;
     _lastEffectPass = null;
 }
Exemplo n.º 5
0
 internal EffectPass(Effect owner, ShaderPass pass)
 {
     _owner = owner;
     _pass = pass;
 }