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


C# Texture2D.QueryInterface方法代码示例

本文整理汇总了C#中Texture2D.QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.QueryInterface方法的具体用法?C# Texture2D.QueryInterface怎么用?C# Texture2D.QueryInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Texture2D的用法示例。


在下文中一共展示了Texture2D.QueryInterface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: D3D11Image

        /// <summary>
        /// Initializes a new instance of the <see cref="D3D11Image"/> class. Associates an D3D11 render target with the current instance.
        /// </summary>
        /// <param name="device">A valid D3D9 DeviceEx.</param>
        /// <param name="renderTarget">A valid D3D11 render target. It must be created with the "Shared" flag.</param>
        public D3D11Image(DeviceEx device, Texture2D renderTarget)
        {
            using (var resource = renderTarget.QueryInterface<DXGIResource>())
            {
                var handle = resource.SharedHandle;

                this.texture = new Texture(
                    device,
                    renderTarget.Description.Width,
                    renderTarget.Description.Height,
                    1,
                    Usage.RenderTarget,
                    Format.A8R8G8B8,
                    Pool.Default,
                    ref handle);
            }

            using (var surface = this.texture.GetSurfaceLevel(0))
            {
                this.textureSurfaceHandle = surface.NativePointer;
                this.TrySetBackbufferPointer(this.textureSurfaceHandle);
            }

            this.IsFrontBufferAvailableChanged += this.HandleIsFrontBufferAvailableChanged;
        }
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:30,代码来源:D3D11Image.cs

示例2: GetSharedHandle

 private static IntPtr GetSharedHandle(Texture2D sharedTexture)
 {
     using (var resource = sharedTexture.QueryInterface<global::SharpDX.DXGI.Resource>())
     {
         IntPtr result = resource.SharedHandle;
         return result;
     }
 }
开发者ID:helix-toolkit,项目名称:helix-toolkit,代码行数:8,代码来源:DX11ImageSource.cs

示例3: InitRendering

        /// <summary>
        /// Initializes DirectX rendering resources.
        /// </summary>
        private void InitRendering()
        {
            double dpiScale = 1.0; // default value for 96 dpi

            var hwndTarget = PresentationSource.FromVisual(this).CompositionTarget as HwndTarget;
            if (hwndTarget != null)
            {
                dpiScale = hwndTarget.TransformToDevice.M11;
            }

            int surfWidth = (int)(this.viewport.Width < 0 ? 0 : Math.Ceiling(this.viewport.Width * dpiScale));
            int surfHeight = (int)(this.viewport.Height < 0 ? 0 : Math.Ceiling(this.viewport.Height * dpiScale));

            var windowHandle = (new System.Windows.Interop.WindowInteropHelper(System.Windows.Window.GetWindow(this))).Handle;

            this.d3d11Device = new D3D11Device(
                DriverType.Hardware,
                DeviceCreationFlags.BgraSupport,
                FeatureLevel.Level_11_0,
                FeatureLevel.Level_10_1,
                FeatureLevel.Level_10_0,
                FeatureLevel.Level_9_3,
                FeatureLevel.Level_9_2,
                FeatureLevel.Level_9_1);

            var backBuffer = new Texture2D(
                this.d3d11Device,
                new Texture2DDescription
                {
                    Height = surfHeight,
                    Width = surfWidth,
                    ArraySize = 1,
                    MipLevels = 1,
                    Format = Format.B8G8R8A8_UNorm,
                    SampleDescription = { Count = 1, Quality = 0 },
                    Usage = ResourceUsage.Default,
                    OptionFlags = ResourceOptionFlags.Shared,
                    BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                    CpuAccessFlags = 0
                });

            var surface = backBuffer.QueryInterface<Surface>();
            this.renderTarget = new RenderTarget(
                this.oxyRenderContext.D2DFactory,
                surface,
                new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)));

            this.d3d9Device = new D3D9Device(
                new Direct3D(),
                0,
                D3D9DeviceType.Hardware,
                windowHandle,
                D3D9CreateFlags.HardwareVertexProcessing | D3D9CreateFlags.Multithreaded | D3D9CreateFlags.FpuPreserve,
                new D3D9PresentParameters(surfWidth, surfHeight)
                {
                    PresentationInterval = D3D9PresentInterval.Immediate,
                    DeviceWindowHandle = windowHandle,
                    SwapEffect = D3D9SwapEffect.Discard,
                    Windowed = true
                });

            this.imageSource = new D3D11Image(this.d3d9Device, backBuffer);

            this.oxyRenderContext.ResetRenderTarget(this.renderTarget);
        }
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:68,代码来源:PlotImage.cs


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