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


C# Device.Clear方法代码示例

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


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

示例1: loop

 public override void loop(Device i_d3d)
 {
     lock (this._ss)
     {
         this._ms.update(this._ss);
         this._rs.drawBackground(i_d3d, this._ss.getSourceImage());
         i_d3d.BeginScene();
         i_d3d.Clear(ClearFlags.ZBuffer, Color.DarkBlue, 1.0f, 0);
         if (this._ms.isExistMarker(this.mid1))
         {
             //立方体を20mm上(マーカーの上)にずらしておく
             Matrix transform_mat2 = Matrix.Translation(0, 0, 20.0f);
             //変換行列を掛ける
             transform_mat2 *= this._ms.getD3dMarkerMatrix(this.mid1);
             // 計算したマトリックスで座標変換
             i_d3d.SetTransform(TransformType.World, transform_mat2);
             // レンダリング(描画)
             this._rs.colorCube(i_d3d, 40);
         }
         if (this._ms.isExistMarker(this.mid2))
         {
             //立方体を20mm上(マーカーの上)にずらしておく
             Matrix transform_mat2 = Matrix.Translation(0, 0, 20.0f);
             //変換行列を掛ける
             transform_mat2 *= this._ms.getD3dMarkerMatrix(this.mid2);
             // 計算したマトリックスで座標変換
             i_d3d.SetTransform(TransformType.World, transform_mat2);
             // レンダリング(描画)
             this._rs.colorCube(i_d3d, 40);
         }
         i_d3d.EndScene();
     }
     i_d3d.Present();
 }
开发者ID:whztt07,项目名称:NyARToolkitCS,代码行数:34,代码来源:Program.cs

