Exemplo n.º 1
0
        private void CmdMatrix_Click(object sender, System.EventArgs e)
        {
            using (MatrixControl matrixControl = new MatrixControl()) {
                MatrixTest matrixTest = new MatrixTest();
                matrixControl.Show();
                matrixTest.Show();

                // Initialize Direct3D and the device object
                if (!matrixControl.InitD3D(matrixTest.Handle))
                {
                    MessageBox.Show("Could not initialize Direct3D.");
                    matrixControl.Dispose();
                    return;
                }
                else
                {
                    // Load the textures and create the cube to show them
                    if (!matrixControl.CreateCube())
                    {
                        MessageBox.Show("Could not initialize geometry.");
                        matrixControl.DisposeD3D();
                        matrixControl.Dispose();
                        return;
                    }
                }

                // Start with a simple rotation, to position the cube more nicely;
                //  and with no scale (100% of the original size)

                matrixControl.RotationX.Value = 45;
                matrixControl.RotationY.Value = 45;
                matrixControl.RotationZ.Value = 45;
                matrixControl.ScaleX.Value    = 100;
                matrixControl.ScaleY.Value    = 100;
                matrixControl.ScaleZ.Value    = 100;

                // Ends the test if ESC is pressed in any of the 2 windows
                while (!matrixControl.EndTest && !matrixTest.EndTest)
                {
                    matrixControl.Render();
                    // Frame rate calculation
                    matrixTest.Text = "Matrix Tests.  Frame Rate: " + DirectXLists.CalcFrameRate().ToString();
                    Application.DoEvents();
                }
                matrixTest.Close();
            }
        }
        private void CmdMatrix_Click(object sender, System.EventArgs e)
        {
            using (MatrixControl matrixControl = new MatrixControl()) {
                MatrixTest matrixTest = new MatrixTest();
                matrixControl.Show();
                matrixTest.Show();

                // Initialize Direct3D and the device object
                if(!matrixControl.InitD3D(matrixTest.Handle)) {
                    MessageBox.Show("Could not initialize Direct3D.");
                    matrixControl.Dispose();
                    return;
                }
                else {
                    // Load the textures and create the cube to show them
                    if(!matrixControl.CreateCube()) {
                        MessageBox.Show("Could not initialize geometry.");
                        matrixControl.DisposeD3D();
                        matrixControl.Dispose();
                        return;
                    }
                }

                // Start with a simple rotation, to position the cube more nicely;
                //  and with no scale (100% of the original size)

                matrixControl.RotationX.Value = 45;
                matrixControl.RotationY.Value = 45;
                matrixControl.RotationZ.Value = 45;
                matrixControl.ScaleX.Value = 100;
                matrixControl.ScaleY.Value = 100;
                matrixControl.ScaleZ.Value = 100;

                // Ends the test if ESC is pressed in any of the 2 windows
                while(!matrixControl.EndTest && !matrixTest.EndTest) {
                    matrixControl.Render();
                    // Frame rate calculation
                    matrixTest.Text = "Matrix Tests.  Frame Rate: " + DirectXLists.CalcFrameRate().ToString();
                    Application.DoEvents();
                }
                matrixTest.Close();
            }
        }