當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。