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 ListDeviceCaps(int adapter, DeviceType deviceType) { DeviceCapsListBox.Items.Clear(); Caps caps = Manager.GetDeviceCaps(adapter, deviceType); DirectXLists.ListGeneralCaps(caps, DeviceCapsListBox); DirectXLists.ListDevCaps(caps.DeviceCaps, DeviceCapsListBox); DirectXLists.ListDriverCaps(caps.DriverCaps, DeviceCapsListBox); DirectXLists.ListRasterCaps(caps.RasterCaps, DeviceCapsListBox); DirectXLists.ListTextureCaps(caps.TextureCaps, DeviceCapsListBox); }
private void CmdLight_Click(object sender, System.EventArgs e) { LightControl winLightControl = new LightControl(); using (LightTest lightTest = new LightTest()) { winLightControl.Show(); lightTest.Show(); // Initialize Direct3D and the device object if (!winLightControl.InitD3D(lightTest.Handle)) { MessageBox.Show("Could not initialize Direct3D."); winLightControl.Dispose(); } else { // Load the textures and create the vertices if (!winLightControl.CreateTextures()) { MessageBox.Show("Could not initialize the textures and vertices."); winLightControl.DisposeD3D(); winLightControl.Dispose(); } } // Start with full white light in all vertices winLightControl.Red1.Value = 255; winLightControl.Green1.Value = 255; winLightControl.Blue1.Value = 255; winLightControl.Red2.Value = 255; winLightControl.Green2.Value = 255; winLightControl.Blue2.Value = 255; winLightControl.Red3.Value = 255; winLightControl.Green3.Value = 255; winLightControl.Blue3.Value = 255; winLightControl.Red4.Value = 255; winLightControl.Green4.Value = 255; winLightControl.Blue4.Value = 255; // Ends the test if ESC is pressed in any of the 2 windows while (!winLightControl.EndTest && !lightTest.EndTest) { winLightControl.Render(); // Frame rate calculation lightTest.Text = "Light Test. Frame Rate: " + DirectXLists.CalcFrameRate().ToString(); Application.DoEvents(); } } }
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 CmdWindow_Click(object sender, System.EventArgs e) { using (WindowTest windowTest = new WindowTest()) { windowTest.Show(); // Initialize Direct3D and the device object if (!windowTest.InitD3D(windowTest.Handle)) { MessageBox.Show("Could not initialize Direct3D."); windowTest.Dispose(); return; } else { // Load the textures and create the square to show them if (!windowTest.CreateTextures()) { MessageBox.Show("Could not initialize vertices and textures."); return; } } // Uncomment the lines below to see a smooth walking man //int desiredFrameRate = 10; //int lastTick = 0; while (!windowTest.EndTest) { // Force a Frame rate of 10 frames to second on maximum //if(System.Environment.TickCount - lastTick >= 1000 / desiredFrameRate) { windowTest.Render(); // Frame rate calculation windowTest.Text = "Window Test. Frame rate: " + DirectXLists.CalcFrameRate().ToString(); //lastTick = System.Environment.TickCount; //} Application.DoEvents(); } } }