} // RenderTarget

        /// <summary>
        /// Creates a render target for render to textures. Use size type constructor for screen relative sizes.
        /// </summary>
        /// <param name="size">Render target size</param>
        /// <param name="_surfaceFormat">Surface format</param>
        /// <param name="_hasDepthBuffer">Has depth buffer?</param>
        /// <param name="antialiasingType">Multi sampling type: System value or no antialiasing.</param>
        public RenderTarget(Size size, SurfaceFormat _surfaceFormat = SurfaceFormat.Color, bool _hasDepthBuffer = true, AntialiasingType antialiasingType = AntialiasingType.NoAntialiasing, bool mipMap = false)
        {
            Name = "Render Target";
            Size = size;

            SurfaceFormat = _surfaceFormat;
            DepthFormat = _hasDepthBuffer ? DepthFormat.Depth24 : DepthFormat.None;
            Antialiasing = antialiasingType;
            MipMap = mipMap;

            Create();
            EngineManager.DeviceReset += OnScreenSizeChanged;
        } // RenderTarget
        /// <summary>
        /// Creates a render target for render to textures. Use size type constructor for screen relative sizes.
        /// </summary>
        /// <param name="size">Render target size</param>
        /// <param name="_surfaceFormat">Surface format</param>
        /// <param name="_depthFormat">Depth Format</param>
        /// <param name="antialiasingType">Multi sampling type: System value or no antialiasing.</param>
        public RenderTarget(Size size, SurfaceFormat _surfaceFormat, DepthFormat _depthFormat, AntialiasingType antialiasingType = AntialiasingType.NoAntialiasing, bool mipMap = false)
        {
            Name = "Render Target";
            Size = size;

            SurfaceFormat = _surfaceFormat;
            DepthFormat = _depthFormat;
            Antialiasing = antialiasingType;
            MipMap = mipMap;

            Create();
            EngineManager.DeviceReset += OnScreenSizeChanged;
        } // RenderTarget
        } // RecreateResource

        #endregion
        
        #region Calculate MultiSample Quality

        /// <summary>
        /// Calculate multiSample quality.
        /// </summary>
        internal static int CalculateMultiSampleQuality(AntialiasingType antialiasingTypeType)
        {
            switch (antialiasingTypeType)
            {
                case AntialiasingType.NoAntialiasing:
                    return 0;
                case AntialiasingType.System:
                    return Screen.MultiSampleQuality;
                case AntialiasingType.TwoSamples:
                    return 2;
                case AntialiasingType.FourSamples:
                    return 4;
                case AntialiasingType.EightSamples:
                    return 8;
                case AntialiasingType.SixtySamples:
                    return 16;
                default:
                    throw new ArgumentException("Render Target error. Antialiasing type doesn't exist (probably a bug).");
            }
        } // CalculateMultiSampleQuality
 /// <summary>
 /// There is a pool of render targets to avoid wasting unnecessary graphic memory.
 /// The idea is that a render target has also a flag that tell us if the content is still need or not.
 /// So, when a shader needs a render target it search in the pool for an unused render target with the right characteristics (size, surface format, etc.)
 /// The problem if someone has to turn the flag false when the render target’s content is unnecessary and this could be somehow ugly. 
 /// But the graphic pipeline performance is critical, it’s not an area for the user and its complexity was diminished thanks to the new code’s restructuring.
 /// The pool should be used in the filters, shadow maps and similar shaders. Not everything.
 /// Use the Release method to return a render target to the pool.
 /// </summary>
 public static RenderTarget Fetch(Size size, SurfaceFormat surfaceFormat, DepthFormat depthFormat, AntialiasingType antialiasingType, bool mipMap = false)
 {
     RenderTarget renderTarget;
     for (int i = 0; i < renderTargets.Count; i++)
     {
         renderTarget = renderTargets[i];
         if (renderTarget.Size == size && renderTarget.SurfaceFormat == surfaceFormat &&
             renderTarget.DepthFormat == depthFormat && renderTarget.Antialiasing == antialiasingType && renderTarget.MipMap == mipMap && !renderTarget.looked)
         {
             renderTarget.looked = true;
             return renderTarget;
         }
     }
     // If there is not one unlook or present we create one.
     AssetContentManager userContentManager = AssetContentManager.CurrentContentManager;
     AssetContentManager.CurrentContentManager = AssetContentManager.SystemContentManager;
     renderTarget = new RenderTarget(size, surfaceFormat, depthFormat, antialiasingType, mipMap);
     AssetContentManager.CurrentContentManager = userContentManager;
     renderTargets.Add(renderTarget);
     renderTarget.looked = true;
     return renderTarget;
 } // Fetch