public void Dispose() { DeviceDisposing?.Invoke(this, EventArgs.Empty); GraphicsDevice.Dispose(); Direct3DDevice?.Dispose(); Direct3DContext?.Dispose(); }
public void GraphicsInteropFromManaged() { // // This test interops a C# component (ie this one) with a C++/CX // component (GraphicsDeviceComponent) using Direct3DDevice and // Direct3DSurface to pass a IDXGIDevice and IDXGISurface between // them. // // Create a device. Direct3DDevice graphicsDevice = NativeComponent.DeviceCreator.CreateDevice(); // We should be able to call Trim() without anything bad happening graphicsDevice.Trim(); // Now create a surface using this device. int expectedWidth = 128; int expectedHeight = 256; var expectedGraphicsFormat = DirectXPixelFormat.R32Float; Direct3DSurface surface = NativeComponent.SurfaceCreator.CreateSurface( graphicsDevice, expectedWidth, expectedHeight, expectedGraphicsFormat); // Look at the surface description to make sure it seems valid. var desc = surface.Description; Assert.AreEqual(expectedWidth, desc.Width); Assert.AreEqual(expectedHeight, desc.Height); Assert.AreEqual(expectedGraphicsFormat, desc.Format); Assert.AreEqual(1, desc.MultisampleDescription.Count); Assert.AreEqual(0, desc.MultisampleDescription.Quality); }
public Direct3DWindow() { _form = new Form(); _form.Width = 640; _form.Height = 480; _form.BackColor = Color.Magenta; _device = new Direct3DDevice(); _device.SetWindow(this); }