예제 #1
0
        public StereoScopica()
        {
            // Setup the relative directory to the executable directory for loading contents with the ContentManager
            Content.RootDirectory = "Content";

            GraphicsDeviceManager = new GraphicsDeviceManager(this);
#if DEBUG
            // Debug mode to get better error msgs out from DX
            GraphicsDeviceManager.DeviceCreationFlags = DeviceCreationFlags.Debug;
#endif
            Renderer       = new Renderer(GraphicsDeviceManager);
            ImagePlane     = new TexturedPlane[2];
            CameraHandler  = new CameraHandler[2];
            CameraSettings = new CameraSettings[2];
            Keyboard       = new KeyboardManager(this);

            // LoadUserSettings() will initialize the imagePlane and cameraSettings arrays
            LoadUserSettingsOrSetDefaults();

            // By initializing the camera handling processes here their windows will be created before the main app window
            // and the focus won't be taken away from the main window
            for (var i = 0; i < CameraHandler.Length; i++)
            {
                CameraHandler[i] = new CameraHandler(CameraSettings[i]);
                CameraHandler[i].ImageUpdated += ImageUpdateEvent;
            }
        }
예제 #2
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                SaveUserSettings();
                foreach (var e in CameraHandler.Where(e => e != null))
                {
                    e.Stop();
                }
                foreach (var e in ImagePlane.Where(e => e != null))
                {
                    e.Dispose();
                }
                if (Keyboard != null)
                {
                    Keyboard.Dispose();
                }
                if (Renderer != null)
                {
                    Renderer.Dispose();
                }
                if (GraphicsDeviceManager != null)
                {
                    GraphicsDeviceManager.Dispose();
                }
                if (TextureShader != null)
                {
                    TextureShader.Dispose();
                }
            }
            _disposed = true;
            base.Dispose(disposing);
        }