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


C# Effect.GetType方法代码示例

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


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

示例1: GetID3DXEffectInterface

			public System.Reflection.Pointer GetID3DXEffectInterface(byte[] shaderCode)
			{
				//XNA 4 embeds a small header on the front of the effect code... sigh
				//header is the following 4 bytes:
				//207,11,240,188
				//the offset of the shader source code
				//plus uints storing state flag information about each pass in each technique (eek)
				//then the souce

				uint passBytes = 2048; //no idea how many passes there are yet, so guess!

				uint headerSize = passBytes * 4 + 8;
				byte[] paddedCode = new byte[shaderCode.Length + headerSize];
				this.shaderByteCode = paddedCode;
				byte[] offset = BitConverter.GetBytes(headerSize);
				paddedCode[0] = 207;
				paddedCode[1] = 11;
				paddedCode[2] = 240;
				paddedCode[3] = 188;
				paddedCode[4] = offset[0];
				paddedCode[5] = offset[1];
				paddedCode[6] = offset[2];
				paddedCode[7] = offset[3];
				for (int i = 0; i < shaderCode.Length; i++)
					paddedCode[i + headerSize] = shaderCode[i];

				try
				{
					Effect = new Effect(Graphics.GraphicsDevice, paddedCode);
					object ptr = Effect.GetType().GetField("pComPtr", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(Effect);

					return (System.Reflection.Pointer)ptr;
				}
				catch (Exception ex)
				{
					//an exception can be thrown if the animation generation failed. In which case, compile the shader using XNA to pick out the errors
					try
					{
						string errors;
						EffectCompiler.CompileEffect(source, filename, buildForXbox, out errors);
						if (errors != null)
						{
							ShaderExtensionGenerator.ThrowGeneratorError(errors, filename);
						}
					}
					catch
					{
					}

					ShaderExtensionGenerator.ThrowGeneratorError(ex.Message, filename);
					return null;
				}
			}
开发者ID:shadarath,项目名称:Wirtualna-rzeczywistosc,代码行数:53,代码来源:FxDecompiler.cs

示例2: PrepareEffect

        /// <summary>
        /// Prepare an effect so that it is ready for rendering
        /// </summary>
        /// <param name="effect"></param>
        protected void PrepareEffect(Effect effect)
        {
            // We have been passed a base effect object.
            // Determine its type and call the appropriate PrepareEffect overload.
            if (effect is BasicEffect)
            {
                PrepareEffect((BasicEffect)effect);
                return;
            }
            if (effect is AlphaTestEffect)
            {
                PrepareEffect((AlphaTestEffect)effect);
                return;
            }
            if (effect is DualTextureEffect)
            {
                PrepareEffect((DualTextureEffect)effect);
                return;
            }
            if (effect is EnvironmentMapEffect)
            {
                PrepareEffect((EnvironmentMapEffect)effect);
                return;
            }

            // Not a supported effect
            throw new NotSupportedException("Cannot prepare effects of type '" + effect.GetType().Name + "', not currently implemented.");
        }
开发者ID:jokerwsd,项目名称:Shidi-Wang-The-Corpse-Flower-Game,代码行数:32,代码来源:MatrixObjectBase.cs

示例3: GetName

    private static string GetName(Effect effect)
    {
      if (effect != null)
      {
        if (!string.IsNullOrEmpty(effect.Name))
          return effect.Name;

        var effectType = effect.GetType();
        if (effectType != typeof(Effect))
          return effectType.Name;
      }

      return null;
    }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:14,代码来源:EffectBindingException.cs


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