• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DeviceContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GraphicsDeviceService

        public GraphicsDeviceService()
        {
            System.Windows.Forms.Control control = new System.Windows.Forms.Panel();

            deviceInformation = new GraphicsDeviceInformation()
            {
                GraphicsProfile = FeatureLevel.Level_11_0,
                DeviceCreationFlags = SharpDX.Direct3D11.DeviceCreationFlags.Debug,
                PresentationParameters = new PresentationParameters()
                {
                    BackBufferFormat = SharpDX.DXGI.Format.R8G8B8A8_UNorm,
                    DepthStencilFormat = DepthFormat.Depth32,
                    DepthBufferShaderResource = true,
                    BackBufferWidth = 1920,
                    BackBufferHeight = 1080,
                    IsFullScreen = false,
                    RenderTargetUsage = SharpDX.DXGI.Usage.RenderTargetOutput,
                    MultiSampleCount = MSAALevel.None,
                    DeviceWindowHandle = control
                }
            };

            FindAdapter();

            graphicsDevice = GraphicsDevice.New(deviceInformation.Adapter, deviceInformation.DeviceCreationFlags);

            renderTarget = RenderTarget2D.New(graphicsDevice, 1920, 1080, PixelFormat.B8G8R8A8.UNorm);
            graphicsDevice.Presenter = new RenderTargetGraphicsPresenter(graphicsDevice, renderTarget, DepthFormat.Depth32, false);

            dxDevice = (Device)typeof(GraphicsDevice).GetField("Device", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(GraphicsDevice);
            dxContext = (DeviceContext)typeof(GraphicsDevice).GetField("Context", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(GraphicsDevice);

            if (DeviceCreated != null)
                DeviceCreated(this, EventArgs.Empty);
        }
开发者ID:ukitake,项目名称:Stratum,代码行数:35,代码来源:GraphicsDeviceService.cs


示例17: UpdateBuffer

        /****************************************************************************************************
         * 
         ****************************************************************************************************/
        public void UpdateBuffer(DeviceContext context, Matrix world, ICamera camera)
        {
            var view = camera.CreateViewMatrix();
            var projection = camera.CreateProjectionMatrix(Resolution);
            Matrices[0] = Matrix.Transpose(world);
            Matrices[1] = Matrix.Transpose(view);
            Matrices[2] = Matrix.Transpose(projection);
            Matrices[3] = Matrix.Transpose(world * view);
            Matrices[4] = Matrix.Transpose(world * view * projection);
            Matrices[5] = Matrix.Transpose(view * projection);
            Matrices[6] = Matrix.Invert(world);
            Matrices[7] = Matrix.Invert(world * view);
            Matrices[8] = Matrix.Transpose(Matrix.Identity * Matrix.Scaling(LightPosition));
            Matrices[9] = new Matrix(new float[] 
            {
                LerpTime, AbsoluteTime, Resolution.X, Resolution.Y,
                BeatTime, Lead,0,0,
                Nisse0, Nisse1, Nisse2, Nisse3,
                0,0,0,0,
            });
            if (Buffer == null)
            {
                Buffer = new Buffer(context.Device, Matrices.Length * Utilities.SizeOf<Matrix>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
            }

            context.UpdateSubresource(Matrices, Buffer);
        }
开发者ID:JoltSoftwareDevelopment,项目名称:Jolt.MashRoom,代码行数:30,代码来源:ShaderEnvironment.cs


示例18: Draw

 public static void Draw(DeviceContext device)
 {
     foreach (Camera c in Cameras)
     {
         c.Draw(device);
     }
 }
开发者ID:eldernos,项目名称:SlimDXEngine,代码行数:7,代码来源:ObjectManager.cs


示例19: Begin

        public override void Begin(DeviceContext Context)
        {
            base.Begin(Context);
            if (pLightBuffer.ElementsCount != Lights.Count() & Lights.Count() != 0)
            {
                maxLights = Lights.Count();
                pLightBuffer.Resize(Lights.Count());
                plStruct = new PointLightStruct[maxLights];
            }
            for (int i = 0; i < maxLights; i++)
            {
                if (Lights.Count() - 1 < i)
                    plStruct[i] = default(PointLightStruct);
                else if (Lights[i] is PointLight)
                {
                    PointLight l = Lights[i] as PointLight;
                    plStruct[i].positionView = MathHelper.ToVector3(Vector3.Transform(l.Position, Renderer.Camera.MatrixView));
                    plStruct[i].attenuationBegin = 0.1f;
                    plStruct[i].color = l.Color;
                    plStruct[i].attenuationEnd = l.Radius;
                }
            }
            pLightBuffer.FillBuffer(Renderer.Context, plStruct);
            cBuffer.FillBuffer(Context);
            Context.PixelShader.Set(GBuffer.PixelShader);

            // Set up render GBuffer render targets
            Context.OutputMerger.SetTargets(Renderer.BackBufferDepth, GBuffer.RenderTargets);
            Context.OutputMerger.DepthStencilState = mDepthState;
            Context.OutputMerger.BlendState = mGeometryBlendState;
        }
开发者ID:RomanHodulak,项目名称:DeferredLightingD3D11,代码行数:31,代码来源:DeferredQuadLighting.cs


示例20: Draw

 internal void Draw(DeviceContext context)
 {
     foreach (PositionedObject po in positionedObjects.OrderByDescending(x => (cameraBelongsTo.Position - x.Position).LengthSquared()))
     {
         po.Draw(context);
     }
 }
开发者ID:eldernos,项目名称:SlimDXEngine,代码行数:7,代码来源:Layer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DeviceInfo类代码示例发布时间:2022-05-24
下一篇:
C# Device类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap