/// <summary>
        /// Gets a global shared context.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <returns>RenderContext.</returns>
        public static RenderContext GetShared(IServiceRegistry services)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));

            // Store RenderContext shared into the GraphicsDevice
            var graphicsDevice = services.GetSafeServiceAs<IGraphicsDeviceService>().GraphicsDevice;
            return graphicsDevice.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerDevice, SharedImageEffectContextKey, d => new RenderContext(services));
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderContext" /> class.
 /// </summary>
 /// <param name="services">The services.</param>
 /// <param name="allocator">The allocator.</param>
 /// <exception cref="System.ArgumentNullException">services</exception>
 internal RenderContext(IServiceRegistry services, GraphicsResourceAllocator allocator = null)
 {
     if (services == null) throw new ArgumentNullException("services");
     Services = services;
     Effects = services.GetSafeServiceAs<EffectSystem>();
     this.allocator = allocator ?? new GraphicsResourceAllocator(Services).DisposeBy(this);
     GraphicsDevice = services.GetSafeServiceAs<IGraphicsDeviceService>().GraphicsDevice;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderContext" /> class.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <exception cref="System.ArgumentNullException">services</exception>
        internal RenderContext(IServiceRegistry services)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));
            Services = services;
            Effects = services.GetSafeServiceAs<EffectSystem>();
            GraphicsDevice = services.GetSafeServiceAs<IGraphicsDeviceService>().GraphicsDevice;
            Allocator = services.GetServiceAs<GraphicsContext>().Allocator ?? new GraphicsResourceAllocator(GraphicsDevice).DisposeBy(GraphicsDevice);

            threadContext = new ThreadLocal<RenderDrawContext>(() => new RenderDrawContext(Services, this, new GraphicsContext(GraphicsDevice, Allocator)), true);
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderContext" /> class.
 /// </summary>
 /// <param name="services">The services.</param>
 /// <param name="allocator">The allocator.</param>
 /// <exception cref="System.ArgumentNullException">services</exception>
 internal RenderContext(IServiceRegistry services, GraphicsResourceAllocator allocator = null)
 {
     if (services == null)
     {
         throw new ArgumentNullException("services");
     }
     Services       = services;
     Effects        = services.GetSafeServiceAs <EffectSystem>();
     this.allocator = allocator ?? new GraphicsResourceAllocator(Services).DisposeBy(this);
     GraphicsDevice = services.GetSafeServiceAs <IGraphicsDeviceService>().GraphicsDevice;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderContext" /> class.
 /// </summary>
 /// <param name="services">The services.</param>
 /// <exception cref="System.ArgumentNullException">services</exception>
 internal RenderContext(IServiceRegistry services)
 {
     if (services == null)
     {
         throw new ArgumentNullException(nameof(services));
     }
     Services       = services;
     Effects        = services.GetSafeServiceAs <EffectSystem>();
     GraphicsDevice = services.GetSafeServiceAs <IGraphicsDeviceService>().GraphicsDevice;
     Allocator      = services.GetServiceAs <GraphicsContext>().Allocator ?? new GraphicsResourceAllocator(GraphicsDevice).DisposeBy(GraphicsDevice);
 }
Example #6
0
        /// <summary>
        /// Gets a global shared context.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <returns>RenderContext.</returns>
        public static RenderContext GetShared(IServiceRegistry services)
        {
            if (services == null)
            {
                throw new ArgumentNullException("services");
            }

            // Store RenderContext shared into the GraphicsDevice
            var graphicsDevice = services.GetSafeServiceAs <IGraphicsDeviceService>().GraphicsDevice;

            return(graphicsDevice.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerDevice, SharedImageEffectContextKey, d => new RenderContext(services)));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderContext" /> class.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <exception cref="System.ArgumentNullException">services</exception>
        internal RenderContext(IServiceRegistry services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            Services       = services;
            Effects        = services.GetSafeServiceAs <EffectSystem>();
            GraphicsDevice = services.GetSafeServiceAs <IGraphicsDeviceService>().GraphicsDevice;
            Allocator      = services.GetServiceAs <GraphicsContext>().Allocator ?? new GraphicsResourceAllocator(GraphicsDevice).DisposeBy(GraphicsDevice);

            threadContext = new ThreadLocal <RenderDrawContext>(() => new RenderDrawContext(Services, this, new GraphicsContext(GraphicsDevice, Allocator)), true);
        }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderContext" /> class.
 /// </summary>
 /// <param name="services">The services.</param>
 /// <param name="allocator">The allocator.</param>
 /// <exception cref="System.ArgumentNullException">services</exception>
 private RenderContext(IServiceRegistry services, GraphicsResourceAllocator allocator = null)
 {
     if (services == null)
     {
         throw new ArgumentNullException("services");
     }
     Services        = services;
     Effects         = services.GetSafeServiceAs <EffectSystem>();
     this.allocator  = allocator ?? new GraphicsResourceAllocator(Services).DisposeBy(this);
     GraphicsDevice  = services.GetSafeServiceAs <IGraphicsDeviceService>().GraphicsDevice;
     parametersStack = new Stack <ParameterCollection>();
     PushParameters(new ParameterCollection());
 }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderContext" /> class.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <exception cref="System.ArgumentNullException">services</exception>
        internal RenderContext(IServiceRegistry services)
        {
            Services         = services ?? throw new ArgumentNullException(nameof(services));
            Effects          = services.GetSafeServiceAs <EffectSystem>();
            GraphicsDevice   = services.GetSafeServiceAs <IGraphicsDeviceService>().GraphicsDevice;
            Allocator        = services.GetSafeServiceAs <GraphicsContext>().Allocator ?? new GraphicsResourceAllocator(GraphicsDevice).DisposeBy(GraphicsDevice);
            StreamingManager = services.GetService <StreamingManager>();

            threadContext = new ThreadLocal <RenderDrawContext>(() =>
            {
                lock (threadContextLock)
                {
                    return(new RenderDrawContext(Services, this, new GraphicsContext(GraphicsDevice, Allocator)));
                }
            }, true);
        }