The ContentCatalogue class encapsulates the Xna ContentManager class to Load content as WeakReferences avoiding therefore to manage Content memory.
Inheritance: IContentCatalogue
Esempio n. 1
0
        protected GameState(string name, Application application, bool useApplicationContent, int bufferWidth, int bufferHeight, DetailPreference precisionMode, DetailPreference lightingRange)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("No valid name was provided to the GameState", "name");
            }

            if (application == null)
            {
                throw new ArgumentNullException("application", "No valid Application instance provided to the GameState");
            }

            Name        = name;
            Application = application;


            if (useApplicationContent)
            {
                Content = new ContentCatalogue(application);
            }
            else
            {
                _localContentManager = new ContentManager(application.Services, application.Content.RootDirectory);
                Content = new ContentCatalogue(application, _localContentManager);
            }
            // We create the IContentOwner List that will get populated with Content to be loaded with the GameState creation
            ContentToLoad = new List <IContentHost>();

            // create the SceneInterface instance from the Application
            SunBurn = Application.SunBurn;

            // create the Framebuffers and assigns the ownership to the SceneInterface
            _frameBuffers = new FrameBuffers(bufferWidth, bufferHeight, precisionMode, lightingRange);
            SunBurn.ResourceManager.AssignOwnership(_frameBuffers);
        }
Esempio n. 2
0
        protected GameState(string name, Application application, bool useApplicationContent, int bufferWidth, int bufferHeight, DetailPreference precisionMode, DetailPreference lightingRange)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentException("No valid name was provided to the GameState", "name");

            if (application == null)
                throw new ArgumentNullException("application", "No valid Application instance provided to the GameState");

            Name = name;
            Application = application;


            if (useApplicationContent)
            {
                Content = new ContentCatalogue(application);
            }
            else
            {
                _localContentManager = new ContentManager(application.Services, application.Content.RootDirectory);
                Content = new ContentCatalogue(application, _localContentManager);
            }
            // We create the IContentOwner List that will get populated with Content to be loaded with the GameState creation
            ContentToLoad = new List<IContentHost>();

            // create the SceneInterface instance from the Application
            SunBurn = Application.SunBurn;

            // create the Framebuffers and assigns the ownership to the SceneInterface
            CreateFrameBuffers(bufferWidth, bufferHeight, precisionMode, lightingRange);

            Application.GraphicsDevice.DeviceReset += new EventHandler<EventArgs>(GraphicsDevice_DeviceReset);
        }