当前位置: 首页>>代码示例>>C#>>正文


C# Effect.ReadEffect方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Effect.ReadEffect方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.ReadEffect方法的具体用法?C# Effect.ReadEffect怎么用?C# Effect.ReadEffect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.Effect的用法示例。


在下文中一共展示了Effect.ReadEffect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Effect

 public Effect(GraphicsDevice graphicsDevice, byte[] effectCode)
   : this(graphicsDevice)
 {
   int hash = Hash.ComputeHash(effectCode);
   Effect cloneSource;
   if (!Effect.EffectCache.TryGetValue(hash, out cloneSource))
   {
     cloneSource = new Effect(graphicsDevice);
     using (MemoryStream memoryStream = new MemoryStream(effectCode))
     {
       using (BinaryReader reader = new BinaryReader((Stream) memoryStream))
         cloneSource.ReadEffect(reader);
     }
     Effect.EffectCache.Add(hash, cloneSource);
   }
   this._isClone = true;
   this.Clone(cloneSource);
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:18,代码来源:Effect.cs

示例2: Effect

        public Effect (GraphicsDevice graphicsDevice, byte[] effectCode)
            : this(graphicsDevice)
		{
			// By default we currently cache all unique byte streams
			// and use cloning to populate the effect with parameters,
			// techniques, and passes.
			//
			// This means all the immutable types in an effect:
			//
			//  - Shaders
			//  - Annotations
			//  - Names
			//  - State Objects
			//
			// Are shared for every instance of an effect while the 
			// parameter values and constant buffers are copied.
			//
			// This might need to change slightly if/when we support
			// shared constant buffers as 'new' should return unique
			// effects without any shared instance state.
 
#if PSM 
			var effectKey = MonoGame.Utilities.Hash.ComputeHash(effectCode);
			int headerSize=0;
#else
            //Read the header
            MGFXHeader header = ReadHeader(effectCode);
			var effectKey = header.EffectKey;
			int headerSize = header.HeaderSize;
#endif

            // First look for it in the cache.
            //
            Effect cloneSource;
            if (!graphicsDevice.EffectCache.TryGetValue(effectKey, out cloneSource))
            {
                using (var stream = new MemoryStream(effectCode, headerSize, effectCode.Length - headerSize, false))
            	using (var reader = new BinaryReader(stream))
            {
                // Create one.
                cloneSource = new Effect(graphicsDevice);
                    cloneSource.ReadEffect(reader);

                // Cache the effect for later in its original unmodified state.
                    graphicsDevice.EffectCache.Add(effectKey, cloneSource);
                }
            }

            // Clone it.
            _isClone = true;
            Clone(cloneSource);
        }
开发者ID:KennethYap,项目名称:MonoGame,代码行数:52,代码来源:Effect.cs

示例3: Effect

        public Effect (GraphicsDevice graphicsDevice, byte[] effectCode)
            : this(graphicsDevice)
		{
			// By default we currently cache all unique byte streams
			// and use cloning to populate the effect with parameters,
			// techniques, and passes.
			//
			// This means all the immutable types in an effect:
			//
			//  - Shaders
			//  - Annotations
			//  - Names
			//  - State Objects
			//
			// Are shared for every instance of an effect while the 
			// parameter values and constant buffers are copied.
			//
			// This might need to change slightly if/when we support
			// shared constant buffers as 'new' should return unique
			// effects without any shared instance state.
            

            // First look for it in the cache.
            //
            // TODO: We could generate a strong and unique signature
            // offline during content processing and just read it from 
            // the front of the effectCode instead of computing a fast
            // hash here at runtime.
            //
            var effectKey = MonoGame.Utilities.Hash.ComputeHash(effectCode);
            Effect cloneSource;
            if (!EffectCache.TryGetValue(effectKey, out cloneSource))
            {
                // Create one.
                cloneSource = new Effect(graphicsDevice);
                using (var stream = new MemoryStream(effectCode))
                using (var reader = new BinaryReader(stream))
                    cloneSource.ReadEffect(reader);

                // Cache the effect for later in its original unmodified state.
                EffectCache.Add(effectKey, cloneSource);
            }

            // Clone it.
            _isClone = true;
            Clone(cloneSource);
        }
开发者ID:DrPandemic,项目名称:EraParadox,代码行数:47,代码来源:Effect.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Effect.ReadEffect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。