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


C# DeviceContext类代码示例

本文整理汇总了C#中DeviceContext的典型用法代码示例。如果您正苦于以下问题:C# DeviceContext类的具体用法?C# DeviceContext怎么用?C# DeviceContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: D3D11RenderingPane

        public D3D11RenderingPane( Factory dxgiFactory, SlimDX.Direct3D11.Device d3D11Device, DeviceContext d3D11DeviceContext, D3D11HwndDescription d3D11HwndDescription )
        {
            mDxgiFactory = dxgiFactory;
            mD3D11Device = d3D11Device;
            mD3D11DeviceContext = d3D11DeviceContext;

            var swapChainDescription = new SwapChainDescription
                                       {
                                           BufferCount = 1,
                                           ModeDescription =
                                               new ModeDescription( d3D11HwndDescription.Width,
                                                                    d3D11HwndDescription.Height,
                                                                    new Rational( 60, 1 ),
                                                                    Format.R8G8B8A8_UNorm ),
                                           IsWindowed = true,
                                           OutputHandle = d3D11HwndDescription.Handle,
                                           SampleDescription = new SampleDescription( 1, 0 ),
                                           SwapEffect = SwapEffect.Discard,
                                           Usage = Usage.RenderTargetOutput
                                       };

            mSwapChain = new SwapChain( mDxgiFactory, mD3D11Device, swapChainDescription );
            mDxgiFactory.SetWindowAssociation( d3D11HwndDescription.Handle, WindowAssociationFlags.IgnoreAll );

            CreateD3D11Resources( d3D11HwndDescription.Width, d3D11HwndDescription.Height );

            PauseRendering = false;
        }
开发者ID:Rhoana,项目名称:Mojo,代码行数:28,代码来源:D3D11RenderingPane.cs

示例2: Render

        public void Render(DeviceContext dc, EffectPass pass, Matrix view, Matrix proj)
        {
            var position = Particle.Position;
            Model.World = Matrix.Translation(position);

            Model.Draw(dc, pass, view, proj);
        }
开发者ID:remy22,项目名称:dx11,代码行数:7,代码来源:BallisticDemo.cs

