Example #1
0
        public void SetRenderTargetsColor(params IRenderTarget2D[] colorTargets)
        {
            if (colorTargets == null || colorTargets.Length == 0)
            {
                if (currentColorTargets.Length != 0)
                {
                    currentColorTargets = new RenderTargetView[0];
                    renderTargetsDirty  = true;
                }
                return;
            }
            RenderTargetView[] targets = new RenderTargetView[colorTargets.Length];
            for (int i = 0; i < targets.Length; i++)
            {
                Texture2D target = graphicsDevice.Cast <Texture2D>(colorTargets[i], "colorTargets[" + i + "]");
                if (target.RenderView == null)
                {
                    throw new ArgumentException("Texture at index " + i + " is not a color target", "colorTargets");
                }
                targets[i] = target.RenderView;
            }

            if (currentColorTargets != null && targets.SequenceEqual(currentColorTargets))
            {
                return;
            }

            currentColorTargets = targets;
            renderTargetsDirty  = true;
        }