示例2: Main

        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var form = new Form1();

            var panel = form.SplitContainer.Panel1;

            var device = new Device(new Direct3D(), 0, DeviceType.Hardware, panel.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters()
            {
                BackBufferWidth = panel.ClientSize.Width,
                BackBufferHeight = panel.ClientSize.Height

            });

            var vertices = new VertexBuffer(device, 3 * 20, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
            vertices.Lock(0, 0, LockFlags.None).WriteRange(new[] {
                new Vertex() { Color = Color.Red.ToArgb(), Position = new Vector4(400.0f, 100.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Blue.ToArgb(), Position = new Vector4(650.0f, 500.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Green.ToArgb(), Position = new Vector4(150.0f, 500.0f, 0.5f, 1.0f) }
            });
            vertices.Unlock();

            var vertices2 = new VertexBuffer(device, 3 * 20, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
            vertices2.Lock(0, 0, LockFlags.None).WriteRange(new[] {
                new Vertex() { Color = Color.Red.ToArgb(), Position = new Vector4(300.0f, 100.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Blue.ToArgb(), Position = new Vector4(550.0f, 500.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Green.ToArgb(), Position = new Vector4(050.0f, 500.0f, 0.5f, 1.0f) }
            });
            vertices2.Unlock();

            var vertexElems = new[] {
                new VertexElement(0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.PositionTransformed, 0),
                new VertexElement(0, 16, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
                VertexElement.VertexDeclarationEnd
            };

            var vertexDecl = new VertexDeclaration(device, vertexElems);

            MessagePump.Run(form, () =>
            {
                device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                device.BeginScene();

                device.SetStreamSource(0, vertices, 0, 20);
                device.VertexDeclaration = vertexDecl;
                device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

                device.SetStreamSource(0, vertices2, 0, 20);
                device.VertexDeclaration = vertexDecl;
                device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

                device.EndScene();
                device.Present();
            });

            foreach (var item in ObjectTable.Objects)
                item.Dispose();
        }
开发者ID:duk3luk3,项目名称:KSPEdit,代码行数:60,代码来源:Program.cs

示例3: MafiaVideo

        public MafiaVideo(Form form, bool fullscreen)
        {
            this.form = form;
            this.fullscreen = fullscreen;

            if (fullscreen)
            {
                form.FormBorderStyle = FormBorderStyle.None;
            }
            else
            {
                form.FormBorderStyle = FormBorderStyle.Sizable;
            }

            try
            {
                device = new Device(0, DeviceType.Hardware, form, CreateFlags.HardwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
            }
            catch (InvalidCallException)
            {
                try
                {
                    device = new Device(0, DeviceType.Hardware, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
                }
                catch (InvalidCallException)
                {
                    try
                    {
                        device = new Device(0, DeviceType.Software, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
                    }
                    catch (InvalidCallException)
                    {
                        throw new Exception("Direct3Dデバイスの生成に失敗しました。");
                    }
                }
            }
            deviceLost = new EventHandler(OnDeviceLost);
            deviceReset = new EventHandler(OnDeviceReset);
            deviceResizing = new CancelEventHandler(OnDeviceResizing);
            device.DeviceLost += deviceLost;
            device.DeviceReset += deviceReset;
            device.DeviceResizing += deviceResizing;
            device.Clear(ClearFlags.Target, Color.FromArgb(212, 208, 200), 0.0f, 0);

            sprite = new Sprite(device);

            backBuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
            offScreenImage = new Texture(device, Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT, 1, Usage.RenderTarget, Manager.Adapters[0].CurrentDisplayMode.Format, Pool.Default);
            offScreenSurface = offScreenImage.GetSurfaceLevel(0);

            texture = MafiaLoader.DefaultLoader.GetTexture(device, "mafia.bmp");

            if (fullscreen)
            {
                Cursor.Hide();
            }

            // form.ClientSize = new Size(Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT);
            form.ClientSize = new Size(Mafia.SCREEN_WIDTH * 2, Mafia.SCREEN_HEIGHT * 2);
        }
开发者ID:sinshu,项目名称:mafia,代码行数:60,代码来源:MafiaVideo.cs

示例4: Form1

        public Form1()
        {
            InitializeComponent();

            m_Device = new Device();
            m_Device.Init( panel1.Handle, false, false );

            m_Shader_RenderCellPlanes = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "RenderCellPlanes.hlsl" ) ), VERTEX_FORMAT.T2, "VS", null, "PS", null );
            m_Shader_RenderCellMesh = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "RenderCellMesh.hlsl" ) ), VERTEX_FORMAT.P3N3, "VS", null, "PS", null );
            m_Shader_RenderCellMesh_Opaque = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "RenderCellMesh_Opaque.hlsl" ) ), VERTEX_FORMAT.P3N3, "VS", null, "PS", null );
            m_Shader_PostProcess = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "PostProcess.hlsl" ) ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null );
            m_Shader_PostProcess2 = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "PostProcess.hlsl" ) ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null );

            VertexT2[]	Vertices = new VertexT2[4] {
                new VertexT2() { UV = new float2( 0, 0 ) },
                new VertexT2() { UV = new float2( 0, 1 ) },
                new VertexT2() { UV = new float2( 1, 0 ) },
                new VertexT2() { UV = new float2( 1, 1 ) },
            };
            m_Prim_Quad = new Primitive( m_Device, 4, VertexT2.FromArray( Vertices ), null, Primitive.TOPOLOGY.TRIANGLE_STRIP, VERTEX_FORMAT.T2 );

            m_RT_WorldPositions[0] = new Texture2D( m_Device, panel1.Width, panel1.Height, 1, 1, PIXEL_FORMAT.RGBA32_FLOAT, false, false, null );
            m_RT_WorldPositions[1] = new Texture2D( m_Device, panel1.Width, panel1.Height, 1, 1, PIXEL_FORMAT.RGBA32_FLOAT, false, false, null );
            m_Device.Clear( m_RT_WorldPositions[0], float4.Zero );
            m_Device.Clear( m_RT_WorldPositions[1], float4.Zero );

            // Setup camera
            m_CB_Camera = new ConstantBuffer< CB_Camera >( m_Device, 0 );
            m_CB_Mesh = new ConstantBuffer< CB_Mesh >( m_Device, 1 );

            m_Camera.CreatePerspectiveCamera( 120.0f * (float) Math.PI / 180.0f, (float) panel1.Width / panel1.Height, 0.01f, 100.0f );
            m_Camera.CameraTransformChanged += new EventHandler( Camera_CameraTransformChanged );

            m_CameraManipulator.Attach( panel1, m_Camera );
            m_CameraManipulator.InitializeCamera( -0.1f * float3.UnitZ, float3.Zero, float3.UnitY );

            // Initalize random neighbors
            integerTrackbarControlNeighborsCount_ValueChanged( integerTrackbarControlNeighborsCount, 0 );

            Application.Idle += new EventHandler( Application_Idle );
        }
开发者ID:Patapom,项目名称:GodComplex,代码行数:41,代码来源:Form1.cs

示例5: TextureViewer_Load

        void TextureViewer_Load(object sender, EventArgs e)
        {
            this.Show();
            Application.DoEvents();
            pp = new PresentParameters();
            pp.BackBufferCount = 2;
            pp.SwapEffect = SwapEffect.Discard;
            pp.Windowed = true;

            Direct3D d3d = new Direct3D();
            d3d_device = new Device(d3d, 0, DeviceType.Hardware, d3dPanel.Handle, CreateFlags.HardwareVertexProcessing, pp);
            texture = Texture.FromFile(d3d_device, texturePath);

            int texWidth = texture.GetLevelDescription(0).Width;
            int texHeight = texture.GetLevelDescription(0).Height;
            d3dPanel.Top = menuStrip1.Height;
            d3dPanel.Left = 0;
            d3dPanel.ClientSize = new Size(texWidth, texHeight);
            this.ClientSize = new System.Drawing.Size(
                d3dPanel.Width,
                d3dPanel.Height + menuStrip1.Height
            );
            pp.BackBufferWidth = texWidth;
            pp.BackBufferHeight = texHeight;

            d3d_device.Reset(pp);
            sprite = new Sprite(d3d_device);

            while (this.Visible)
            {
                d3d_device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, new Color4(Color.Black), 1.0f, 0);
                d3d_device.BeginScene();
                sprite.Begin(SpriteFlags.AlphaBlend);
                Rectangle rect = new Rectangle()
                {
                    X = 0,
                    Y = 0,
                    Width = texture.GetLevelDescription(0).Width,
                    Height = texture.GetLevelDescription(0).Height
                };
                sprite.Draw(texture, rect, new Color4(Color.White));
                sprite.End();
                d3d_device.EndScene();
                d3d_device.Present();
                Application.DoEvents();
            }
        }
