Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----------------------------------------------------------------------------
- // Torque
- // Copyright © GarageGames, LLC.
- //-----------------------------------------------------------------------------
- using Microsoft.Xna.Framework.Graphics;
- using Torque.Engine.Framework.Core.Content;
- using Torque.Engine.Framework.Core.Contexts;
- using Torque.Engine.Runtime.Core.Material;
- using Torque.Engine.Runtime.XNA.Texture;
- namespace Torque.Engine.Runtime.XNA.Material
- {
- public sealed class XnaMaterialModule : ContextModule
- {
- #region Constructors / Finalizers
- /// <summary>
- /// Construct and populate the module.
- /// </summary>
- public XnaMaterialModule()
- {
- // Bind the singleton material system object.
- this.Bind<IMaterialSystem>().ToOneInstanceOf<XnaMaterialSystem>();
- // Bind the material data content loader.
- this.Bind<IContentReference<XnaMaterialData>>().To( ( c, t ) => new ContentReference<XnaMaterialData, MaterialUri> { ParentContext = c } );
- this.Bind<IContentLoader<XnaMaterialData>>().To( ( c, t ) => new MaterialDataContentLoader { ParentContext = c } );
- this.Bind<IContentManager<XnaMaterialData>>().To( ( c, t ) =>
- {
- _materialDataContentManager.ParentContext = c; // NOT THREAD SAFE!
- return _materialDataContentManager;
- });
- // Bind the effect program content loader.
- this.Bind<IContentReference<EffectProgram>>().To( ( c, t ) => new ContentReference<EffectProgram, ShaderProgramUri> { ParentContext = c } );
- this.Bind<IContentLoader<EffectProgram>>().To( ( c, t ) => new EffectProgramContentLoader { ParentContext = c } );
- this.Bind<IContentManager<EffectProgram>>().To( ( c, t ) =>
- {
- _effectProgramContentManager.ParentContext = c; // NOT THREAD SAFE!
- return _effectProgramContentManager;
- });
- // Bind the texture content loader.
- this.Bind<IContentReference<Texture2D>>().To( ( c, t ) => new ContentReference<Texture2D, TextureUri> { ParentContext = this } );
- this.Bind<IContentLoader<Texture2D>>().To( ( c, t ) => new Texture2DContentLoader { ParentContext = this } );
- this.Bind<IContentManager<Texture2D>>().To( ( c, t ) =>
- {
- _textureContentManager.ParentContext = c; // NOT THREAD SAFE!
- return _textureContentManager;
- });
- }
- #endregion
- private readonly ContentManager<XnaMaterialData> _materialDataContentManager = new ContentManager<XnaMaterialData>();
- private readonly ContentManager<EffectProgram> _effectProgramContentManager = new ContentManager<EffectProgram>();
- private readonly ContentManager<Texture2D> _textureContentManager = new ContentManager<Texture2D>();
- }
- }
Add Comment
Please, Sign In to add comment