本文整理汇总了C#中SharpDX.QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C# SharpDX.QueryInterface方法的具体用法?C# SharpDX.QueryInterface怎么用?C# SharpDX.QueryInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpDX
的用法示例。
在下文中一共展示了SharpDX.QueryInterface方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSharedD3D9
public static Texture GetSharedD3D9(this DeviceEx device, SharpDX.Direct3D11.Texture2D renderTarget)
{
if (renderTarget == null)
return null;
if ((renderTarget.Description.OptionFlags & SharpDX.Direct3D11.ResourceOptionFlags.Shared) == 0)
throw new ArgumentException("Texture must be created with ResourceOptionFlags.Shared");
Format format = ToD3D9(renderTarget.Description.Format);
if (format == Format.Unknown)
throw new ArgumentException("Texture format is not compatible with OpenSharedResource");
using (var resource = renderTarget.QueryInterface<SharpDX.DXGI.Resource>())
{
IntPtr handle = resource.SharedHandle;
if (handle == IntPtr.Zero)
throw new ArgumentNullException("Handle");
return new Texture(device, renderTarget.Description.Width, renderTarget.Description.Height, 1, Usage.RenderTarget, format, Pool.Default, ref handle);
}
}
示例2: GetSharedHandle
private IntPtr GetSharedHandle(SharpDX.Direct3D10.Texture2D Texture)
{
SharpDX.DXGI.Resource resource = Texture.QueryInterface<SharpDX.DXGI.Resource>();
IntPtr result = resource.SharedHandle;
resource.Dispose();
return result;
}
示例3: UpdateResources
/// <summary>
/// Update all resources
/// </summary>
/// <param name="backBuffer">BackBuffer</param>
internal void UpdateResources(SharpDX.Direct3D11.Texture2D backBuffer)
{
var d2dFactory = new SharpDX.Direct2D1.Factory();
var d2dSurface = backBuffer.QueryInterface<Surface>();
_direct2DRenderTarget = new SharpDX.Direct2D1.RenderTarget(d2dFactory, d2dSurface, new SharpDX.Direct2D1.RenderTargetProperties(new SharpDX.Direct2D1.PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Premultiplied)));
d2dSurface.Dispose();
d2dFactory.Dispose();
InitFont();
}
示例4: GetSharedHandle
private IntPtr GetSharedHandle( SharpDX.Direct3D11.Texture2D texture ) {
using ( var resource = texture.QueryInterface<SharpDX.DXGI.Resource>() ) {
return resource.SharedHandle;
}
}
示例5: CreateSharedTexture
//public bool IsOk()
//{
// ThrowIfDisposed();
// return _device.CheckDeviceState(IntPtr.Zero) == DeviceState.Ok;
//}
/// <summary>
/// Creates a Direct3D 9 texture from the specified Direct3D 11 texture.
/// (The content is shared between the devices.)
/// </summary>
/// <param name="texture">The Direct3D 11 texture.</param>
/// <returns>The Direct3D 9 texture.</returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="texture"/> is <see langword="null"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// The Direct3D 11 texture is not a shared resource, or the texture format is not supported.
/// </exception>
public Texture CreateSharedTexture(SharpDX.Direct3D11.Texture2D texture)
{
ThrowIfDisposed();
if (texture == null)
throw new ArgumentNullException("texture");
var format = ToD3D9(texture.Description.Format);
IntPtr sharedHandle;
using (var resource = texture.QueryInterface<SharpDX.DXGI.Resource>())
sharedHandle = resource.SharedHandle;
if (sharedHandle == IntPtr.Zero)
throw new ArgumentException("Unable to access resource. The texture needs to be created as a shared resource.", "texture");
int width = texture.Description.Width;
int height = texture.Description.Height;
return new Texture(_device, width, height, 1, Usage.RenderTarget, format, Pool.Default, ref sharedHandle);
}