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


C# Device.QueryInterface方法代码示例

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


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

示例1: DrawingSurfaceContentProvider

        /// <summary>
        /// Default construtor.
        /// </summary>
        /// <param name="context">Parent SharpDXContext object.</param>
        public DrawingSurfaceContentProvider(SharpDXContext context)
        {
            this.sharpDXContext = context;

#if DEBUG
            DeviceCreationFlags creationFlags = DeviceCreationFlags.Debug;
#else
            DeviceCreationFlags creationFlags = DeviceCreationFlags.None;
#endif

            FeatureLevel[] featureLevels = 
	        {
                FeatureLevel.Level_11_1,
		        FeatureLevel.Level_11_0,
		        FeatureLevel.Level_10_1,
		        FeatureLevel.Level_10_0,
		        FeatureLevel.Level_9_3
	        };

            using (Device defaultDevice = new Device(DriverType.Hardware, creationFlags, featureLevels))
            {
                Device newDevice = defaultDevice.QueryInterface<Device1>();
                DeviceContext newContext = newDevice.ImmediateContext.QueryInterface<DeviceContext1>();

                this.sharpDXContext.OnDeviceReset(newDevice, newContext);
            }
        }
开发者ID:r2d2rigo,项目名称:SharpDX.SimpleInitializer,代码行数:31,代码来源:DrawingSurfaceContentProvider.cs

示例2: Initialize

        /* DEVICE MANAGER METHODS */
        /// <summary>
        /// Initialize resources and trigger an initialization event for all registered listeners
        /// </summary>
        public void Initialize(Tesseract gameEngine)
        {
            // Release any pre-exisitng references
            ReleaseResources();

            // Retrieve the Direct3D 11.1 device
            using (var device = new Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport, FeatureLevel))
            {
                Device3D = ToDispose(device.QueryInterface<Device1>());
            }

            // Get the Direct3D 11.1 context
            Context3D = ToDispose(Device3D.ImmediateContext.QueryInterface<DeviceContext1>());

            // Create the remaining references
            Factory2D = ToDispose(new SharpDX.Direct2D1.Factory1(SharpDX.Direct2D1.FactoryType.SingleThreaded));
            FactoryDW = ToDispose(new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared));
            FactoryWIC = ToDispose(new SharpDX.WIC.ImagingFactory2());

            // Create the Direct2D device
            using (var device = Device3D.QueryInterface<SharpDX.DXGI.Device>())
            {
                Device2D = ToDispose(new SharpDX.Direct2D1.Device(Factory2D, device));
            }

            // Create the Direct2D context
            Context2D = ToDispose(new SharpDX.Direct2D1.DeviceContext(Device2D, SharpDX.Direct2D1.DeviceContextOptions.None));
        }
开发者ID:JoshGrooms,项目名称:Tesseract,代码行数:32,代码来源:DeviceManager.cs

示例3: CreateInstances

        /// <summary>
        /// Creates device manager objects
        /// </summary>
        /// <remarks>
        /// This method is called at the initialization of this instance.
        /// </remarks>
        protected virtual void CreateInstances()
        {
            // Dispose previous references and set to null
            RemoveAndDispose(ref d3dDevice);
            RemoveAndDispose(ref d3dContext);
            RemoveAndDispose(ref d2dDevice);
            RemoveAndDispose(ref d2dContext);
            RemoveAndDispose(ref d2dFactory);
            RemoveAndDispose(ref dwriteFactory);
            RemoveAndDispose(ref wicFactory);

            #region Create Direct3D 11.1 device and retrieve device context

            // Bgra performs better especially with Direct2D software
            // render targets
            var creationFlags = DeviceCreationFlags.BgraSupport;
            #if DEBUG
            // Enable D3D device debug layer
            creationFlags |= DeviceCreationFlags.Debug;
            #endif

            // Retrieve the Direct3D 11.1 device and device context
            using (var device = new Device(DriverType.Hardware, creationFlags, Direct3DFeatureLevels))
            {
                d3dDevice = ToDispose(device.QueryInterface<Device1>());
            }

            // Get Direct3D 11.1 context
            d3dContext = ToDispose(d3dDevice.ImmediateContext.QueryInterface<DeviceContext1>());
            #endregion

            #region Create Direct2D device and context

            #if DEBUG
            var debugLevel = SharpDX.Direct2D1.DebugLevel.Information;
            #else
            var debugLevel = SharpDX.Direct2D1.DebugLevel.None;
            #endif

            // Allocate new references
            d2dFactory = ToDispose(new SharpDX.Direct2D1.Factory1(SharpDX.Direct2D1.FactoryType.SingleThreaded, debugLevel));
            dwriteFactory = ToDispose(new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared));
            wicFactory = ToDispose(new SharpDX.WIC.ImagingFactory2());

            // Create Direct2D device
            using (var dxgiDevice = d3dDevice.QueryInterface<SharpDX.DXGI.Device>())
            {
                d2dDevice = ToDispose(new SharpDX.Direct2D1.Device(d2dFactory, dxgiDevice));
            }

            // Create Direct2D context
            d2dContext = ToDispose(new SharpDX.Direct2D1.DeviceContext(d2dDevice, SharpDX.Direct2D1.DeviceContextOptions.None));
            #endregion
        }
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:60,代码来源:DeviceManager.cs


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