开发者ID:anirnet,项目名称:raf-manager,代码行数:47,代码来源:TextureViewer.cs

示例6: MainWindow_OnLoaded

        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            var bmp = new WriteableBitmap(640, 480, 32, 32, PixelFormats.Bgra32, null);

            _device = new Device(bmp);

            _image.Source = bmp;

            var mesh = new Mesh("Cube", 8, 12);
            meshes.Add(mesh);
            mesh.Vertices[0] = new Vector3(-1, 1, 1);
            mesh.Vertices[1] = new Vector3(1, 1, 1);
            mesh.Vertices[2] = new Vector3(-1, -1, 1);
            mesh.Vertices[3] = new Vector3(1, -1, 1);
            mesh.Vertices[4] = new Vector3(-1, 1, -1);
            mesh.Vertices[5] = new Vector3(1, 1, -1);
            mesh.Vertices[6] = new Vector3(1, -1, -1);
            mesh.Vertices[7] = new Vector3(-1, -1, -1);

            mesh.Faces[0] = new Face { A = 0, B = 1, C = 2 };
            mesh.Faces[1] = new Face { A = 1, B = 2, C = 3 };
            mesh.Faces[2] = new Face { A = 1, B = 3, C = 6 };
            mesh.Faces[3] = new Face { A = 1, B = 5, C = 6 };
            mesh.Faces[4] = new Face { A = 0, B = 1, C = 4 };
            mesh.Faces[5] = new Face { A = 1, B = 4, C = 5 };

            mesh.Faces[6] = new Face { A = 2, B = 3, C = 7 };
            mesh.Faces[7] = new Face { A = 3, B = 6, C = 7 };
            mesh.Faces[8] = new Face { A = 0, B = 2, C = 7 };
            mesh.Faces[9] = new Face { A = 0, B = 4, C = 7 };
            mesh.Faces[10] = new Face { A = 4, B = 5, C = 6 };
            mesh.Faces[11] = new Face { A = 4, B = 6, C = 7 };

            camera.Position = new Vector3(0, 0, 10.0f);
            camera.Target = Vector3.Zero;

            CompositionTarget.Rendering += (o, args) => {
                _device.Clear(0, 0, 0, 255);

                mesh.Rotation = new Vector3(mesh.Rotation.X + 0.01f, mesh.Rotation.Y + 0.01f, mesh.Rotation.Z);

                _device.Render(camera, mesh);
                _device.Present();
            };
        }
开发者ID:LambdaSix,项目名称:SoftEngine,代码行数:45,代码来源:MainWindow.xaml.cs

示例7: OnFrameRender

        /// <summary>
        /// This callback function will be called at the end of every frame to perform all the 
        /// rendering calls for the scene, and it will also be called if the window needs to be 
        /// repainted. After this function has returned, the sample framework will call 
        /// Device.Present to display the contents of the next buffer in the swap chain
        /// </summary>
        public void OnFrameRender(Device device, double appTime, float elapsedTime) {
            bool beginSceneCalled = false;

            // Clear the render target and the zbuffer 
            device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, unchecked((int)0x8C003F3F), 1.0f, 0);
            try {
                device.BeginScene();
                beginSceneCalled = true;

                // Render the arrows so the user can visually see the light direction
                ColorValue arrowColor = LightColor;
                lightControl.OnRender(arrowColor, camera.ViewMatrix, camera.ProjectionMatrix, camera.EyeLocation);

                if(nif!=null) {
                    // Update the effects now
                    Vector3 ldir=lightControl.LightDirection;
                    Vector3 edir=-camera.EyeVector;
                    Vector3 hdir=ldir+edir;
                    hdir.Normalize();
                    float[] dir=new float[] { ldir.X, ldir.Y, ldir.Z };
                    effect.SetValue(ehLightDir, dir);
                    effect.SetValue(ehLightCol, ColorOperator.Scale(LightColor, lightScale));
                    effect.SetValue(egAmbCol, ColorOperator.Scale(AmbientLightColor, ambLightScale));
                    effect.SetValue(ehViewProj, camera.ViewMatrix * camera.ProjectionMatrix);
                    dir=new float[] { camera.EyeLocation.X, camera.EyeLocation.Y, camera.EyeLocation.Z };
                    effect.SetValue(ehEyePos, dir);
                    dir=new float[] { edir.X, edir.Y, edir.Z };
                    effect.SetValue(ehEyeVec, dir);
                    dir=new float[] { hdir.X, hdir.Y, hdir.Z };
                    effect.SetValue(ehHalfVec, dir);

                    // Apply the technique contained in the effect
                    if(currentSubset==-1) nif.Render();
                    else nif.RenderSubset(currentSubset);
                }

                // Show frame rate and help, etc
                RenderText(appTime);

                // Show UI
                hud.OnRender(elapsedTime);
                sampleUi.OnRender(elapsedTime);
            } finally {
                if(beginSceneCalled) device.EndScene();
            }
        }
