當前位置: 首頁>>代碼示例>>C#>>正文


C# EffectHandle.Dispose方法代碼示例

本文整理匯總了C#中SharpDX.Direct3D9.EffectHandle.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# EffectHandle.Dispose方法的具體用法?C# EffectHandle.Dispose怎麽用?C# EffectHandle.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SharpDX.Direct3D9.EffectHandle的用法示例。


在下文中一共展示了EffectHandle.Dispose方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LoadFromSource


//.........這裏部分代碼省略.........
					var macro = new D3D9.Macro();
					if ( define.Contains( "=" ) )
					{
						var split = define.Split( '=' );
						macro.Name = split[ 0 ];
						macro.Definition = split[ 1 ];
					}
					else
					{
						macro.Name = define;
						macro.Definition = "1";
					}

					if ( !string.IsNullOrEmpty( macro.Name ) )
					{
						defines.Add( macro );
					}
				}
			}

			// Populate compile flags
			var compileFlags = UseColumnMajorMatrices
			                   	? D3D9.ShaderFlags.PackMatrixColumnMajor
			                   	: D3D9.ShaderFlags.PackMatrixRowMajor;

#if DEBUG
			compileFlags |= D3D9.ShaderFlags.Debug;
#endif
			switch ( OptimizationLevel )
			{
				case OptimizationLevel.Default:
					compileFlags |= D3D9.ShaderFlags.OptimizationLevel1;
					break;

				case OptimizationLevel.None:
					compileFlags |= D3D9.ShaderFlags.SkipOptimization;
					break;

				case OptimizationLevel.LevelZero:
					compileFlags |= D3D9.ShaderFlags.OptimizationLevel0;
					break;

				case OptimizationLevel.LevelOne:
					compileFlags |= D3D9.ShaderFlags.OptimizationLevel1;
					break;

				case OptimizationLevel.LevelTwo:
					compileFlags |= D3D9.ShaderFlags.OptimizationLevel2;
					break;

				case OptimizationLevel.LevelThree:
					compileFlags |= D3D9.ShaderFlags.OptimizationLevel3;
					break;
			}

			var parseFlags = compileFlags;
			compileFlags ^= UseColumnMajorMatrices ? D3D9.ShaderFlags.PackMatrixColumnMajor : D3D9.ShaderFlags.PackMatrixRowMajor;

			// include handler
			var includeHandler = new HLSLIncludeHandler( this );

			// Compile & assemble into microcode
			var effectCompiler = new D3D9.EffectCompiler( Source, defines.ToArray(), includeHandler, parseFlags );
			var effectHandle = new D3D9.EffectHandle( EntryPoint );
			var errors = string.Empty;

			try
			{
				MicroCode = effectCompiler.CompileShader( effectHandle, Target, compileFlags, out this.constTable );
			}
			catch ( DX.SharpDXException ex )
			{
				if ( ex is DX.CompilationException )
				{
					errors = ex.Message;
				}

				// check for errors
				if ( !string.IsNullOrEmpty( errors ) )
				{
					if ( MicroCode != null )
					{
						if ( LogManager.Instance != null )
						{
							LogManager.Instance.Write( "HLSL: Warnings while compiling high level shader {0}:\n{1}", Name, errors );
						}
					}
					else
					{
						throw new AxiomException( "HLSL: Unable to compile high level shader {0}:\n{1}", Name, errors );
					}
				}
			}
			finally
			{
				effectCompiler.Dispose();
				effectHandle.Dispose();
				includeHandler.Dispose();
			}
		}
開發者ID:ryan-bunker,項目名稱:axiom3d,代碼行數:101,代碼來源:HLSLProgram.cs


注:本文中的SharpDX.Direct3D9.EffectHandle.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。