當前位置: 首頁>>代碼示例>>C#>>正文


C# GraphicsDevice.Clear方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear方法的典型用法代碼示例。如果您正苦於以下問題:C# GraphicsDevice.Clear方法的具體用法?C# GraphicsDevice.Clear怎麽用?C# GraphicsDevice.Clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.Graphics.GraphicsDevice的用法示例。


在下文中一共展示了GraphicsDevice.Clear方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Run

        public void Run()
        {
            using (var form = CreateForm())
            {
                PresentationParameters presentationParameters = CreatePresentationParameters();

                var device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware,
                    form.Handle, presentationParameters);

                Application.Idle +=
                    delegate
                    {
                        device.Clear(Color.Blue);

                        device.Present();

                        Application.DoEvents();
                    };

                Application.Run(form);
            }
        }
開發者ID:Christof,項目名稱:afterglow,代碼行數:22,代碼來源:EmptyWindow.cs

示例2: ToneMap

        private void ToneMap(Renderer renderer, Vector2 resolution, GraphicsDevice device, Texture2D lightBuffer)
        {
            var toneMapped = RenderTargetManager.GetTarget(device, (int)resolution.X, (int)resolution.Y, SurfaceFormat.Color, depthFormat: DepthFormat.Depth24Stencil8, name: "tone mapped", usage: RenderTargetUsage.DiscardContents);
            device.SetRenderTarget(toneMapped);
            device.Clear(Color.Transparent);
            device.DepthStencilState = DepthStencilState.None;
            device.BlendState = BlendState.Opaque;

            _toneMap.Parameters["Texture"].SetValue(lightBuffer);
            _toneMap.Parameters["Luminance"].SetValue(_adaptedLuminance[_current]);
            _toneMap.Parameters["MinExposure"].SetValue(renderer.Data.GetValue(new TypedName<float>("hdr_minexposure")));
            _toneMap.Parameters["MaxExposure"].SetValue(renderer.Data.GetValue(new TypedName<float>("hdr_maxexposure")));
            _quad.Draw(_toneMap, renderer.Data);
            Output("tonemapped", toneMapped);
        }
開發者ID:xoxota99,項目名稱:Myre,代碼行數:15,代碼來源:ToneMapComponent.cs

示例3: CalculateLuminance

        private void CalculateLuminance(Renderer renderer, Vector2 resolution, GraphicsDevice device, Texture2D lightBuffer)
        {
            if (_previous == -1)
            {
                _previous = 1;
                device.SetRenderTarget(_adaptedLuminance[_previous]);
                device.Clear(Color.Transparent);
                device.SetRenderTarget(null);
            }

            var tmp = _previous;
            _previous = _current;
            _current = tmp;

            // calculate luminance map
            var luminanceMap = RenderTargetManager.GetTarget(device, 1024, 1024, SurfaceFormat.Single, mipMap: true, name: "luminance map", usage: RenderTargetUsage.DiscardContents);
            device.SetRenderTarget(luminanceMap);
            device.BlendState = BlendState.Opaque;
            device.Clear(Color.Transparent);
            _calculateLuminance.Parameters["Texture"].SetValue(lightBuffer);
            _quad.Draw(_calculateLuminance, renderer.Data);
            Output("luminance", luminanceMap);

            // read bottom mipmap to find average luminance
            _averageLuminance = RenderTargetManager.GetTarget(device, 1, 1, SurfaceFormat.Single, name: "average luminance", usage: RenderTargetUsage.DiscardContents);
            device.SetRenderTarget(_averageLuminance);
            _readLuminance.Parameters["Texture"].SetValue(luminanceMap);
            _quad.Draw(_readLuminance, renderer.Data);

            // adapt towards the current luminance
            device.SetRenderTarget(_adaptedLuminance[_current]);
            _adaptLuminance.Parameters["Texture"].SetValue(_averageLuminance);
            _adaptLuminance.Parameters["PreviousAdaption"].SetValue(_adaptedLuminance[_previous]);
            _quad.Draw(_adaptLuminance, renderer.Data);

            RenderTargetManager.RecycleTarget(_averageLuminance);
        }
開發者ID:xoxota99,項目名稱:Myre,代碼行數:37,代碼來源:ToneMapComponent.cs

示例4: Create

        public void Create(bool fullscreen, int width, int height, bool audio)
        {
            GraphicsDevice Device;
            Window = new Form();
            Window.ClientSize = new System.Drawing.Size(width, height);

            Window.Show();

            //GraphicsAdapter.DefaultAdapter.
            PresentationParameters param=new PresentationParameters();
            param.BackBufferCount=1;
            //param.BackBufferFormat=SurfaceFormat.Rgba32;
            param.BackBufferHeight=height;
            param.BackBufferWidth=width;
            //param.FullScreenRefreshRateInHz=60;
            param.IsFullScreen=fullscreen;
            param.PresentFlag=PresentFlag.None;
            param.SwapEffect=fullscreen?SwapEffect.Flip:SwapEffect.Discard;
            param.PresentationInterval=PresentInterval.One;
            param.AutoDepthStencilFormat = DepthFormat.Depth16;
            param.BackBufferFormat = SurfaceFormat.Bgr32;
            param.EnableAutoDepthStencil = true;
            param.PresentationInterval = PresentInterval.Immediate;

            try
            {
                Device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, Window.Handle, CreateOptions.HardwareVertexProcessing, param);
            }
            catch (InvalidCallException e)
            {
                System.Console.WriteLine(e.Message);
                System.Console.WriteLine(e.ErrorCode);
                throw e;
            }

            Device.Clear(new Color(0, 0, 0, 1));
            Device.Present();

            renderer = new XnaRenderer(Device);
        }
開發者ID:cody82,項目名稱:spacewar-arena,代碼行數:40,代碼來源:xna.cs


注:本文中的Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。