/// <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 #2
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);
 }
        /// <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);
        }