/// <summary> /// Initialize the RenderDevice. /// </summary> public void Init() { // Fenstergröße anpassen presentParameters.BackBufferHeight = ClientSize.Height; presentParameters.BackBufferWidth = ClientSize.Width; // Device erzeugen CreateFlags flags; if (deviceCaps.DeviceCaps.SupportsHardwareTransformAndLight) { flags = CreateFlags.HardwareVertexProcessing; } else { flags = CreateFlags.SoftwareVertexProcessing; } if (deviceCaps.DeviceCaps.SupportsPureDevice) { flags |= CreateFlags.PureDevice; } // Versuche ein DirectX-Device zu erzeugen. Falls dies fehlschlägt wird alternativ ein // Referenz-Device erzeugt. try { renderDevice = new Device(0, DeviceType.Hardware, this, flags, presentParameters); } catch (Exception) { renderDevice = new Device (0, DeviceType.Reference, this, CreateFlags.SoftwareVertexProcessing, presentParameters); } // Events abgreifen renderDevice.DeviceReset += device_reset; // Kamera erstellen camera = new Camera(this); // Grundeinstellungen des Geräts laden device_reset(null, null); // Initialisieren von Manager und Kamera modelManager = new ModellManager(renderDevice); }
/// <summary> /// Uninit the RenderDevice. /// </summary> public void Uninit() { // Switch back to window-Screen Fullscreen = false; // free model-resources if (modelManager != null) { modelManager.Dispose(); modelManager = null; } // free Device if (renderDevice != null) { renderDevice.DeviceReset -= device_reset; renderDevice.Dispose(); renderDevice = null; } }