本文整理汇总了C#中SharpDX.Direct3D9.Macro类的典型用法代码示例。如果您正苦于以下问题:C# Macro类的具体用法?C# Macro怎么用?C# Macro使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Macro类属于SharpDX.Direct3D9命名空间,在下文中一共展示了Macro类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EffectCompiler
/// <summary>
/// Initializes a new instance of the <see cref="EffectCompiler"/> class.
/// </summary>
/// <param name="data">The data.</param>
/// <param name="defines">The defines.</param>
/// <param name="includeFile">The include file.</param>
/// <param name="flags">The flags.</param>
/// <unmanaged>HRESULT D3DXCreateEffectCompiler([In] const char* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] unsigned int Flags,[In] ID3DXEffectCompiler** ppCompiler,[In] ID3DXBuffer** ppParseErrors)</unmanaged>
public EffectCompiler(string data, Macro[] defines, Include includeFile, ShaderFlags flags) : base(IntPtr.Zero)
{
IntPtr dataPtr = Marshal.StringToHGlobalAnsi(data);
try
{
CreateEffectCompiler(dataPtr, data.Length, defines, includeFile, flags, this);
}
finally
{
Marshal.FreeHGlobal(dataPtr);
}
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:21,代码来源:EffectCompiler.cs
示例2: Initialize
public static void Initialize(ref Device device, ref RenderForm form)
{
Macro macro = new Macro("nblights", 2.ToString());
Basic_Effect = Effect.FromFile(device, "Effect.fx", new Macro[] { macro }, null, "", ShaderFlags.OptimizationLevel3);
Basic_Effect.Technique = Basic_Effect.GetTechnique(0);
Basic_Effect.SetValue("AmbientLightColor", new Vector4(0f, 0f, 0f, 0f));
Matrix proj = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, form.ClientSize.Width / (float)form.ClientSize.Height, 0.1f, 7000.0f);
}
开发者ID:Arys02,项目名称:Underground,代码行数:8,代码来源:ResManager.cs
示例3: CreateEffectCompiler
private static void CreateEffectCompiler(IntPtr data, int length, Macro[] defines, Include includeFile, ShaderFlags flags, EffectCompiler instance)
{
Blob blobForErrors = null;
try
{
D3DX9.CreateEffectCompiler(data, length, defines, IncludeShadow.ToIntPtr(includeFile), (int)flags, instance, out blobForErrors);
}
catch (SharpDXException ex)
{
if (blobForErrors != null)
throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
throw;
}
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:14,代码来源:EffectCompiler.cs
示例4: FromMemory
/// <summary>
/// Creates an effect compiler from a memory buffer containing an ASCII effect description .
/// </summary>
/// <param name="data">The data.</param>
/// <param name="defines">The defines.</param>
/// <param name="includeFile">The include file.</param>
/// <param name="flags">The flags.</param>
/// <returns>
/// An instance of <see cref="EffectCompiler"/>
/// </returns>
/// <unmanaged>HRESULT D3DXCreateEffectCompiler([In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] unsigned int Flags,[Out, Fast] ID3DXEffectCompiler** ppCompiler,[In] ID3DXBuffer** ppParseErrors)</unmanaged>
public static EffectCompiler FromMemory(byte[] data, Macro[] defines, Include includeFile, ShaderFlags flags)
{
unsafe
{
var compiler = new EffectCompiler(IntPtr.Zero);
fixed (void* pData = data)
CreateEffectCompiler((IntPtr)pData, data.Length, defines, includeFile, flags, compiler);
return compiler;
}
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:21,代码来源:EffectCompiler.cs
示例5: LoadFromSource
protected override void LoadFromSource()
{
// Populate preprocessor defines
var defines = new List<D3D9.Macro>();
if ( !string.IsNullOrEmpty( PreprocessorDefines ) )
{
var tmp = PreprocessorDefines.Split( ' ', ',', ';' );
foreach ( string define in tmp )
{
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 );
}
//.........这里部分代码省略.........
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:101,代码来源:HLSLProgram.cs
示例6: PrepareMacros
internal static Macro[] PrepareMacros(Macro[] macros)
{
if (macros == null)
return null;
if (macros.Length == 0)
return null;
if (macros[macros.Length - 1].Name == null && macros[macros.Length - 1].Definition == null)
return macros;
var macroArray = new Macro[macros.Length + 1];
Array.Copy(macros, macroArray, macros.Length);
macroArray[macros.Length] = new Macro(null, null);
return macroArray;
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:18,代码来源:Effect.cs
示例7: FromString
/// <summary>
/// Compiles an effect from a string.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="sourceData">The source data.</param>
/// <param name="preprocessorDefines">The preprocessor defines.</param>
/// <param name="includeFile">The include file.</param>
/// <param name="skipConstants">The skip constants.</param>
/// <param name="flags">The flags.</param>
/// <returns>
/// An <see cref="Effect"/>
/// </returns>
/// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
public static Effect FromString(Device device, string sourceData, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags)
{
return FromString(device, sourceData, preprocessorDefines, includeFile, skipConstants, flags, null);
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:17,代码来源:Effect.cs
示例8: FromMemory
/// <summary>
/// Compiles an effect from a memory buffer.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="memory">The buffer.</param>
/// <param name="preprocessorDefines">The preprocessor defines.</param>
/// <param name="includeFile">The include file.</param>
/// <param name="skipConstants">The skip constants.</param>
/// <param name="flags">The flags.</param>
/// <param name="pool">The pool.</param>
/// <returns>An <see cref="Effect"/></returns>
/// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
public static Effect FromMemory(Device device, byte[] memory, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool)
{
unsafe
{
Effect effect = null;
Blob blobForErrors = null;
try
{
fixed (void* pData = memory)
D3DX9.CreateEffectEx(
device,
(IntPtr)pData,
memory.Length,
PrepareMacros(preprocessorDefines),
IncludeShadow.ToIntPtr(includeFile),
skipConstants,
(int)flags,
pool,
out effect,
out blobForErrors);
}
catch (SharpDXException ex)
{
if (blobForErrors != null)
throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
throw;
}
return effect;
}
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:43,代码来源:Effect.cs
示例9: CompileFromFile
/// <summary>
/// Compiles a shader or effect from a file on disk.
/// </summary>
/// <param name="fileName">The name of the source file to compile.</param>
/// <param name="entryPoint">The name of the shader entry-point function, or <c>null</c> for an effect file.</param>
/// <param name="profile">The shader target or set of shader features to compile against.</param>
/// <param name="shaderFlags">Shader compilation options.</param>
/// <param name="defines">A set of macros to define during compilation.</param>
/// <param name="include">An interface for handling include files.</param>
/// <returns>
/// The compiled shader bytecode, or <c>null</c> if the method fails.
/// </returns>
/// <unmanaged>HRESULT D3DXCompileShader([In] const char* pSrcData,[In] unsigned int SrcDataLen,[In] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pFunctionName,[In] const char* pProfile,[In] unsigned int Flags,[In] ID3DXBuffer** ppShader,[In] ID3DXBuffer** ppErrorMsgs,[In] ID3DXConstantTable** ppConstantTable)</unmanaged>
public static CompilationResult CompileFromFile(string fileName, string entryPoint, string profile, ShaderFlags shaderFlags = ShaderFlags.None, Macro[] defines = null, Include include = null)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
if (profile == null)
{
throw new ArgumentNullException("profile");
}
if (!File.Exists(fileName))
{
throw new FileNotFoundException("Could not open the shader or effect file.", fileName);
}
return Compile(File.ReadAllText(fileName), entryPoint, profile, shaderFlags, PrepareMacros(defines), include);
}
开发者ID:Ziriax,项目名称:SharpDX,代码行数:29,代码来源:ShaderBytecode.cs
示例10: Compile
/// <summary>
/// Compiles the provided shader or effect source.
/// </summary>
/// <param name="shaderSource">A string containing the source of the shader or effect to compile.</param>
/// <param name="entryPoint">The name of the shader entry-point function, or <c>null</c> for an effect file.</param>
/// <param name="profile">The shader target or set of shader features to compile against.</param>
/// <param name="shaderFlags">Shader compilation options.</param>
/// <param name="defines">A set of macros to define during compilation.</param>
/// <param name="include">An interface for handling include files.</param>
/// <returns>
/// The compiled shader bytecode, or <c>null</c> if the method fails.
/// </returns>
/// <unmanaged>HRESULT D3DXCompileShader([In] const char* pSrcData,[In] unsigned int SrcDataLen,[In] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pFunctionName,[In] const char* pProfile,[In] unsigned int Flags,[In] ID3DXBuffer** ppShader,[In] ID3DXBuffer** ppErrorMsgs,[In] ID3DXConstantTable** ppConstantTable)</unmanaged>
public static CompilationResult Compile(string shaderSource, string entryPoint, string profile, ShaderFlags shaderFlags, Macro[] defines, Include include)
{
if (string.IsNullOrEmpty(shaderSource))
{
throw new ArgumentNullException("shaderSource");
}
return Compile(Encoding.ASCII.GetBytes(shaderSource), entryPoint, profile, shaderFlags, defines, include);
}
开发者ID:Ziriax,项目名称:SharpDX,代码行数:21,代码来源:ShaderBytecode.cs
示例11: AssembleFromFile
/// <summary>
/// Assembles a shader from file.
/// </summary>
/// <param name="fileName">Name of the shader file.</param>
/// <param name="defines">Macro definitions.</param>
/// <param name="includeFile">An <see cref="SharpDX.Direct3D9.Include"/> interface to use for handling #include directives.</param>
/// <param name="flags">Compilation options.</param>
/// <returns>
/// A <see cref="SharpDX.Direct3D9.CompilationResult"/> object representing the raw shader stream.
/// </returns>
public static CompilationResult AssembleFromFile(string fileName, Macro[] defines, Include includeFile, ShaderFlags flags)
{
return Assemble(File.ReadAllText(fileName), defines, includeFile, flags);
}
开发者ID:Ziriax,项目名称:SharpDX,代码行数:14,代码来源:ShaderBytecode.cs
示例12: Assemble
/// <summary>
/// Assembles a shader from the given source data.
/// </summary>
/// <param name="sourceData">The source shader data.</param>
/// <param name="defines">Macro definitions.</param>
/// <param name="includeFile">An <see cref="SharpDX.Direct3D9.Include" /> interface to use for handling #include directives.</param>
/// <param name="flags">Compilation options.</param>
/// <returns>A <see cref="SharpDX.Direct3D9.CompilationResult" /> object representing the raw shader stream.</returns>
/// <unmanaged>HRESULT D3DXAssembleShader([In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] unsigned int Flags,[In] ID3DXBuffer** ppShader,[In] ID3DXBuffer** ppErrorMsgs)</unmanaged>
public static CompilationResult Assemble(byte[] sourceData, Macro[] defines, Include includeFile, ShaderFlags flags)
{
unsafe
{
var resultCode = Result.Ok;
Blob blobForCode = null;
Blob blobForErrors = null;
try
{
fixed (void* pData = sourceData)
D3DX9.AssembleShader(
(IntPtr)pData,
sourceData.Length,
PrepareMacros(defines),
IncludeShadow.ToIntPtr(includeFile),
(int)flags,
out blobForCode,
out blobForErrors);
}
catch (SharpDXException ex)
{
if (blobForErrors != null)
{
resultCode = ex.ResultCode;
if (Configuration.ThrowOnShaderCompileError)
throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
}
else
{
throw;
}
}
return new CompilationResult(blobForCode != null ? new ShaderBytecode(blobForCode) : null, resultCode, Utilities.BlobToString(blobForErrors));
}
}
开发者ID:Ziriax,项目名称:SharpDX,代码行数:47,代码来源:ShaderBytecode.cs
示例13: FromFile
/// <summary>
/// Compiles an effect from a file.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="fileName">Name of the file.</param>
/// <param name="preprocessorDefines">The preprocessor defines.</param>
/// <param name="includeFile">The include file.</param>
/// <param name="skipConstants">The skip constants.</param>
/// <param name="flags">The flags.</param>
/// <param name="pool">The pool.</param>
/// <returns>
/// An <see cref="Effect"/>
/// </returns>
/// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
public static Effect FromFile(Device device, string fileName, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool)
{
return FromString(device, File.ReadAllText(fileName), preprocessorDefines, includeFile, skipConstants, flags, pool);
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:18,代码来源:Effect.cs
示例14: FromStream
/// <summary>
/// Compiles an effect from a stream.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="stream">The stream.</param>
/// <param name="preprocessorDefines">The preprocessor defines.</param>
/// <param name="includeFile">The include file.</param>
/// <param name="skipConstants">The skip constants.</param>
/// <param name="flags">The flags.</param>
/// <param name="pool">The pool.</param>
/// <returns>An <see cref="Effect"/></returns>
/// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
public static Effect FromStream(Device device, Stream stream, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool)
{
unsafe
{
Effect effect = null;
Blob blobForErrors = null;
try
{
if (stream is DataStream)
{
D3DX9.CreateEffectEx(
device,
((DataStream)stream).PositionPointer,
(int)(stream.Length - stream.Position),
PrepareMacros(preprocessorDefines),
IncludeShadow.ToIntPtr(includeFile),
skipConstants,
(int)flags,
pool,
out effect,
out blobForErrors);
}
else
{
var data = Utilities.ReadStream(stream);
fixed (void* pData = data)
D3DX9.CreateEffectEx(
device,
(IntPtr)pData,
data.Length,
PrepareMacros(preprocessorDefines),
IncludeShadow.ToIntPtr(includeFile),
skipConstants,
(int)flags,
pool,
out effect,
out blobForErrors);
}
stream.Position = stream.Length;
}
catch (SharpDXException ex)
{
if (blobForErrors != null)
throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
throw;
}
return effect;
}
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:63,代码来源:Effect.cs
示例15: Preprocess
/// <summary>
/// Preprocesses the provided shader or effect source.
/// </summary>
/// <param name = "shaderSource">An array of bytes containing the raw source of the shader or effect to preprocess.</param>
/// <param name = "defines">A set of macros to define during preprocessing.</param>
/// <param name = "include">An interface for handling include files.</param>
/// <returns>The preprocessed shader source.</returns>
/// <unmanaged>HRESULT D3DXPreprocessShader([In] const void* pSrcData,[In] unsigned int SrcDataSize,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] ID3DXBuffer** ppShaderText,[In] ID3DXBuffer** ppErrorMsgs)</unmanaged>
public static string Preprocess(byte[] shaderSource, Macro[] defines = null, Include include = null)
{
string errors = null;
return Preprocess(shaderSource, defines, include, out errors);
}
开发者ID:Ziriax,项目名称:SharpDX,代码行数:13,代码来源:ShaderBytecode.cs
示例16: FromFile
/// <summary>
/// Creates an effect compiler from a file on disk containing an ASCII effect description .
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="defines">The defines.</param>
/// <param name="includeFile">The include file.</param>
/// <param name="flags">The flags.</param>
/// <returns>
/// An instance of <see cref="EffectCompiler"/>
/// </returns>
/// <unmanaged>HRESULT D3DXCreateEffectCompiler([In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] unsigned int Flags,[Out, Fast] ID3DXEffectCompiler** ppCompiler,[In] ID3DXBuffer** ppParseErrors)</unmanaged>
public static EffectCompiler FromFile(string fileName, Macro[] defines, Include includeFile, ShaderFlags flags)
{
return new EffectCompiler(File.ReadAllText(fileName), defines, includeFile, flags);
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:15,代码来源:EffectCompiler.cs
示例17: FromStream
/// <summary>
/// Creates an effect compiler from a stream containing an ASCII effect description .
/// </summary>
/// <param name="stream">The stream.</param>
/// <param name="defines">The defines.</param>
/// <param name="includeFile">The include file.</param>
/// <param name="flags">The flags.</param>
/// <returns>An instance of <see cref="EffectCompiler"/></returns>
/// <unmanaged>HRESULT D3DXCreateEffectCompiler([In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] unsigned int Flags,[Out, Fast] ID3DXEffectCompiler** ppCompiler,[In] ID3DXBuffer** ppParseErrors)</unmanaged>
public static EffectCompiler FromStream(Stream stream, Macro[] defines, Include includeFile, ShaderFlags flags)
{
if (stream is DataStream)
{
var compiler = new EffectCompiler(IntPtr.Zero);
CreateEffectCompiler(((DataStream)stream).PositionPointer, (int)(stream.Length - stream.Position), defines, includeFile, flags, compiler);
return compiler;
}
return FromMemory(Utilities.ReadStream(stream), defines, includeFile, flags);
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:19,代码来源:EffectCompiler.cs
示例18: PreprocessFromFile
/// <summary>
/// Preprocesses a shader or effect from a file on disk.
/// </summary>
/// <param name = "fileName">The name of the source file to compile.</param>
/// <param name = "defines">A set of macros to define during preprocessing.</param>
/// <param name = "include">An interface for handling include files.</param>
/// <returns>The preprocessed shader source.</returns>
/// <unmanaged>HRESULT D3DXPreprocessShader([In] const void* pSrcData,[In] unsigned int SrcDataSize,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] ID3DXBuffer** ppShaderText,[In] ID3DXBuffer** ppErrorMsgs)</unmanaged>
public static string PreprocessFromFile(string fileName, Macro[] defines, Include include)
{
string errors = null;
return PreprocessFromFile(fileName, defines, include, out errors);
}
开发者ID:Ziriax,项目名称:SharpDX,代码行数:13,代码来源:ShaderBytecode.cs
示例19: Main
//.........这里部分代码省略.........
true,
true,
Format.D24X8,
PresentFlags.None,
0,
PresentInterval.Immediate);
input = new Input(form);
device = new Device(direct3D, 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, Parametres);
vertexElems3D = new[] {
new VertexElement(0, // POSITION
0,
DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Position, 0),
new VertexElement(0, // TEXCOORD0
Convert.ToInt16(Utilities.SizeOf<Vector4>()),
DeclarationType.Float2, DeclarationMethod.Default,DeclarationUsage.TextureCoordinate,0),
new VertexElement(0, // COLOR0
Convert.ToInt16(Utilities.SizeOf<Vector4>()+Utilities.SizeOf<Vector2>()),
DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Color, 0),
new VertexElement(0, // NORMAL0
Convert.ToInt16(Utilities.SizeOf<Vector4>()+Utilities.SizeOf<Vector2>()+Utilities.SizeOf<Vector4>()),
DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Normal, 0),
new VertexElement(0, // TANGENT
Convert.ToInt16(Utilities.SizeOf<Vector4>()+Utilities.SizeOf<Vector2>()+Utilities.SizeOf<Vector4>()+Utilities.SizeOf<Vector4>()),
DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Tangent, 0),
VertexElement.VertexDeclarationEnd,
new VertexElement(0, // booléen de bump mapping
Convert.ToInt16(Utilities.SizeOf<Vector4>()+Utilities.SizeOf<Vector2>()+Utilities.SizeOf<Vector4>()+Utilities.SizeOf<Vector4>()+Utilities.SizeOf<Vector4>()),
DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
VertexElement.VertexDeclarationEnd,
};
vertexElems2D = new[] {
new VertexElement(0,0,DeclarationType.Float4,DeclarationMethod.Default,DeclarationUsage.PositionTransformed,0),
new VertexElement(0,16,DeclarationType.Float2,DeclarationMethod.Default,DeclarationUsage.TextureCoordinate,0),
VertexElement.VertexDeclarationEnd
};
VertexDeclaration3D = new VertexDeclaration(Program.device, Program.vertexElems3D);
VertexDeclaration2D = new VertexDeclaration(Program.device, Program.vertexElems2D);
VertexBufferZero = new VertexBuffer(IntPtr.Zero);
device.VertexDeclaration = VertexDeclaration3D;
Program.device.SetRenderState(RenderState.AlphaBlendEnable, true); // graphics.GraphicsDevice.RenderState.AlphaBlendEnable = true;
Program.device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha); // graphics.GraphicsDevice.RenderState.DestinationBlend = Blend.One;
Program.device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha); // graphics.GraphicsDevice.RenderState.SourceBlend = Blend.One;
Program.device.SetRenderState(RenderState.AlphaFunc, BlendOperation.Maximum); // graphics.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Add;
Program.device.SetRenderState(RenderState.AlphaTestEnable, true);
Program.device.SetRenderState(RenderState.MinTessellationLevel, 8);
#endregion
Liste_textures = new List<structTexture>();
Liste_binaires = new List<structBinary>();
Liste_OBJ = new List<structOBJ>();
Liste_Lights = new Light[2];
Liste_Lights[0].Type = LightType.Point;
Liste_Lights[0].Position = new Vector3(0, 0, 0);
Liste_Lights[0].Ambient = new Color4(0.5f, 0.5f, 0.5f, 1);
Liste_Lights[0].Range = 30f * 70;
Liste_Lights[1].Type = LightType.Point;
Liste_Lights[1].Position = new Vector3(-100, -100, -100);
Liste_Lights[1].Ambient = new Color4(0.5f,0,0,1);
Liste_Lights[1].Range = 5f * 70;
Liste_textures.Add(new structTexture("null.bmp", Texture.FromFile(device, "null.bmp")));
//Ingame.Slender.doit_etre_recharge = true;
// Creation du fichier effect de référence
Macro macro = new Macro("nblights", 2.ToString());
BaseEffect = Effect.FromFile(Program.device, "Underground.fx", new Macro[] { macro }, null, "", ShaderFlags.OptimizationLevel3);
BaseEffect.Technique = BaseEffect.GetTechnique(0);
BaseEffect.SetValue("AmbientLightColor", new Vector4(0f, 0f, 0f, 0f));
Matrix proj = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, Program.form.ClientSize.Width / (float)Program.form.ClientSize.Height, 0.1f, 7000.0f);
BaseEffect.SetValue("Projection", proj);
BaseEffect.SetValue("LightDiffuseColor[0]", Liste_Lights[0].Ambient);
BaseEffect.SetValue("LightDiffuseColor[1]", Liste_Lights[1].Ambient);
BaseEffect.SetValue("LightDistanceSquared[1]", Liste_Lights[1].Range);
Thread ThSound = new Thread(Sound.main);
Thread ThEvents = new Thread(Ingame.fevents);
ThSound.Start();
ThEvents.Start();
Menu.Initialize_Menu();
ObjLoader.Initialize();
newmaze = new Maze(10, 10);
newmaze.Initecelles();
newmaze.Generate(newmaze.maze[0, 0]);
newmaze.impefectGenerate();
newmaze.Setaffichage();
Ingame.ingame();
Menu.Dispose();
ThSound.Abort();
ThEvents.Abort();
VertexBufferZero.Dispose();
VertexDeclaration3D.Dispose();
VertexDeclaration2D.Dispose();
device.Dispose();
direct3D.Dispose();
}
开发者ID:Arys02,项目名称:Underground,代码行数:101,代码来源:Program.cs
注:本文中的SharpDX.Direct3D9.Macro类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论