Guest User

Untitled

a guest
Oct 20th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.96 KB | None | 0 0
  1. //-----------------------------------------------------------------------------
  2. // Torque
  3. // Copyright © GarageGames, LLC.
  4. //-----------------------------------------------------------------------------
  5.  
  6. using Microsoft.Xna.Framework.Graphics;
  7. using Torque.Engine.Framework.Core.Content;
  8. using Torque.Engine.Framework.Core.Contexts;
  9. using Torque.Engine.Runtime.Core.Material;
  10. using Torque.Engine.Runtime.XNA.Texture;
  11.  
  12. namespace Torque.Engine.Runtime.XNA.Material
  13. {
  14.     public sealed class XnaMaterialModule : ContextModule
  15.     {
  16.         #region Constructors / Finalizers
  17.  
  18.         /// <summary>
  19.         /// Construct and populate the module.
  20.         /// </summary>
  21.         public XnaMaterialModule()
  22.         {
  23.             // Bind the singleton material system object.
  24.             this.Bind<IMaterialSystem>().ToOneInstanceOf<XnaMaterialSystem>();
  25.  
  26.             // Bind the material data content loader.
  27.             this.Bind<IContentReference<XnaMaterialData>>().To( ( c, t ) => new ContentReference<XnaMaterialData, MaterialUri> { ParentContext = c } );
  28.             this.Bind<IContentLoader<XnaMaterialData>>().To( ( c, t ) => new MaterialDataContentLoader { ParentContext = c } );
  29.             this.Bind<IContentManager<XnaMaterialData>>().To( ( c, t ) =>
  30.                 {
  31.                     _materialDataContentManager.ParentContext = c; // NOT THREAD SAFE!
  32.                     return _materialDataContentManager;
  33.                 });
  34.  
  35.             // Bind the effect program content loader.
  36.             this.Bind<IContentReference<EffectProgram>>().To( ( c, t ) => new ContentReference<EffectProgram, ShaderProgramUri> { ParentContext = c } );
  37.             this.Bind<IContentLoader<EffectProgram>>().To( ( c, t ) => new EffectProgramContentLoader { ParentContext = c } );
  38.             this.Bind<IContentManager<EffectProgram>>().To( ( c, t ) =>
  39.                 {
  40.                     _effectProgramContentManager.ParentContext = c;  // NOT THREAD SAFE!
  41.                     return _effectProgramContentManager;
  42.                 });
  43.  
  44.             // Bind the texture content loader.
  45.             this.Bind<IContentReference<Texture2D>>().To( ( c, t ) => new ContentReference<Texture2D, TextureUri> { ParentContext = this } );
  46.             this.Bind<IContentLoader<Texture2D>>().To( ( c, t ) => new Texture2DContentLoader { ParentContext = this } );
  47.             this.Bind<IContentManager<Texture2D>>().To( ( c, t ) =>
  48.                 {
  49.                     _textureContentManager.ParentContext = c; // NOT THREAD SAFE!
  50.                     return _textureContentManager;
  51.                 });
  52.         }
  53.  
  54.         #endregion
  55.  
  56.         private readonly ContentManager<XnaMaterialData> _materialDataContentManager = new ContentManager<XnaMaterialData>();
  57.         private readonly ContentManager<EffectProgram> _effectProgramContentManager = new ContentManager<EffectProgram>();
  58.         private readonly ContentManager<Texture2D> _textureContentManager = new ContentManager<Texture2D>();
  59.     }
  60. }
Add Comment
Please, Sign In to add comment