Exemple #1
0
        public RenderTarget2D UpdateCustomSizedRenderTarget(RenderTarget2D renderTarget, IRenderContext renderContext, Vector2 size, SurfaceFormat?surfaceFormat, DepthFormat?depthFormat, int?multiSampleCount, bool?shared)
        {
            if (IsCustomSizedRenderTargetOutOfDate(renderTarget, renderContext, size, surfaceFormat, depthFormat, multiSampleCount))
            {
                if (renderTarget != null)
                {
                    renderTarget.Dispose();
                }

                if (size.X < 1 ||
                    size.Y < 1)
                {
                    return(null);
                }

                renderTarget = new RenderTarget2D(
                    renderContext.GraphicsDevice,
                    (int)size.X,
                    (int)size.Y,
                    false,
                    surfaceFormat ?? GetRealBackBufferFormat(renderContext.GraphicsDevice.PresentationParameters.BackBufferFormat),
                    depthFormat ?? renderContext.GraphicsDevice.PresentationParameters.DepthStencilFormat,
                    multiSampleCount ?? renderContext.GraphicsDevice.PresentationParameters.MultiSampleCount,
                    RenderTargetUsage.PreserveContents,
                    shared ?? false);

#if PLATFORM_WINDOWS
                if (shared ?? false)
                {
                    renderTarget.AcquireLock(0, 1000000);
                }
#endif
            }

            return(renderTarget);
        }