开发者ID:IntegralLee,项目名称:fomm,代码行数:52,代码来源:BasicHLSL.cs

示例8: Render

        /// <summary>
        /// シーンを描画
        /// </summary>
        public void Render(Device device)
        {
            device.Clear(ClearFlags.All, Color.Black, 1, 0);
            _view.Render(device);

            //ライト設定
            device.SetRenderState(RenderState.Lighting, true);
            foreach(var item in _lights.Select((l, i)=>new {l, i})){
                device.SetLight(item.i, item.l);
                device.EnableLight(item.i, true);
            }

            _drawables.ForEach(d => d.Draw(device));
        }
开发者ID:ousttrue,项目名称:csmeshio,代码行数:17,代码来源:Scene.cs

示例9: Start

        public override void Start()
        {
            base.Start();
            var form = new RenderForm("02_vertex_and_fragment_program");
            this.device = new Device(new Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters
                                                                                                                                {
                                                                                                                                    BackBufferWidth = form.ClientSize.Width,
                                                                                                                                    BackBufferHeight = form.ClientSize.Height
                                                                                                                                });
            int vertexCount = 0;

            for (int i = 0; i < MyStarCount; i++)
            {
                vertexCount += myStarList[i].Points * 2 + 2;
            }

            vertexBuffer = new VertexBuffer(device, vertexCount * 12, Usage.WriteOnly, VertexFormat.Position, Pool.Default);

            Vector3[] starVertices = new Vector3[vertexCount];
            var dataStream = vertexBuffer.Lock(0, 0, LockFlags.Discard);
            for (int i = 0, n = 0; i < myStarList.Length; i++)
            {
                double piOverStarPoints = 3.14159 / myStarList[i].Points;
                float x = myStarList[i].X,
                      y = myStarList[i].Y,
                      outerRadius = myStarList[i].OuterRadius,
                      r = myStarList[i].InnerRadius;
                double angle = 0.0;

                /* Center of star */
                starVertices[n++] = new Vector3(x, y, 0);
                /* Emit exterior vertices for star's points. */
                for (int j = 0; j < myStarList[i].Points; j++)
                {
                    starVertices[n++] = new Vector3(x + outerRadius * (float)Math.Cos(angle), y + outerRadius * (float)Math.Sin(angle), 0);
                    angle -= piOverStarPoints;
                    starVertices[n++] = new Vector3(x + r * (float)Math.Cos(angle), y + r * (float)Math.Sin(angle), 0);
                    angle -= piOverStarPoints;
                }
                /* End by repeating first exterior vertex of star. */
                angle = 0;
                starVertices[n++] = new Vector3(x + outerRadius * (float)Math.Cos(angle), y + outerRadius * (float)Math.Sin(angle), 0);
            }
            dataStream.WriteRange(starVertices);
            dataStream.Position = 0;
            vertexBuffer.Unlock();

            this.CgContext = Context.Create();
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;
            this.CreateCgPrograms();

            form.Show();
            while (form.Visible)
            {
                device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(0.1f, 0.3f, 0.6f), 1.0f, 0);
                device.BeginScene();

                vertexProgram.Bind();
                fragmentProgram.Bind();

                /* Render the triangle. */
                device.SetStreamSource(0, vertexBuffer, 0, 12);
                device.VertexFormat = VertexFormat.Position;
                for (int i = 0; i < MyStarCount; i++)
                {
                    device.DrawPrimitives(PrimitiveType.TriangleFan, i * 12, 10);
                }
                device.EndScene();
                device.Present();
                Application.DoEvents();
            }

            fragmentProgram.Dispose();
            vertexProgram.Dispose();
            this.CgContext.Dispose();
            foreach (var item in ObjectTable.Objects)
            {
                item.Dispose();
            }
        }
开发者ID:himanshugoel2797,项目名称:CrossEngine,代码行数:80,代码来源:VertexFragmentProgram.cs

