本文整理汇总了C#中BufferDescription类的典型用法代码示例。如果您正苦于以下问题:C# BufferDescription类的具体用法?C# BufferDescription怎么用?C# BufferDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BufferDescription类属于命名空间,在下文中一共展示了BufferDescription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Sky
public Sky(Device device, string filename, float skySphereRadius) {
CubeMapSRV = ShaderResourceView.FromFile(device, filename);
using (var r = CubeMapSRV.Resource) {
r.DebugName = "sky cubemap";
}
var sphere = GeometryGenerator.CreateSphere(skySphereRadius, 30, 30);
var vertices = sphere.Vertices.Select(v => v.Position).ToArray();
var vbd = new BufferDescription(
Marshal.SizeOf(typeof(Vector3)) * vertices.Length,
ResourceUsage.Immutable,
BindFlags.VertexBuffer,
CpuAccessFlags.None,
ResourceOptionFlags.None,
0
);
_vb = new Buffer(device, new DataStream(vertices, false, false), vbd);
_indexCount = sphere.Indices.Count;
var ibd = new BufferDescription(
_indexCount * sizeof(int),
ResourceUsage.Immutable,
BindFlags.IndexBuffer,
CpuAccessFlags.None,
ResourceOptionFlags.None,
0
);
_ib = new Buffer(device, new DataStream(sphere.Indices.ToArray(), false, false), ibd);
}
开发者ID:amitprakash07,项目名称:dx11,代码行数:30,代码来源:Sky.cs
示例2: loadWave
/** 指定の音声データを読み込む*/
public bool loadWave(int idx, string fname)
{
try
{
BufferDescription desc = null;
desc = new BufferDescription();
desc.ControlPan = true;
desc.GlobalFocus = true;
//現在実行中のアセンブリを取得
Assembly thisExe = Assembly.GetExecutingAssembly();
string assemblyName = thisExe.GetName().Name;
// string FileName = assemblyName + "." + fname;
string FileName = "DoujinGameProject.Resources." + fname;
//埋め込みファイルのストリームを取得
Stream stream = thisExe.GetManifestResourceStream(FileName);
//ストリームからバッファ作成
bufSec[idx] = new SecondaryBuffer(stream, desc, devSound);
//ストリームを閉じる!
stream.Close();
// bufSec[idx] = new SecondaryBuffer(fname, devSound);
}
catch (Exception e)
{
sErr = "[loadWaveエラー]" + e.ToString();
return false;
}
return true;
}
开发者ID:Jkank,项目名称:sister,代码行数:33,代码来源:DirectSound.cs
示例3: WVPTransformShader
/// <summary>
/// Initializes a new instance of the <see cref="WVPTransformShader" /> class.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="vertexShaderPath">The vertex shader path.</param>
/// <param name="pixelShaderPath">The pixel shader path.</param>
public WVPTransformShader(Device device, string vertexShaderPath, string pixelShaderPath, IInputLayoutProvider inputLayoutMaker)
: base(device, vertexShaderPath, pixelShaderPath, inputLayoutMaker)
{
Contract.Ensures(matrixConstantBuffer != null, "matrixConstantBuffer must not be null after this method executes.");
BufferDescription matrixBufferDesc = new BufferDescription(System.Runtime.InteropServices.Marshal.SizeOf(typeof(MatrixCBuffer)), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
matrixConstantBuffer = new SlimDX.Direct3D11.Buffer(device, matrixBufferDesc);
}
开发者ID:nickudell,项目名称:PigmentFramework,代码行数:13,代码来源:WVPTransformShader.cs
示例4: Minimap
public Minimap(Device device, DeviceContext dc, int minimapWidth, int minimapHeight, Terrain terrain, CameraBase viewCam)
{
_dc = dc;
_minimapViewport = new Viewport(0, 0, minimapWidth, minimapHeight);
CreateMinimapTextureViews(device, minimapWidth, minimapHeight);
_terrain = terrain;
SetupOrthoCamera();
_viewCam = viewCam;
// frustum vb will contain four corners of view frustum, with first vertex repeated as the last
var vbd = new BufferDescription(
VertexPC.Stride * 5,
ResourceUsage.Dynamic,
BindFlags.VertexBuffer,
CpuAccessFlags.Write,
ResourceOptionFlags.None,
0
);
_frustumVB = new Buffer(device, vbd);
_edgePlanes = new[] {
new Plane(1, 0, 0, -_terrain.Width / 2),
new Plane(-1, 0, 0, _terrain.Width / 2),
new Plane(0, 1, 0, -_terrain.Depth / 2),
new Plane(0, -1, 0, _terrain.Depth / 2)
};
ScreenPosition = new Vector2(0.25f, 0.75f);
Size = new Vector2(0.25f, 0.25f);
}
开发者ID:jackinf,项目名称:dx11,代码行数:34,代码来源:Minimap.cs
示例5: loadSound
/// <summary>
/// Carga un archivo WAV de audio, indicando el volumen del mismo
/// Solo se pueden cargar sonidos WAV que sean MONO (1 channel).
/// Sonidos stereos (2 channels) no pueden ser utilizados.
/// </summary>
/// <param name="soundPath">Path del archivo WAV</param>
/// <param name="volume">Volumen del mismo</param>
public void loadSound(string soundPath, int volume)
{
try
{
dispose();
BufferDescription bufferDescription = new BufferDescription();
bufferDescription.Control3D = true;
if (volume != -1)
{
bufferDescription.ControlVolume = true;
}
soundBuffer = new SecondaryBuffer(soundPath, bufferDescription, GuiController.Instance.DirectSound.DsDevice);
buffer3d = new Buffer3D(soundBuffer);
buffer3d.MinDistance = 50;
if (volume != -1)
{
soundBuffer.Volume = volume;
}
}
catch (Exception ex)
{
throw new Exception("Error al cargar sonido estático WAV: " + soundPath, ex);
}
}
开发者ID:aniPerezG,项目名称:barbalpha,代码行数:34,代码来源:Tgc3dSound.cs
示例6: ObjRenderer
public ObjRenderer(Form1 F)
: base(F.Device)
{
P = F;
PortalRoomManager.Equals(null, null);
S = new Sorter();
string s0 = Environment.CurrentDirectory + "/resources/shaders/ambient_fast.fx";
SB_V = ShaderBytecode.CompileFromFile(s0, "VS_STATIC", "vs_4_0", ManagedSettings.ShaderCompileFlags, EffectFlags.None);
SB_P = ShaderBytecode.CompileFromFile(s0, "PS", "ps_4_0", ManagedSettings.ShaderCompileFlags, EffectFlags.None);
VS = new VertexShader(F.Device.HadrwareDevice(), SB_V);
PS = new PixelShader(F.Device.HadrwareDevice(), SB_P);
IL = new InputLayout(Device.HadrwareDevice(), SB_V, StaticVertex.ies);
BufferDescription desc = new BufferDescription
{
Usage = ResourceUsage.Default,
SizeInBytes = 2 * 64,
BindFlags = BindFlags.ConstantBuffer
};
cBuf = new SlimDX.Direct3D11.Buffer(Device.HadrwareDevice(), desc);
dS = new DataStream(2 * 64, true, true);
BufferDescription desc2 = new BufferDescription
{
Usage = ResourceUsage.Default,
SizeInBytes = 64,
BindFlags = BindFlags.ConstantBuffer
};
cBuf2 = new SlimDX.Direct3D11.Buffer(Device.HadrwareDevice(), desc2);
dS2 = new DataStream(64, true, true);
}
开发者ID:hhergeth,项目名称:RisenEditor,代码行数:30,代码来源:ObjRenderer.cs
示例7: Initialize
public static void Initialize(System.Windows.Forms.Control Parent)
{
// Initialize sound
sounddevice = new DS.Device();
sounddevice.SetCooperativeLevel(Parent, CooperativeLevel.Normal);
//BufferDescription description = new BufferDescription();
description = new BufferDescription();
description.ControlEffects = false;
shotsound = new SecondaryBuffer[10];
//shotsound[0]
// = new SecondaryBuffer("turn-left.wav", description, sounddevice);
//shotsound[1]
// = new SecondaryBuffer("turn-left.wav", description, sounddevice);
shotsound[2]
= new SecondaryBuffer("turn-left.wav", description, sounddevice);
shotsound[3]
= new SecondaryBuffer("turn-right.wav", description, sounddevice);
shotsound[4]
= new SecondaryBuffer("horn.wav", description, sounddevice);
shotsound[5]
= new SecondaryBuffer("ignition.wav", description, sounddevice);
shotsound[6]
= new SecondaryBuffer("police_siren.wav", description, sounddevice);
shotsound[7]
= new SecondaryBuffer("ambulance_siren.wav", description, sounddevice);
//shotsound[8]
// = new SecondaryBuffer("ignition.wav", description, sounddevice);
//shotsound[9]
// = new SecondaryBuffer("ignition.wav", description, sounddevice);
//shotsound = new SecondaryBuffer("horn.wav", description, sounddevice);
//shotsound.Play(0, BufferPlayFlags.Default);
}
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:35,代码来源:DirectSoundWrapper.cs
示例8: DX11RawBuffer
public DX11RawBuffer(Device dev, int size, DX11RawBufferFlags flags= new DX11RawBufferFlags())
{
this.Size = size;
BufferDescription bd = new BufferDescription()
{
BindFlags = BindFlags.ShaderResource | BindFlags.UnorderedAccess,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.RawBuffer,
SizeInBytes = this.Size,
Usage = ResourceUsage.Default,
};
this.Buffer = new Buffer(dev, bd);
ShaderResourceViewDescription srvd = new ShaderResourceViewDescription()
{
Format = SlimDX.DXGI.Format.R32_Typeless,
Dimension = ShaderResourceViewDimension.ExtendedBuffer,
Flags = ShaderResourceViewExtendedBufferFlags.RawData,
ElementCount = size / 4
};
this.SRV = new ShaderResourceView(dev, this.Buffer, srvd);
UnorderedAccessViewDescription uavd = new UnorderedAccessViewDescription()
{
Format = SlimDX.DXGI.Format.R32_Typeless,
Dimension = UnorderedAccessViewDimension.Buffer,
Flags = UnorderedAccessViewBufferFlags.RawData,
ElementCount = size / 4
};
this.UAV = new UnorderedAccessView(dev, this.Buffer, uavd);
}
开发者ID:arturoc,项目名称:FeralTic,代码行数:33,代码来源:DX11RawBuffer.cs
示例9: DX11VertexBuffer
public DX11VertexBuffer(DX11RenderContext context, int verticescount, int vertexsize, bool allowstreamout)
{
this.context = context;
this.TotalSize = verticescount * vertexsize;
this.AllowStreamOutput = allowstreamout;
BindFlags flags = BindFlags.VertexBuffer;
if (allowstreamout)
{
flags |= BindFlags.StreamOutput;
}
BufferDescription bd = new BufferDescription()
{
BindFlags = flags,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None,
SizeInBytes = this.TotalSize,
Usage = ResourceUsage.Default
};
this.Buffer = new SlimDX.Direct3D11.Buffer(context.Device, bd);
this.VertexSize = vertexsize;
this.VerticesCount = verticescount;
}
开发者ID:arturoc,项目名称:FeralTic,代码行数:26,代码来源:VertexBuffer.cs
示例10: Sound
public Sound(string filename, int ID, short type)
: base(filename, ID)
{
// get the file data
WaveFile wf = FileManager.Instance.Load(filename);
if(wf.WavFile != null) // we have a wave file with headers
{
// set up the buffer properties
soundDesc = new BufferDescription();
soundDesc.GlobalFocus = false;
soundDesc.ControlVolume = true;
// enable 3D features for 3D sounds
if(type == Sound.THREED_SOUND)
{
soundDesc.Control3D = true;
soundDesc.Mute3DAtMaximumDistance = true;
}
// load the wave file from the stream into the buffer
sound = new SecondaryBuffer(wf.WavFile, soundDesc, ((DirectSoundManager)SoundManager.Instance).Device);
} else { // we have only raw PCM encoded sound data (usually from a decoder)
// convert the format settings
WaveFormat wfo = new WaveFormat();
wfo.BitsPerSample = wf.Bits;
wfo.Channels = wf.Channels;
wfo.SamplesPerSecond = wf.Frequency;
wfo.BlockAlign = (short)(wf.Bits*wf.Channels / 8);
wfo.FormatTag = WaveFormatTag.Pcm;
wfo.AverageBytesPerSecond = wf.Frequency * wfo.BlockAlign;
// set up buffer properties
soundDesc = new BufferDescription(wfo);
soundDesc.GlobalFocus = false;
soundDesc.ControlVolume = true;
soundDesc.BufferBytes = (int)wf.Data.Length;
// enable 3D features for 3D sounds
if(type == Sound.THREED_SOUND)
{
soundDesc.Control3D = true;
soundDesc.Mute3DAtMaximumDistance = true;
}
// initialise the buffer and copy the (raw data) stream into it
sound = new SecondaryBuffer(soundDesc, ((DirectSoundManager)SoundManager.Instance).Device);
sound.Write(0, wf.Data, (int)wf.Data.Length, LockFlag.EntireBuffer);
}
// create a 3D buffer for 3D sounds
if(type == Sound.THREED_SOUND)
{
threeDsound = new Buffer3D(sound);
threeDsound.Mode = Mode3D.Normal;
threeDsound.Deferred = true;
}
}
开发者ID:BackupTheBerlios,项目名称:agex-svn,代码行数:60,代码来源:Sound.cs
示例11: TransparencyShader
protected TransparencyShader(Device device, string vertexShaderPath, string pixelShaderPath, IInputLayoutProvider inputLayoutMaker)
: base(device, vertexShaderPath, pixelShaderPath, inputLayoutMaker)
{
Contract.Ensures(transparencyConstantBuffer != null, "lightConstantBuffer must be instantiated by this function.");
BufferDescription transparencyBufferDesc = new BufferDescription(System.Runtime.InteropServices.Marshal.SizeOf(typeof(TransparencyCBuffer)), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
transparencyConstantBuffer = new SlimDX.Direct3D11.Buffer(device, transparencyBufferDesc);
}
开发者ID:nickudell,项目名称:PigmentFramework,代码行数:7,代码来源:TransparencyShader.cs
示例12: DX11IndexBuffer
public DX11IndexBuffer(DX11RenderContext context, DataStream initial,bool dynamic, bool dispose)
{
this.context = context;
format = SlimDX.DXGI.Format.R32_UInt;
BindFlags flags = BindFlags.IndexBuffer;
if (context.IsFeatureLevel11) { flags |= BindFlags.ShaderResource; }
BufferDescription bd = new BufferDescription()
{
BindFlags = flags,
CpuAccessFlags = dynamic ? CpuAccessFlags.Write : CpuAccessFlags.None,
OptionFlags = context.IsFeatureLevel11 ? ResourceOptionFlags.RawBuffer : ResourceOptionFlags.None,
SizeInBytes = (int)initial.Length,
Usage = dynamic ? ResourceUsage.Dynamic : ResourceUsage.Default,
};
initial.Position = 0;
this.IndicesCount = (int)initial.Length / 4;
this.Buffer = new SlimDX.Direct3D11.Buffer(context.Device, initial, bd);
this.CreateSRV();
if (dispose) { initial.Dispose(); }
}
开发者ID:kopffarben,项目名称:FeralTic,代码行数:26,代码来源:IndexBuffer.cs
示例13: SoundPlayer
public SoundPlayer(Control owner, PullAudio pullAudio, string sample, short channels)
{
if (sample == null || File.Exists(sample) == false)
return;
this.channels = channels;
this.pullAudio = pullAudio;
this.samplefile = sample;
this._owner = owner;
this.soundDevice = new Device();
this.soundDevice.SetCooperativeLevel(_owner, CooperativeLevel.Priority);
// Set up our wave format to 44,100Hz, with 16 bit resolution
WaveFormat wf = new WaveFormat();
wf.FormatTag = WaveFormatTag.Pcm;
wf.SamplesPerSecond = 44100;
wf.BitsPerSample = 16;
wf.Channels = channels;
wf.BlockAlign = (short)(wf.Channels * wf.BitsPerSample / 8);
wf.AverageBytesPerSecond = wf.SamplesPerSecond * wf.BlockAlign;
this.samplesPerUpdate = 512;
// Create a buffer with 2 seconds of sample data
BufferDescription bufferDesc = new BufferDescription();
bufferDesc.BufferBytes = this.samplesPerUpdate * wf.BlockAlign * 2;
bufferDesc.ControlPositionNotify = true;
bufferDesc.GlobalFocus = true;
bufferDesc.ControlFrequency = true;
bufferDesc.ControlEffects = true;
bufferDesc.ControlVolume = true;
this.soundBuffer = new SecondaryBuffer(samplefile, bufferDesc, this.soundDevice);
this.soundBuffer.Volume = 0;
Notify notify = new Notify(this.soundBuffer);
fillEvent[0] = new AutoResetEvent(false);
fillEvent[1] = new AutoResetEvent(false);
// Set up two notification events, one at halfway, and one at the end of the buffer
BufferPositionNotify[] posNotify = new BufferPositionNotify[2];
posNotify[0] = new BufferPositionNotify();
posNotify[0].Offset = bufferDesc.BufferBytes / 2 - 1;
posNotify[0].EventNotifyHandle = fillEvent[0].Handle;
posNotify[1] = new BufferPositionNotify();
posNotify[1].Offset = bufferDesc.BufferBytes - 1;
posNotify[1].EventNotifyHandle = fillEvent[1].Handle;
notify.SetNotificationPositions(posNotify);
this.thread = new Thread(new ThreadStart(SoundPlayback));
this.thread.Priority = ThreadPriority.Lowest;
this.thread.IsBackground = true;
this.Pause();
this.running = true;
this.thread.Start();
}
开发者ID:nlhans,项目名称:SimTelemetry,代码行数:59,代码来源:SoundPlayer.cs
示例14: GameSound
public GameSound(System.Windows.Forms.Control Owner)
{
_bufferDesc = new BufferDescription();
_bufferDesc.GlobalFocus = true;
_bufferDesc.Control3D = true;
_soundDevice = new Device();
_soundDevice.SetCooperativeLevel(Owner, CooperativeLevel.Normal);
}
开发者ID:hassanmaher,项目名称:Pacman,代码行数:8,代码来源:GameSound.cs
示例15: GetBuffer
public SecondaryBuffer GetBuffer(Microsoft.DirectX.DirectSound.Device device, string fileName)
{
BufferDescription bd = new BufferDescription();
bd.ControlEffects = false;
bd.ControlPan = true;
bd.ControlVolume = true;
return new SecondaryBuffer(GetFileStream(fileName), bd, device);
}
开发者ID:sinshu,项目名称:mafia,代码行数:8,代码来源:MafiaLoader.cs
示例16: SoundBox
public SoundBox(System.Windows.Forms.Form frm, string soundFileName)
{
soundDevice = new Device();
soundDevice.SetCooperativeLevel(frm, CooperativeLevel.Normal);
BufferDescription description = new BufferDescription();
description.ControlVolume = true;
description.ControlEffects = false;
sound = new SecondaryBuffer(soundFileName, description, soundDevice);
soundList = new ArrayList();
}
开发者ID:Behzadkhosravifar,项目名称:Museum-3D,代码行数:10,代码来源:SoundBox.cs
示例17: SoundBuffer
/// <summary>
/// Konstruktor parametrowy obiektu
/// </summary>
/// <param name="device">Uchwyt do karty dzwiekowej</param>
/// <param name="fileName">Sciezka do pliku wav</param>
/// <param name="position">Pozycja dzwieku w przestrzeni</param>
public SoundBuffer(Device device, String fileName, Vector3 position)
{
BufferDescription description3D = new BufferDescription();
description3D.ControlEffects = false;
description3D.Control3D = true;
sound = new SecondaryBuffer(fileName, description3D, device);
sound3D = new Buffer3D(sound);
sound3D.Position = position;
sound3D.MinDistance = 15f;
}
开发者ID:kensniper,项目名称:castle-butcher,代码行数:17,代码来源:SoundBuffer.cs
示例18: MdxListener
public MdxListener(Device device)
{
BufferDescription desc = new BufferDescription();
desc.PrimaryBuffer = true;
desc.Control3D = true;
desc.Mute3DAtMaximumDistance = true;
Microsoft.DirectX.DirectSound.Buffer buffer = new Microsoft.DirectX.DirectSound.Buffer(desc, device);
_listener = new Listener3D(buffer);
Orientation = Matrix.Identity;
}
开发者ID:sikora507,项目名称:OpenC1,代码行数:12,代码来源:MdxListener.cs
示例19: CreateStaticVertexBuffer
public static Buffer CreateStaticVertexBuffer( int nVertices, int vertexSizeBytes )
{
var bd = new BufferDescription
(
nVertices * vertexSizeBytes,
ResourceUsage.Default,
BindFlags.VertexBuffer,
CpuAccessFlags.None,
ResourceOptionFlags.None
);
return new Buffer( D3D10Wrapper.Instance.Device, bd );
}
开发者ID:jiawen,项目名称:libcgt.net,代码行数:12,代码来源:BufferFactory.cs
示例20: CreateStagingBuffer
public static Buffer CreateStagingBuffer( int nBytes )
{
var bd = new BufferDescription
(
nBytes,
ResourceUsage.Staging,
BindFlags.None,
CpuAccessFlags.Read | CpuAccessFlags.Write,
ResourceOptionFlags.None
);
return new Buffer( D3D10Wrapper.Instance.Device, bd );
}
开发者ID:jiawen,项目名称:libcgt.net,代码行数:12,代码来源:BufferFactory.cs
注:本文中的BufferDescription类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论