本文整理汇总了C#中Texture2D.GetDXGISurface方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.GetDXGISurface方法的具体用法?C# Texture2D.GetDXGISurface怎么用?C# Texture2D.GetDXGISurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture2D
的用法示例。
在下文中一共展示了Texture2D.GetDXGISurface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDeviceResources
void CreateDeviceResources()
{
uint width = (uint) host.ActualWidth;
uint height = (uint) host.ActualHeight;
// If we don't have a device, need to create one now and all
// accompanying D3D resources.
CreateDevice();
DXGIFactory dxgiFactory = DXGIFactory.CreateFactory();
SwapChainDescription swapDesc = new SwapChainDescription();
swapDesc.BufferDescription.Width = width;
swapDesc.BufferDescription.Height = height;
swapDesc.BufferDescription.Format = Format.R8G8B8A8_UNORM;
swapDesc.BufferDescription.RefreshRate.Numerator = 60;
swapDesc.BufferDescription.RefreshRate.Denominator = 1;
swapDesc.SampleDescription.Count = 1;
swapDesc.SampleDescription.Quality = 0;
swapDesc.BufferUsage = UsageOption.RenderTargetOutput;
swapDesc.BufferCount = 1;
swapDesc.OutputWindowHandle = host.Handle;
swapDesc.Windowed = true;
swapChain = dxgiFactory.CreateSwapChain(
device, swapDesc);
// Create rasterizer state object
RasterizerDescription rsDesc = new RasterizerDescription();
rsDesc.AntialiasedLineEnable = false;
rsDesc.CullMode = CullMode.None;
rsDesc.DepthBias = 0;
rsDesc.DepthBiasClamp = 0;
rsDesc.DepthClipEnable = true;
rsDesc.FillMode = D3D10.FillMode.Solid;
rsDesc.FrontCounterClockwise = false; // Must be FALSE for 10on9
rsDesc.MultisampleEnable = false;
rsDesc.ScissorEnable = false;
rsDesc.SlopeScaledDepthBias = 0;
rasterizerState = device.CreateRasterizerState(
rsDesc);
device.RS.SetState(
rasterizerState
);
// If we don't have a D2D render target, need to create all of the resources
// required to render to one here.
// Ensure that nobody is holding onto one of the old resources
device.OM.SetRenderTargets(new RenderTargetView[] {null});
InitializeDepthStencil(width, height);
// Create views on the RT buffers and set them on the device
RenderTargetViewDescription renderDesc = new RenderTargetViewDescription();
renderDesc.Format = Format.R8G8B8A8_UNORM;
renderDesc.ViewDimension = RenderTargetViewDimension.Texture2D;
renderDesc.Texture2D.MipSlice = 0;
using (D3DResource spBackBufferResource = swapChain.GetBuffer<D3DResource>(0))
{
renderTargetView = device.CreateRenderTargetView(
spBackBufferResource,
renderDesc);
}
device.OM.SetRenderTargets(new RenderTargetView[] {renderTargetView}, depthStencilView);
SetViewport(width, height);
// Create a D2D render target which can draw into the surface in the swap chain
RenderTargetProperties props =
new RenderTargetProperties(
RenderTargetType.Default, new PixelFormat(Format.Unknown, AlphaMode.Premultiplied),
96, 96, RenderTargetUsage.None, FeatureLevel.Default);
// Allocate a offscreen D3D surface for D2D to render our 2D content into
Texture2DDescription tex2DDescription;
tex2DDescription.ArraySize = 1;
tex2DDescription.BindFlags = BindFlag.RenderTarget | BindFlag.ShaderResource;
tex2DDescription.CpuAccessFlags = CpuAccessFlag.Unspecified;
tex2DDescription.Format = Format.R8G8B8A8_UNORM;
tex2DDescription.Height = 4096;
tex2DDescription.Width = 512;
tex2DDescription.MipLevels = 1;
tex2DDescription.MiscFlags = 0;
tex2DDescription.SampleDescription.Count = 1;
tex2DDescription.SampleDescription.Quality = 0;
tex2DDescription.Usage = Usage.Default;
offscreenTexture = device.CreateTexture2D(tex2DDescription);
using (Surface dxgiSurface = offscreenTexture.GetDXGISurface())
{
// Create a D2D render target which can draw into our offscreen D3D surface
renderTarget = d2DFactory.CreateDxgiSurfaceRenderTarget(
dxgiSurface,
props);
//.........这里部分代码省略.........
示例2: InitializeTextureRenderTarget
private void InitializeTextureRenderTarget()
{
Texture2DDescription offscreenTextureDesc = new Texture2DDescription
{
ArraySize = 1,
BindFlags = BindFlag.RenderTarget | BindFlag.ShaderResource,
CpuAccessFlags = 0,
Format = Format.R8G8B8A8_UNORM,
Height = 512,
Width = 512,
MipLevels = 1,
MiscFlags = 0,
SampleDescription = new SampleDescription
{
Count = 1,
Quality = 0
},
Usage = Usage.Default,
};
offscreenTexture = device.CreateTexture2D(offscreenTextureDesc);
// Convert the Direct2D texture into a Shader Resource View
textureResourceView = device.CreateShaderResourceView(offscreenTexture);
textureSurface = offscreenTexture.GetDXGISurface();
}