示例10: MainWindow


//.........这里部分代码省略.........
                        Multisample = MultisampleType.None,
                        SwapEffect = SwapEffect.Discard,
                        EnableAutoDepthStencil = true,
                        AutoDepthStencilFormat = Format.D16,
                        PresentFlags = PresentFlags.DiscardDepthStencil,
                        PresentationInterval = PresentInterval.Default,
                        Windowed = true,
                        DeviceWindowHandle = handle
                    });

                // ティーポッドと文字列を作成
                teapod = Mesh.CreateTeapot(device);
                helloWorld = Mesh.CreateText(device, new System.Drawing.Font("Arial", 10), "Hello, world!", 0.001f, 0.001f);

                // 光源描画を有効化
                device.SetRenderState(RenderState.Lighting, true);

                // 光源を設定
                device.SetLight(0, new Light()
                {
                    Type = LightType.Directional,
                    Diffuse = Color.White,
                    Ambient = Color.GhostWhite,
                    Direction = new Vector3(0.0f, -1.0f, 0.0f)
                });

                // 光源を有効化
                device.EnableLight(0, true);

                //射影変換を設定
                device.SetTransform(TransformState.Projection,
                    Matrix.PerspectiveFovLH((float)(Math.PI / 4),
                    (float)(this.Width / this.Height),
                    0.1f, 20.0f));

                //ビューを設定
                device.SetTransform(TransformState.View,
                    Matrix.LookAtLH(new Vector3(3.0f, 2.0f, -3.0f),
                    Vector3.Zero,
                    new Vector3(0.0f, 1.0f, 0.0f)));

                //マテリアル設定
                device.Material = new Material()
                {
                    Diffuse = new Color4(Color.GhostWhite)
                };

                // 描画される時に描画処理を実行
                CompositionTarget.Rendering += (sender2, e2) =>
                {
                    // 画像をロックしてバックバッファーに設定
                    this.directXImage.Lock();
                    this.directXImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, device.GetBackBuffer(0, 0).ComPointer);

                    // フロントバッファーがあれば
                    if (directXImage.IsFrontBufferAvailable)
                    {
                        // デバイスの現在の状態を確かめて失敗したら
                        if (device.TestCooperativeLevel().IsFailure)
                        {
                            // 例外
                            throw new Direct3D9Exception("デバイスが無効です");
                        }

                        // 全面灰色でクリア
                        device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(0.3f, 0.3f, 0.3f), 1.0f, 0);

                        // シーン開始
                        device.BeginScene();

                        //ティーポットを描画
                        device.SetTransform(TransformState.World,
                            Matrix.Translation(-2, 0, 5));
                        teapod.DrawSubset(0);

                        //文字列を描画
                        device.SetTransform(TransformState.World,
                            Matrix.Translation(-4, 0, 0));
                        helloWorld.DrawSubset(0);

                        // シーン終了
                        device.EndScene();

                        // バッファー更新
                        device.Present();
                    }

                    // バックバッファー領域を指定
                    this.directXImage.AddDirtyRect(new Int32Rect(0, 0, directXImage.PixelWidth, directXImage.PixelHeight));

                    // ロック解除
                    this.directXImage.Unlock();
                };

                // イメージのバックバッファーを設定
                directXImage.Lock();
                directXImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, device.GetBackBuffer(0, 0).ComPointer);
                directXImage.Unlock();
            };
        }
开发者ID:aokomoriuta,项目名称:StudiesOfOpenTK,代码行数:101,代码来源:MainWindow.cs

