本文整理汇总了C#中System.Factory.GetAdapter方法的典型用法代码示例。如果您正苦于以下问题:C# Factory.GetAdapter方法的具体用法?C# Factory.GetAdapter怎么用?C# Factory.GetAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Factory
的用法示例。
在下文中一共展示了Factory.GetAdapter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public override void Initialize()
{
using (var fac = new Factory())
{
using (var tmpDevice = new Device(fac.GetAdapter(0), DriverType.Hardware, DeviceCreationFlags.None))
{
using (var rf = new RenderForm())
{
var desc = new SwapChainDescription
{
BufferCount = 1,
Flags = SwapChainFlags.None,
IsWindowed = true,
ModeDescription = new ModeDescription(100, 100, new Rational(60, 1), Format.R8G8B8A8_UNorm),
OutputHandle = rf.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
using (var sc = new SwapChain(fac, tmpDevice, desc))
{
PresentPointer = Pulse.Magic.GetObjectVtableFunction(sc.ComPointer, VMT_PRESENT);
ResetTargetPointer = Pulse.Magic.GetObjectVtableFunction(sc.ComPointer, VMT_RESIZETARGET);
}
}
}
}
_presentDelegate = Pulse.Magic.RegisterDelegate<Direct3D10Present>(PresentPointer);
_presentHook = Pulse.Magic.Detours.CreateAndApply(_presentDelegate, new Direct3D10Present(Callback), "D10Present");
}
示例2: DeviceContext10
/// <summary>
/// Initializes a new instance of the <see cref="DeviceContext10"/> class.
/// </summary>
/// <param name="handle">The window handle to associate with the device.</param>
/// <param name="settings">The settings used to configure the device.</param>
internal DeviceContext10(IntPtr handle, DeviceSettings10 settings)
{
if (handle == IntPtr.Zero)
throw new ArgumentException("Value must be a valid window handle.", "handle");
if (settings == null)
throw new ArgumentNullException("settings");
this.settings = settings;
factory = new Factory();
device = new Direct3D10.Device(factory.GetAdapter(settings.AdapterOrdinal), Direct3D10.DriverType.Hardware, settings.CreationFlags);
swapChain = new SwapChain(factory, device, new SwapChainDescription
{
BufferCount = 1,
Flags = SwapChainFlags.None,
IsWindowed = true,
ModeDescription = new ModeDescription(settings.Width, settings.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
OutputHandle = handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
});
factory.SetWindowAssociation(handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter);
}
示例3: Initialize
public static void Initialize( out Factory dxgiFactory, out SlimDX.Direct3D11.Device d3d11Device )
{
dxgiFactory = new Factory();
Adapter adapter = null;
long videoMemory = 0;
for ( var i = 0; i < dxgiFactory.GetAdapterCount(); i++ )
{
var tmpAdapter = dxgiFactory.GetAdapter( i );
if ( tmpAdapter.Description.DedicatedVideoMemory > videoMemory )
{
adapter = tmpAdapter;
videoMemory = tmpAdapter.Description.DedicatedVideoMemory;
}
}
d3d11Device = null;
try
{
d3d11Device = Constants.DEBUG_D3D11_DEVICE
? new SlimDX.Direct3D11.Device( adapter,
DeviceCreationFlags.Debug,
new[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0 } )
: new SlimDX.Direct3D11.Device( adapter,
DeviceCreationFlags.None,
new[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0 } );
}
catch ( Exception e )
{
Console.WriteLine( "\nError: Couldn't create Direct3D 11 device (exception: " + e.Source + ", " + e.Message + ").\n" );
}
}
示例4: PrintAdapters
private static void PrintAdapters(Factory factory) {
var adapterCount = factory.GetAdapterCount();
for (var adapterIndex = 0; adapterIndex < adapterCount; ++adapterIndex) {
using (var adapter = factory.GetAdapter(adapterIndex)) {
Console.WriteLine("Adapter Index: {0}", adapterIndex);
foreach (var descProperty in adapter.Description.GetType().GetProperties()) {
Console.WriteLine(" {0}: {1}", ParseName(descProperty.Name), descProperty.GetValue(adapter.Description, null));
}
PrintAdapterOutputs(adapter);
PrintDeviceInformation(adapter);
}
}
}
示例5: InitializeDevice
public void InitializeDevice()
{
isInitialized = false;
try
{
// Declare and create the Device and SwapChain.
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(mParent.ClientSize.Width, mParent.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = mParent.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
Factory fact = new Factory();
Device.CreateWithSwapChain(fact.GetAdapter(0), DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain);
Device context = device;
shaderEffect = ShaderHelper.GetEffect(device);
shaderHelper.Initialize(device, shaderEffect);
shaderSignature = shaderEffect.GetTechniqueByIndex(0).GetPassByIndex(0).Description.Signature;
// Scale the buffers appropriately to the size of the parent control.
isInitialized = true;
ResizeBuffers();
EnableAlphaBlending();
UpdateTextures();
UpdateAllShapes();
}
catch (Direct3D10Exception ex)
{
MessageBox.Show("" + ex.Message + "\n\n" + ex.ResultCode.Code.ToString("X")
+ "\n\n" + ex.StackTrace); return;
}
}
示例6: InitializeDevice
public void InitializeDevice()
{
mForm = new Form { Width = mWidth, Height = mHeight };
mForm.Closing += (sender, args) => IsClosing = true;
using (var factory = new Factory())
{
Device = new Device(factory.GetAdapter(0), DriverType.Hardware, DeviceCreationFlags.None);
mSwapChain = CreateSwapChain(factory);
}
using (var texture = Resource.FromSwapChain<Texture2D>(mSwapChain, 0))
{
mRenderTarget = new RenderTargetView(Device, texture);
}
var viewport = new Viewport
{
X = 0,
Y = 0,
Width = mWidth,
Height = mHeight,
MinZ = 0.0f,
MaxZ = 1.0f
};
SetRasterizerState();
CreateDepthBuffer();
CreateStencilState();
Device.Rasterizer.SetViewports(viewport);
Device.OutputMerger.SetTargets(mDepthStencilView, mRenderTarget);
}