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


C# GraphicsDevice.Present方法代码示例

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


在下文中一共展示了GraphicsDevice.Present方法的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: Run

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

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

                Vertex[] vertices = CreateVertices();

                var vertexBuffer = new VertexBuffer(device,
                    typeof(Vertex), vertices.Length, BufferUsage.None);

                vertexBuffer.SetData(vertices, 0, vertices.Length);

                var indices = CreateIndices();
                var indexBuffer = new IndexBuffer(device,
                    sizeof (int) * indices.Length, BufferUsage.None,
                    IndexElementSize.ThirtyTwoBits);
                indexBuffer.SetData(indices);

                VertexDeclaration vertexDeclaration = TriangleWithVertexBuffer.CreateVertexDeclaration(device);

                var basicEffect = new BasicEffect(device, new EffectPool())
                {
                    LightingEnabled = false,
                    TextureEnabled = false,
                    VertexColorEnabled = true
                };

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

                        device.VertexDeclaration = vertexDeclaration;
                        device.Vertices[0].SetSource(vertexBuffer, 0, 24);
                        device.Indices = indexBuffer;
                        device.RenderState.CullMode = CullMode.None;

                        basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(
                            (float)(System.Math.PI / 3), 800f / 600.0f, 0.01f, 100f);
                        basicEffect.View = Matrix.CreateLookAt(
                            new Vector3(0, 0, -3), new Vector3(), new Vector3(0, 1, 0));
                        basicEffect.World = Matrix.Identity;

                        basicEffect.Begin();
                        foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                        {
                            pass.Begin();

                            device.DrawIndexedPrimitives(PrimitiveType.TriangleList,
                                0, 0, vertices.Length, 0, 2);

                            pass.End();
                        }

                        basicEffect.End();

                        device.Present();

                        Application.DoEvents();
                    };

                Application.Run(form);
            }
        }
开发者ID:Christof,项目名称:afterglow,代码行数:68,代码来源:QuadWithVertexAndIndexBuffer.cs

示例3: DrawRightEye

        private void DrawRightEye(GameTime time, Vector3 eyePosition, RenderModes mode, GraphicsDevice device,
                                  SpriteBatch sb)
        {
            switch (mode)
            {
                case RenderModes.StereoCrossConverged:
                    device.SetRenderTarget(0, (_takeScreenshot ? _screenshotTargetRight : _rightEyeRender));
                    break;
                case RenderModes.Stereo:
                    // Draw on the extra created window
                    device.Present(_stereoRightHandle);
                    break;
            }

            device.Clear(ClearColor);

            // Setup camera for right eye
            // Translate look at direction to new eye position
            const float focusDistance = 10.0f;
            Vector3 lookAtVector = Vector3.Normalize(Camera.LookAt - Camera.Position);
            Camera.LookAt = Camera.Position + focusDistance*lookAtVector;
            Camera.Position = eyePosition;
            Camera.UpdateMatrices();

            _basicEffect.View = Camera.View; 
            base.Draw(time);

            // Print FPS
            if (ShowFPS)
            {
                string fpsText = "FPS: " + _fpsUtil.Value;
                PrintInfo(sb, new Vector2(0.9f*_screenWidth, 0), fpsText);
            }
        }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:34,代码来源:SimulatorGame.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.Present方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。