示例11: drawPostProcess

        /// <summary>
        /// Se toma todo lo dibujado antes, que se guardo en una textura, y se le aplica un shader para borronear la imagen
        /// </summary>
        private void drawPostProcess(Device d3dDevice)
        {
            //Arrancamos la escena
            d3dDevice.BeginScene();

            //Ver si el efecto de oscurecer esta activado, configurar Technique del shader segun corresponda
            bool activar_efecto = (bool)GuiController.Instance.Modifiers["activar_efecto"];

            //Hacer blur
            if (activar_efecto)
            {
                float deviation = (float)GuiController.Instance.Modifiers["deviation"];
                Surface blurTempS = blurTempRT.GetSurfaceLevel(0);

                //Gaussian blur horizontal
                Vector2[] texCoordOffsets;
                float[] colorWeights;
                TgcPostProcessingUtils.computeGaussianBlurSampleOffsets15(blurTempS.Description.Width, deviation, 1, true, out texCoordOffsets, out colorWeights);
                effect.Technique = "GaussianBlurPass";
                effect.SetValue("texSceneRT", sceneRT);
                effect.SetValue("gauss_offsets", TgcParserUtils.vector2ArrayToFloat2Array(texCoordOffsets));
                effect.SetValue("gauss_weights", colorWeights);
                d3dDevice.SetRenderTarget(0, blurTempS);
                d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                screenQuad.render(effect);
                
                //Gaussian blur vertical
                TgcPostProcessingUtils.computeGaussianBlurSampleOffsets15(blurTempS.Description.Height, deviation, 1, false, out texCoordOffsets, out colorWeights);
                effect.Technique = "GaussianBlurPass";
                effect.SetValue("texSceneRT", blurTempRT);
                effect.SetValue("gauss_offsets", TgcParserUtils.vector2ArrayToFloat2Array(texCoordOffsets));
                effect.SetValue("gauss_weights", colorWeights);
                d3dDevice.SetRenderTarget(0, pOldRT);
                d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                screenQuad.render(effect);

                blurTempS.Dispose();
            }
            //No hacer blur
            else
            {
                effect.Technique = "DefaultTechnique";
                effect.SetValue("texSceneRT", sceneRT);
                d3dDevice.SetRenderTarget(0, pOldRT);
                d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                screenQuad.render(effect);
            }


            //Como estamos en modo CustomRenderEnabled, tenemos que dibujar todo nosotros, incluso el contador de FPS
            GuiController.Instance.Text3d.drawText("FPS: " + HighResolutionTimer.Instance.FramesPerSecond, 0, 0, Color.Yellow);

            //Tambien hay que dibujar el indicador de los ejes cartesianos
            GuiController.Instance.AxisLines.render();


            //Terminamos el renderizado de la escena
            d3dDevice.EndScene();
        }
开发者ID:aniPerezG,项目名称:barbalpha,代码行数:62,代码来源:EfectoGaussianBlur.cs

示例12: drawPostProcess

        /// <summary>
        /// Se toma todo lo dibujado antes, que se guardo en una textura, y se le aplica un shader para borronear la imagen
        /// </summary>
        private void drawPostProcess(Device d3dDevice, float elapsedTime)
        {
            //Arrancamos la escena
            d3dDevice.BeginScene();

            //Cargamos para renderizar el unico modelo que tenemos, un Quad que ocupa toda la pantalla, con la textura de todo lo dibujado antes
            d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format;
            d3dDevice.SetStreamSource(0, screenQuadVB, 0);

            effect.Technique = "AlarmaTechnique";

            //Cargamos parametros en el shader de Post-Procesado
            effect.SetValue("render_target2D", renderTarget2D);
            effect.SetValue("textura_alarma", alarmTexture.D3dTexture);
            effect.SetValue("alarmaScaleFactor", intVaivenAlarm.update());

            //Limiamos la pantalla y ejecutamos el render del shader
            d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            //Terminamos el renderizado de la escena
            d3dDevice.EndScene();
        }
开发者ID:nicolasazrak,项目名称:RenderMan,代码行数:30,代码来源:PostProcesadoManager.cs

示例13: PostProcess

        /// <summary>
        /// Aplica efectos de post-procesamiento
        /// </summary>
        /// <param name="d3dDevice"></param>
        private void PostProcess(Device d3dDevice)
        {
            d3dDevice.BeginScene();

            d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format;
            d3dDevice.SetStreamSource(0, vbPostProcessMesh, 0);

            // \TODO JJ: multiples efectos en multiples render targets
            if (PostProcessing.LensDistortion)
            {
                postProcessEffect.Technique = "LensDistortion";
                postProcessEffect.SetValue("lens_radius", PostProcessing.LensRadius);

                postProcessEffect.SetValue("chromatic_aberrance_factor",
                    (float)GuiController.Instance.Modifiers.getValue(CHROMATIC_ABERRANCE_FACTOR_MOD));

                postProcessEffect.SetValue("blue_tint_factor",
                    (float)GuiController.Instance.Modifiers.getValue(BLUE_TINT_FACTOR_MOD));

                postProcessEffect.SetValue("k",
                    (float)GuiController.Instance.Modifiers.getValue(LENS_DISTORTION_K_MOD));

                postProcessEffect.SetValue("kcube",
                    (float)GuiController.Instance.Modifiers.getValue(LENS_DISTORTION_KCUBE_MOD));

                Size screen = GuiController.Instance.Panel3d.Size;

                postProcessEffect.SetValue("screen_w", screen.Width);
                postProcessEffect.SetValue("screen_h", screen.Height);
                postProcessEffect.SetValue("screen_center_x", screen.Width / 2);
                postProcessEffect.SetValue("screen_center_y", screen.Height / 2);
            }
            else
                postProcessEffect.Technique = "NoEffect";

            postProcessEffect.SetValue("pre_render", preTargetTexture);

            d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

            postProcessEffect.Begin(FX.None);
            postProcessEffect.BeginPass(0);

            d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);

            postProcessEffect.EndPass();
            postProcessEffect.End();

            d3dDevice.EndScene();
        }
开发者ID:javs,项目名称:Snipers-CEGA,代码行数:53,代码来源:Snipers.cs