示例3: WindowsGraphics

        // Construction/destruction API

        /// <include file='doc\WindowsGraphics.uex' path='docs/doc[@for="WindowsGraphics.WindowsGraphics"]/*' />
        public WindowsGraphics( DeviceContext dc )
        {
            Debug.Assert( dc != null, "null dc!");         
            this.dc = dc;
            this.dc.SaveHdc();
            //this.disposeDc = false; // the dc is not owned by this object.
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:10,代码来源:WindowsGraphics.cs

示例4: Draw

        public void Draw(Device device, DeviceContext context, RenderTargetView renderTargetView)
        {
            var deviceChanged = _device != device || _context != context;
            _device = device;
            _context = context;

            if (deviceChanged)
            {
                DrawingSurfaceState.Device = _device;
                DrawingSurfaceState.Context = _context;
                DrawingSurfaceState.RenderTargetView = renderTargetView;
            }

            if (!_game.Initialized)
            {
                // Start running the game.
                _game.Run(GameRunBehavior.Asynchronous);
            }
            else if (deviceChanged)
            {
                _game.GraphicsDevice.Initialize();

                Microsoft.Xna.Framework.Content.ContentManager.ReloadGraphicsContent();

                // DeviceReset events
                _game.graphicsDeviceManager.OnDeviceReset(EventArgs.Empty);
                _game.GraphicsDevice.OnDeviceReset();
            }

            _game.GraphicsDevice.UpdateTarget(renderTargetView);
            _game.GraphicsDevice.ResetRenderTargets();
            _game.Tick();

            _host.RequestAdditionalFrame();
        }
开发者ID:GhostTap,项目名称:MonoGame,代码行数:35,代码来源:SurfaceUpdateHandler.cs

示例5: ShaderPassCollection

        internal ShaderPassCollection(DeviceContext context, Shader shader, ShaderTechnique technique)
        {
            _passes = new ShaderPass[technique.PassCount];

            for (int i = 0; i < _passes.Length; i++)
                _passes[i] = new ShaderPass(context, shader, shader.Effect.GetPass(technique.Handle, i), i);
        }
开发者ID:TormentedEmu,项目名称:OpenUO,代码行数:7,代码来源:ShaderPassCollection.cs

示例6: DeviceContextWpf

        public DeviceContextWpf(DeviceSettings settings)
        {
            Contract.Requires(settings != null);

            Settings = settings;
            LogEvent.Engine.Log(settings.ToString());

            eventHandlerList = new EventHandlerList();

            LogEvent.Engine.Log(Resources.INFO_OE_DeviceCreating);
            //SwapChainDescription swapChainDesc = new SwapChainDescription
            //                                         {
            //                                             BufferCount = 1,
            //                                             ModeDescription =
            //                                                 new ModeDescription(Settings.ScreenWidth, Settings.ScreenHeight,
            //                                                                     new Rational(120, 1), Settings.Format),
            //                                             IsWindowed = true,
            //                                             OutputHandle =(new System.Windows.Interop.WindowInteropHelper(Global.Window)).Handle,
            //                                             SampleDescription = Settings.SampleDescription,
            //                                             SwapEffect = SwapEffect.Discard,
            //                                             Usage = Usage.RenderTargetOutput,
            //                                         };

            //LogEvent.Engine.Log(Resources.INFO_OE_DeviceCreating);
            //Device.CreateWithSwapChain(DriverType.Hardware, Settings.CreationFlags, swapChainDesc, out device, out swapChain);
            device = new Device(DriverType.Hardware, Settings.CreationFlags, FeatureLevel.Level_11_0);

            //if (!Settings.IsWindowed)

            immediate = device.ImmediateContext;

            CreateTargets();
            LogEvent.Engine.Log(Resources.INFO_OE_DeviceCreated);
            device.ImmediateContext.Flush();
        }
开发者ID:yong-ja,项目名称:starodyssey,代码行数:35,代码来源:DeviceContextWpf.cs

示例7: Engine

        public Engine(IoCContainer container)
        {
            _container = container;
            #if DEBUG_REFERENCES
            SharpDX.Configuration.EnableObjectTracking = true;
            SharpDX.Configuration.EnableReleaseOnFinalizer = true;
            #endif
            IDeviceContextService deviceContextService = _container.Resolve<IDeviceContextService>();

            _form = deviceContextService.Form;
            _context = deviceContextService.Context;

            _form.Icon = Resources.openuo;
            _form.Text = string.Format("OpenUO v{0}", new AssemblyInfo(Assembly.GetEntryAssembly()).Version);
            _form.ResizeBegin += OnResizeBegin;
            _form.ResizeEnd += OnResizeEnd;
            _form.FormClosed += OnFormClosed;

            _updateState = new UpdateState();
            _gameTime = new GameTime();
            _world = new World(container);

            container.Resolve<IConsole>().WriteLine("Testing 123");

            _config = _container.Resolve<IConfiguration>();
            _updateChain = _container.Resolve<IChain<UpdateState>>();
            _worldRenderChain = _container.Resolve<IWorldRenderChain>();
            _uiRenderChain = _container.Resolve<IUIRenderChain>();

            _screenTarget = new DrawScreenTarget(_context);

            _updateChain.Freeze();
            _worldRenderChain.Freeze();
            _uiRenderChain.Freeze();
        }
开发者ID:TormentedEmu,项目名称:OpenUO,代码行数:35,代码来源:Engine.cs

示例8: ClearRenderTarget

 public override void ClearRenderTarget(DeviceContext context, Color4 color)
 {
     foreach (RenderTargetView view in renderTargetView)
     {
         context.ClearRenderTargetView(view, color);
     }
 }
开发者ID:nickudell,项目名称:PigmentFramework,代码行数:7,代码来源:MultiRenderTexture.cs

示例9: FromFile

 public static Texture2D FromFile(DeviceContext context, string file, Usage usage, Pool pool)
 {
     using (var stream = File.OpenRead(file))
     {
         return FromStream(context, stream, usage, pool);
     }
 }
开发者ID:TormentedEmu,项目名称:OpenUO,代码行数:7,代码来源:Texture2D.cs

示例10: Restore

		public void Restore(DeviceContext context)
		{
			context.InputAssembler.PrimitiveTopology = this.topology;
			context.InputAssembler.InputLayout = this.layout;
			context.Rasterizer.SetViewports(this.viewports);
			context.Rasterizer.SetScissorRectangles(this.scissorRectangles);
			context.Rasterizer.State = this.rasterizerState;
			context.OutputMerger.SetBlendState(this.blendState, this.blendFactor, this.sampleMaskRef);
			context.OutputMerger.SetDepthStencilState(this.depthState, this.stencilRefRef);
			context.OutputMerger.SetRenderTargets(this.depthStencilView, this.renderTargetView[0]);

			context.PixelShader.Set(this.ps);
			context.PixelShader.SetConstantBuffers(0, this.psConstantBuffers);
			context.PixelShader.SetSamplers(0, this.psSamplers);
			context.PixelShader.SetShaderResources(0, this.psResources);

			context.VertexShader.Set(this.vs);
			context.VertexShader.SetConstantBuffers(0, this.vsConstantBuffers);
			context.VertexShader.SetSamplers(0, this.vsSamplers);
			context.VertexShader.SetShaderResources(0, this.vsResources);

			context.InputAssembler.SetIndexBuffer(this.ib, this.ibFormat, this.ibOffset);
			context.InputAssembler.SetVertexBuffers(0, this.vb, this.vbStride, this.vbOffset);

			this.renderTargetView[0].Dispose();
			this.depthStencilView.Dispose();
		}
开发者ID:aienabled,项目名称:NoesisGUI.MonoGameWrapper,代码行数:27,代码来源:DeviceDX11StateHelper.cs

示例11: RegisterDebug

 public static void RegisterDebug(DeviceContext context, string name, RenderTargetSet debuggedRT)
 {
     if (m_AvailableModes.Contains(name))
     {
         if (m_CurrentDebugSurface == name)
         {
             if (m_CurrentDebugMode == "A")
             {
                 PostEffectHelper.CopyAlpha(context, m_DebugRenderTarget, debuggedRT);
             }
             else if (m_CurrentDebugMode == "FRAC")
             {
                 PostEffectHelper.CopyFrac(context, m_DebugRenderTarget, debuggedRT);
             }
             else
             {
                 PostEffectHelper.Copy(context, m_DebugRenderTarget, debuggedRT);
             }
         }
     }
     else
     {
         m_IsUIRebuildRequired = true;
         m_AvailableModes.Add(name);
     }
 }
开发者ID:shoff,项目名称:CSharpRenderer,代码行数:26,代码来源:SurfaceDebugManager.cs

示例12: Minimap

        public Minimap(Device device, DeviceContext dc, int minimapWidth, int minimapHeight, Terrain terrain, CameraBase viewCam)
        {
            _dc = dc;

            _minimapViewport = new Viewport(0, 0, minimapWidth, minimapHeight);

            CreateMinimapTextureViews(device, minimapWidth, minimapHeight);

            _terrain = terrain;

            SetupOrthoCamera();
            _viewCam = viewCam;

            // frustum vb will contain four corners of view frustum, with first vertex repeated as the last
            var vbd = new BufferDescription(
                VertexPC.Stride * 5,
                ResourceUsage.Dynamic,
                BindFlags.VertexBuffer,
                CpuAccessFlags.Write,
                ResourceOptionFlags.None,
                0
            );
            _frustumVB = new Buffer(device, vbd);

            _edgePlanes = new[] {
            new Plane(1, 0, 0, -_terrain.Width / 2),
            new Plane(-1, 0, 0, _terrain.Width / 2),
            new Plane(0, 1, 0, -_terrain.Depth / 2),
            new Plane(0, -1, 0, _terrain.Depth / 2)
            };

            ScreenPosition = new Vector2(0.25f, 0.75f);
            Size = new Vector2(0.25f, 0.25f);
        }
开发者ID:jackinf,项目名称:dx11,代码行数:34,代码来源:Minimap.cs

示例13: DX11RenderContext

 public DX11RenderContext(Device device)
 {
     this.Device = device;
     this.immediatecontext = this.Device.ImmediateContext;
     this.immediatecontext.Dispose(); //Remove ref
     this.CurrentDeviceContext = this.immediatecontext;
 }
开发者ID:joreg,项目名称:FeralTic,代码行数:7,代码来源:DX11RenderContext.cs

示例14: Render

 public void Render(DeviceContext deviceContext, Matrix viewMatrix, Matrix projectionMatrix, Light light, ICamera camera)
 {
     _skydome.Render(deviceContext);
     _shader.Render(deviceContext, _skydome.IndexCount,
         Matrix.Scaling(10000) * Matrix.RotationY(MathUtil.PiOverTwo - _angle / 8), viewMatrix,
         projectionMatrix, _skydome.Texture, light, camera);
 }
开发者ID:ndech,项目名称:Alpha,代码行数:7,代码来源:Sky.cs

示例15: Render

 public void Render(DeviceContext context, vsBuffer vsBuffer, psBuffer psBuffer)
 {
     foreach (Model model in models)
     {
         model.Render(context, vsBuffer, psBuffer);
     }
 }
开发者ID:sinushawa,项目名称:ROD,代码行数:7,代码来源:Scene.cs


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