当前位置: 首页>>代码示例>>C#>>正文


C# SharpDX.QueryInterface方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:rookboom,项目名称:Flow,代码行数:20,代码来源:DXSharing.cs

示例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;
 }
开发者ID:iejeecee,项目名称:mediaviewer,代码行数:7,代码来源:DX10ImageSource.cs

示例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();
        }
开发者ID:chantsunman,项目名称:SharpDX_Demo,代码行数:14,代码来源:Sharp2D.cs

示例4: GetSharedHandle

 private IntPtr GetSharedHandle( SharpDX.Direct3D11.Texture2D texture ) {
     using ( var resource = texture.QueryInterface<SharpDX.DXGI.Resource>() ) {
         return resource.SharedHandle;
     }
 }
开发者ID:Korhog,项目名称:D2dControl,代码行数:5,代码来源:Dx11ImageSource.cs

示例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);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:37,代码来源:D3D9.cs


注:本文中的SharpDX.QueryInterface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。