示例#1
0
        private void CmdTransparency_Click(object sender, System.EventArgs e)
        {
            using (TransparentTest transparentTest = new TransparentTest()) {
                transparentTest.Show();

                // Initialize Direct3D and the device object
                if (!transparentTest.InitD3D(transparentTest.Handle))
                {
                    MessageBox.Show("Could not initialize Direct3D.");
                    transparentTest.Dispose();
                    return;
                }
                else
                {
                    // Load the textures and create the square to show them
                    if (!(transparentTest.CreateTextures() && transparentTest.CreateTransparentVertices(0, 0)))
                    {
                        MessageBox.Show("Could not initialize vertices and textures.");
                        transparentTest.DisposeD3D();
                        transparentTest.Dispose();
                        return;
                    }
                }

                // If we have no errors, then enter the rendering loop
                while (!transparentTest.EndTest)
                {
                    transparentTest.Render();
                    // Frame rate calculation
                    transparentTest.Text =
                        "Transparency Test.  Frame rate: " + DirectXLists.CalcFrameRate().ToString();
                    Application.DoEvents();
                }
            }
        }
        private void CmdTransparency_Click(object sender, System.EventArgs e)
        {
            using (TransparentTest transparentTest = new TransparentTest()) {
                transparentTest.Show();

                // Initialize Direct3D and the device object
                if(!transparentTest.InitD3D(transparentTest.Handle)) {
                    MessageBox.Show("Could not initialize Direct3D.");
                    transparentTest.Dispose();
                    return;
                }
                else {
                    // Load the textures and create the square to show them
                    if(!(transparentTest.CreateTextures() && transparentTest.CreateTransparentVertices(0, 0))) {
                        MessageBox.Show("Could not initialize vertices and textures.");
                        transparentTest.DisposeD3D();
                        transparentTest.Dispose();
                        return;
                    }
                }

                // If we have no errors, then enter the rendering loop
                while(!transparentTest.EndTest) {
                    transparentTest.Render();
                    // Frame rate calculation
                    transparentTest.Text =
                        "Transparency Test.  Frame rate: " + DirectXLists.CalcFrameRate().ToString();
                    Application.DoEvents();
                }
            }
        }