Exemplo n.º 1
0
        public SkyboxGeneratorContext(SkyboxAsset skybox, IDatabaseFileProviderService fileProviderService)
        {
            Skybox   = skybox ?? throw new ArgumentNullException(nameof(skybox));
            Services = new ServiceRegistry();
            Services.AddService(fileProviderService);
            Content = new ContentManager(Services);
            Services.AddService <IContentManager>(Content);
            Services.AddService(Content);

            GraphicsDevice        = GraphicsDevice.New();
            GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);
            Services.AddService(GraphicsDeviceService);

            var graphicsContext = new GraphicsContext(GraphicsDevice);

            Services.AddService(graphicsContext);

            EffectSystem          = new EffectSystem(Services);
            EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem);

            Services.AddService(EffectSystem);
            EffectSystem.Initialize();
            ((IContentable)EffectSystem).LoadContent();
            ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false;

            RenderContext     = RenderContext.GetShared(Services);
            RenderDrawContext = new RenderDrawContext(Services, RenderContext, graphicsContext);
        }
Exemplo n.º 2
0
        protected void Init(IDatabaseFileProviderService databaseFileProviderService, ContentStorage storage)
        {
            Storage?.RemoveDisposeBy(this);

            Storage      = storage;
            fileProvider = databaseFileProviderService.FileProvider;

            Storage.DisposeBy(this);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Load this system.
 /// </summary>
 /// <param name="graphicsDevice">The graphics device.</param>
 /// <exception cref="System.ArgumentNullException">graphicsDevice</exception>
 public void Load(GraphicsDevice graphicsDevice, IDatabaseFileProviderService fileProviderService)
 {
     // TODO possibly load cached character bitmaps from the disk
     if (graphicsDevice == null)
     {
         throw new ArgumentNullException("graphicsDevice");
     }
     GraphicsDevice   = graphicsDevice;
     FontManager      = new FontManager(fileProviderService);
     FontCacheManager = new FontCacheManager(this);
 }
Exemplo n.º 4
0
        internal void Init(IDatabaseFileProviderService databaseFileProviderService, [NotNull] ContentStorage storage, ref ImageDescription imageDescription)
        {
            if (imageDescription.Depth != 1)
            {
                throw new ContentStreamingException("Texture streaming supports only 2D textures and 2D texture arrays.", storage);
            }

            Init(databaseFileProviderService, storage);
            texture.FullQualitySize = new Size3(imageDescription.Width, imageDescription.Height, imageDescription.Depth);
            description             = imageDescription;
            residentMips            = 0;
            CacheMipMaps();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create an empty register.
        /// </summary>
        public FontManager(IDatabaseFileProviderService fileProviderService)
        {
            contentManager = new ContentManager(fileProviderService);

            // Preload proper freetype native library (depending on CPU type)
            NativeLibraryHelper.Load("freetype.dll", typeof(FontManager));

            // create a freetype library used to generate the bitmaps
            freetypeLibrary = new Library();

            // launch the thumbnail builder thread
            bitmapBuilderThread = new Thread(SafeAction.Wrap(BuildBitmapThread))
            {
                IsBackground = true, Name = "Bitmap Builder thread"
            };
            bitmapBuilderThread.Start();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create an empty register.
        /// </summary>
        public FontManager(IDatabaseFileProviderService fileProviderService)
        {
            contentManager = new ContentManager(fileProviderService);

            // Preload proper freetype native library (depending on CPU type)
            Core.NativeLibrary.PreloadLibrary("freetype.dll", typeof(FontManager));

            // create a freetype library used to generate the bitmaps
            freetypeLibrary = new Library();

#if XENKO_PLATFORM_UWP
            Windows.System.Threading.ThreadPool.RunAsync(operation => SafeAction.Wrap(BuildBitmapThread)());
#else
            // launch the thumbnail builder thread
            bitmapBuilderThread = new Thread(SafeAction.Wrap(BuildBitmapThread))
            {
                IsBackground = true, Name = "Bitmap Builder thread"
            };
            bitmapBuilderThread.Start();
#endif
        }
Exemplo n.º 7
0
 public ContentManager(IDatabaseFileProviderService fileProvider)
 {
     databaseFileProvider = fileProvider;
     Serializer           = new ContentSerializer();
 }