示例14: Render

        // TODO: Consider returning IEnumerable<RenderInfo>
        private RenderInfo[] Render(Device dev, MatrixStack transform, EditorCamera cam)
        {
            List<RenderInfo> result = new List<RenderInfo>();

            if (!enabled)
                return result.ToArray();

            float dist = cam.Position.Distance(position) * 0.0825f;
            BoundingSphere gizmoSphere = new BoundingSphere() { Center = new Vertex(position.X, position.Y, position.Z), Radius = (1.0f * Math.Abs(dist)) };

            #region Setting Render States
            dev.SetSamplerState(0, SamplerStageStates.MinFilter, (int)TextureFilter.Point); // no fancy filtering is required because no textures are even being used
            dev.SetSamplerState(0, SamplerStageStates.MagFilter, (int)TextureFilter.Point);
            dev.SetSamplerState(0, SamplerStageStates.MipFilter, (int)TextureFilter.Point);
            dev.SetRenderState(RenderStates.Lighting, true);
            dev.SetRenderState(RenderStates.SpecularEnable, false);
            dev.SetRenderState(RenderStates.Ambient, Color.White.ToArgb());
            dev.SetRenderState(RenderStates.AlphaBlendEnable, false);
            dev.SetRenderState(RenderStates.ColorVertex, false);
            dev.Clear(ClearFlags.ZBuffer, 0, 1, 0);
            #endregion

            transform.Push();
            transform.TranslateLocal(position.X, position.Y, position.Z);
            transform.RotateXYZLocal(rotation.X, rotation.Y, rotation.Z);
            transform.ScaleLocal(Math.Abs(dist), Math.Abs(dist), Math.Abs(dist));

            #region Handling Transform Modes
            switch (mode)
            {
                case TransformMode.TRANFORM_MOVE:
                    {
                        RenderInfo xRenderInfo = new RenderInfo(Gizmo.XMoveMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.X_AXIS) ? Gizmo.HighlightMaterial : Gizmo.XMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(xRenderInfo);
                        RenderInfo yRenderInfo = new RenderInfo(Gizmo.YMoveMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.Y_AXIS) ? Gizmo.HighlightMaterial : Gizmo.YMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(yRenderInfo);
                        RenderInfo zRenderInfo = new RenderInfo(Gizmo.ZMoveMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.Z_AXIS) ? Gizmo.HighlightMaterial : Gizmo.ZMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(zRenderInfo);

                        if (!isTransformLocal) // this is such a cop-out. I'll try to find a better solution.
                        {
                            RenderInfo xyRenderInfo = new RenderInfo(Gizmo.XYMoveMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.XY_AXIS) ? Gizmo.HighlightMaterial : Gizmo.DoubleAxisMaterial, null, FillMode.Solid, gizmoSphere);
                            result.Add(xyRenderInfo);
                            RenderInfo zxRenderInfo = new RenderInfo(Gizmo.ZXMoveMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.XZ_AXIS) ? Gizmo.HighlightMaterial : Gizmo.DoubleAxisMaterial, null, FillMode.Solid, gizmoSphere);
                            result.Add(zxRenderInfo);
                            RenderInfo zyRenderInfo = new RenderInfo(Gizmo.ZYMoveMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.ZY_AXIS) ? Gizmo.HighlightMaterial : Gizmo.DoubleAxisMaterial, null, FillMode.Solid, gizmoSphere);
                            result.Add(zyRenderInfo);
                        }
                    }
                    break;
                case TransformMode.TRANSFORM_ROTATE:
                    {
                        RenderInfo xRenderInfo = new RenderInfo(Gizmo.XRotateMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.X_AXIS) ? Gizmo.HighlightMaterial : Gizmo.XMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(xRenderInfo);
                        RenderInfo yRenderInfo = new RenderInfo(Gizmo.YRotateMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.Y_AXIS) ? Gizmo.HighlightMaterial : Gizmo.YMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(yRenderInfo);
                        RenderInfo zRenderInfo = new RenderInfo(Gizmo.ZRotateMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.Z_AXIS) ? Gizmo.HighlightMaterial : Gizmo.ZMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(zRenderInfo);
                    }
                    break;
                case TransformMode.NONE:
                    {
                        RenderInfo xRenderInfo = new RenderInfo(Gizmo.XNullMesh, 0, transform.Top, Gizmo.XMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(xRenderInfo);
                        RenderInfo yRenderInfo = new RenderInfo(Gizmo.YNullMesh, 0, transform.Top, Gizmo.YMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(yRenderInfo);
                        RenderInfo zRenderInfo = new RenderInfo(Gizmo.ZNullMesh, 0, transform.Top, Gizmo.ZMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(zRenderInfo);
                    }
                    break;
                case TransformMode.TRANSFORM_SCALE:
                    {
                        RenderInfo xRenderInfo = new RenderInfo(Gizmo.XScaleMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.X_AXIS) ? Gizmo.HighlightMaterial : Gizmo.XMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(xRenderInfo);
                        RenderInfo yRenderInfo = new RenderInfo(Gizmo.YScaleMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.Y_AXIS) ? Gizmo.HighlightMaterial : Gizmo.YMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(yRenderInfo);
                        RenderInfo zRenderInfo = new RenderInfo(Gizmo.ZScaleMesh, 0, transform.Top, (selectedAxes == GizmoSelectedAxes.Z_AXIS) ? Gizmo.HighlightMaterial : Gizmo.ZMaterial, null, FillMode.Solid, gizmoSphere);
                        result.Add(zRenderInfo);
                    }
                    break;
            }
            #endregion

            transform.Pop();
            return result.ToArray();
        }
开发者ID:Radfordhound,项目名称:sa_tools,代码行数:87,代码来源:TransformGizmo.cs

示例15: Main


//.........这里部分代码省略.........
            {
                if (!GameEngine.Instance.PauseRendering)
                {
                    int score = GameEngine.Instance.PlayerScore;
                    int life = GameEngine.Instance.PlayerLife;
                    int hiscore = GameEngine.Instance.HiScore;

                    //Time to spawn?
                    GameEngine.Instance.SpawnTimer.Stop();
                    if ((float)GameEngine.Instance.SpawnTimer.Elapsed >= GameEngine.Instance.SpawnFrequency)
                    {
                        GameEngine.Instance.SpawnEnemy(GameEngine.Instance.PlayerLevel);
                        if((GameEngine.Instance.SpawnFrequency - GameTypes.GAME_SPAWN_SPEEDUP_RATE >= GameTypes.GAME_SPAWN_MIN_FREQ))
                            GameEngine.Instance.SpawnFrequency -= GameTypes.GAME_SPAWN_SPEEDUP_RATE;

                        for(int i =0;i<GameTypes.GAME_LEVEL_FREQ.Length;i++)
                            if(GameEngine.Instance.SpawnFrequency <= GameTypes.GAME_LEVEL_FREQ[i])
                                GameEngine.Instance.PlayerLevel = i;

                        GameEngine.Instance.SpawnTimer.Start();
                    }
                    else
                    {
                        //if (GameEngine.Instance.Enemies.Count == 1)
                          //  GameEngine.Instance.SpawnEnemy(GameEngine.Instance.PlayerLevel);
                    }

                    GameEngine.Instance.LifeTimer.Stop();
                    float time = (float)GameEngine.Instance.LifeTimer.Elapsed;
                    float fps = (float)GameEngine.Instance.FPSTimer.FPS;
                    float ticks = (float)GameEngine.Instance.LifeTimer.GetTicks(0.017f);
                    WindowManager.Instance.Main.showelapsed(time, fps, ticks);

                    device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                    device.BeginScene();

                    //draw maze

                    TextureManager.Instance.spritey.Begin(SpriteFlags.AlphaBlend | SpriteFlags.DoNotAddRefTexture);
                    for (int y = 0; y < GameTypes.MAP_HEIGHT; y++)
                    {
                        for (int x = 0; x < GameTypes.MAP_WIDTH; x++)
                        {
                            if (PathFinding.Instance.GetNode(x, y).Walkable)
                                TextureManager.Instance.spritey.Draw(TextureManager.Instance.ddsTestTile, new Rectangle(0, 0, 32, 32), new Vector3(0, 0, 0), new Vector3(x * 32, y * 32, 0), new Color4(Color.White));
                            else
                                TextureManager.Instance.spritey.Draw(TextureManager.Instance.ddsTestTileOut, new Rectangle(0, 0, 32, 32), new Vector3(0, 0, 0), new Vector3(x * 32, y * 32, 0), new Color4(Color.White));
                        }
                    }

                    //draw shiny
                    TextureManager.Instance.spritey.Draw(TextureManager.Instance.pngShiny, new Rectangle(0, 0, 32, 32), new Vector3(0, 0, 0), new Vector3(GameEngine.Instance.ShinyLocation.X*32,GameEngine.Instance.ShinyLocation.Y*32,0), new Color4(Color.White));

                    //sprite update
                    GameEngine.Instance.TestSpriteTimer.Stop();
                    if (GameEngine.Instance.TestSpriteTimer.Elapsed > 0.017)
                    {
                        GameEngine.Instance.ThePlayer.Update();
                        //GameEngine.Instance.testvec.X += 0.5f;
                        //GameEngine.Instance.testEnemy.UpdateMove();

                        // move enemies
                        foreach (Enemy enemy in GameEngine.Instance.Enemies)
                        {
                            if (enemy.Active)
                                enemy.UpdateMove();
开发者ID:JamesPersaud,项目名称:EnemyMaze,代码行数:67,代码来源:Program.cs


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