本文整理汇总了C#中SwapChain.ResizeBuffers方法的典型用法代码示例。如果您正苦于以下问题:C# SwapChain.ResizeBuffers方法的具体用法?C# SwapChain.ResizeBuffers怎么用?C# SwapChain.ResizeBuffers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SwapChain
的用法示例。
在下文中一共展示了SwapChain.ResizeBuffers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSwapChainForDesktop
private SwapChain CreateSwapChainForDesktop(IntPtr handle)
{
bufferCount = 1;
var description = new SwapChainDescription
{
ModeDescription = new ModeDescription(Description.BackBufferWidth, Description.BackBufferHeight, Description.RefreshRate.ToSharpDX(), (SharpDX.DXGI.Format)Description.BackBufferFormat),
BufferCount = bufferCount, // TODO: Do we really need this to be configurable by the user?
OutputHandle = handle,
SampleDescription = new SampleDescription((int)Description.MultiSampleCount, 0),
SwapEffect = SwapEffect.Discard,
Usage = SharpDX.DXGI.Usage.BackBuffer | SharpDX.DXGI.Usage.RenderTargetOutput,
IsWindowed = true,
Flags = Description.IsFullScreen ? SwapChainFlags.AllowModeSwitch : SwapChainFlags.None,
};
var newSwapChain = new SwapChain(GraphicsAdapterFactory.NativeFactory, GraphicsDevice.NativeDevice, description);
if (Description.IsFullScreen)
{
// Before fullscreen switch
newSwapChain.ResizeTarget(ref description.ModeDescription);
// Switch to full screen
newSwapChain.IsFullScreen = true;
// This is really important to call ResizeBuffers AFTER switching to IsFullScreen
newSwapChain.ResizeBuffers(bufferCount, Description.BackBufferWidth, Description.BackBufferHeight, (SharpDX.DXGI.Format)Description.BackBufferFormat, SwapChainFlags.AllowModeSwitch);
}
return newSwapChain;
}
示例2: CreateSwapChainForDesktop
private SwapChain CreateSwapChainForDesktop(IntPtr handle)
{
bufferCount = 1;
var backbufferFormat = Description.BackBufferFormat;
#if SILICONSTUDIO_XENKO_GRAPHICS_API_DIRECT3D12
// TODO D3D12 (check if this setting make sense on D3D11 too?)
backbufferFormat = backbufferFormat.ToNonSRgb();
// TODO D3D12 Can we make it work with something else after?
bufferCount = 2;
#endif
var description = new SwapChainDescription
{
ModeDescription = new ModeDescription(Description.BackBufferWidth, Description.BackBufferHeight, Description.RefreshRate.ToSharpDX(), (SharpDX.DXGI.Format)backbufferFormat),
BufferCount = bufferCount, // TODO: Do we really need this to be configurable by the user?
OutputHandle = handle,
SampleDescription = new SampleDescription((int)Description.MultiSampleLevel, 0),
#if SILICONSTUDIO_XENKO_GRAPHICS_API_DIRECT3D11
SwapEffect = SwapEffect.Discard,
#elif SILICONSTUDIO_XENKO_GRAPHICS_API_DIRECT3D12
SwapEffect = SwapEffect.FlipDiscard,
#endif
Usage = SharpDX.DXGI.Usage.BackBuffer | SharpDX.DXGI.Usage.RenderTargetOutput,
IsWindowed = true,
Flags = Description.IsFullScreen ? SwapChainFlags.AllowModeSwitch : SwapChainFlags.None,
};
#if SILICONSTUDIO_XENKO_GRAPHICS_API_DIRECT3D11
var newSwapChain = new SwapChain(GraphicsAdapterFactory.NativeFactory, GraphicsDevice.NativeDevice, description);
#elif SILICONSTUDIO_XENKO_GRAPHICS_API_DIRECT3D12
var newSwapChain = new SwapChain(GraphicsAdapterFactory.NativeFactory, GraphicsDevice.NativeCommandQueue, description);
#endif
//prevent normal alt-tab
GraphicsAdapterFactory.NativeFactory.MakeWindowAssociation(handle, WindowAssociationFlags.IgnoreAltEnter);
if (Description.IsFullScreen)
{
// Before fullscreen switch
newSwapChain.ResizeTarget(ref description.ModeDescription);
// Switch to full screen
newSwapChain.IsFullScreen = true;
// This is really important to call ResizeBuffers AFTER switching to IsFullScreen
newSwapChain.ResizeBuffers(bufferCount, Description.BackBufferWidth, Description.BackBufferHeight, (SharpDX.DXGI.Format)Description.BackBufferFormat, SwapChainFlags.AllowModeSwitch);
}
return newSwapChain;
}
示例3: CreateSwapChainForDesktop
private SwapChain CreateSwapChainForDesktop()
{
IntPtr? handle = null;
var control = Description.DeviceWindowHandle as Control;
if (control != null) handle = control.Handle;
else if (Description.DeviceWindowHandle is IntPtr) handle = (IntPtr)Description.DeviceWindowHandle;
if (!handle.HasValue)
{
throw new NotSupportedException(string.Format("DeviceWindowHandle of type [{0}] is not supported. Only System.Windows.Control or IntPtr are supported", Description.DeviceWindowHandle != null ? Description.DeviceWindowHandle.GetType().Name : "null"));
}
bufferCount = 1;
var description = new SwapChainDescription
{
ModeDescription = new ModeDescription(Description.BackBufferWidth, Description.BackBufferHeight, Description.RefreshRate, Description.BackBufferFormat),
BufferCount = bufferCount, // TODO: Do we really need this to be configurable by the user?
OutputHandle = handle.Value,
SampleDescription = new SampleDescription((int)Description.MultiSampleCount, 0),
SwapEffect = SwapEffect.Discard,
Usage = Description.RenderTargetUsage,
IsWindowed = true,
Flags = Description.Flags,
};
var newSwapChain = new SwapChain(GraphicsAdapter.Factory, (Direct3D11.Device)GraphicsDevice, description);
if (Description.IsFullScreen)
{
// Before fullscreen switch
newSwapChain.ResizeTarget(ref description.ModeDescription);
// Switch to full screen
newSwapChain.IsFullScreen = true;
// This is really important to call ResizeBuffers AFTER switching to IsFullScreen
newSwapChain.ResizeBuffers(bufferCount, Description.BackBufferWidth, Description.BackBufferHeight, Description.BackBufferFormat, SwapChainFlags.AllowModeSwitch);
}
return newSwapChain;
}
示例4: CreateSwapChainForDesktop
private SwapChain CreateSwapChainForDesktop()
{
var control = Description.DeviceWindowHandle.NativeHandle as Control;
if (control == null)
{
throw new NotSupportedException(string.Format("Form of type [{0}] is not supported. Only System.Windows.Control are supported", Description.DeviceWindowHandle != null ? Description.DeviceWindowHandle.GetType().Name : "null"));
}
bufferCount = 1;
var description = new SwapChainDescription
{
ModeDescription = new ModeDescription(Description.BackBufferWidth, Description.BackBufferHeight, Description.RefreshRate.ToSharpDX(), (SharpDX.DXGI.Format)Description.BackBufferFormat),
BufferCount = bufferCount, // TODO: Do we really need this to be configurable by the user?
OutputHandle = control.Handle,
SampleDescription = new SampleDescription((int)Description.MultiSampleCount, 0),
SwapEffect = SwapEffect.Discard,
Usage = SharpDX.DXGI.Usage.BackBuffer | SharpDX.DXGI.Usage.RenderTargetOutput,
IsWindowed = true,
Flags = Description.IsFullScreen ? SwapChainFlags.AllowModeSwitch : SwapChainFlags.None,
};
var newSwapChain = new SwapChain(GraphicsAdapterFactory.NativeFactory, GraphicsDevice.NativeDevice, description);
if (Description.IsFullScreen)
{
// Before fullscreen switch
newSwapChain.ResizeTarget(ref description.ModeDescription);
// Switch to full screen
newSwapChain.IsFullScreen = true;
// This is really important to call ResizeBuffers AFTER switching to IsFullScreen
newSwapChain.ResizeBuffers(bufferCount, Description.BackBufferWidth, Description.BackBufferHeight, (SharpDX.DXGI.Format)Description.BackBufferFormat, SwapChainFlags.AllowModeSwitch);
}
return newSwapChain;
}
示例5: Resize
public void Resize(Device device, SwapChain swapChain, DeviceContext context)
{
renderTarget.Dispose();
//DepthStencilView.Dispose();
swapChain.ResizeBuffers(2, 0, 0, Format.R8G8B8A8_UNorm, SwapChainFlags.AllowModeSwitch);
using (var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0))
renderTarget = new RenderTargetView(device, resource);
context.OutputMerger.SetTargets(renderTarget);
}