public GameMain() { #if DEBUG graphics = DxManager.XNAInit(this, "content", 1280, 720); #endif #if !DEBUG graphics = DxManager.XNAInit(this, "content"); #endif manager = new Manager(); graphics.PreferMultiSampling = true; // graphics.PreparingDeviceSettings += // new EventHandler<PreparingDeviceSettingsEventArgs>(Graphics_PreparingDeviceSettings); #if !DEBUG this.graphics.IsFullScreen = true; #endif }
public MainWindow() { InitializeComponent(); Loaded += (sender, args) => Catch(() => { _manager = new DxManager(SharpDxElement); Prepare(); }); SharpDxElement.OnResized += (source, e) => Catch( () => _proj = Matrix.PerspectiveFovRH( MathUtil.PiOverFour, (float)SharpDxElement.ActualWidth / (float)SharpDxElement.ActualHeight, 0.1f, 1000.0f) ); new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(15), IsEnabled = true, }.Tick += (sender, args) => Draw(); Closing += (sender, args) => Clean(); Point popPos = default(Point); _distSum = 40; SharpDxElement.MouseDown += (s, a) => popPos = a.GetPosition(this); SharpDxElement.MouseMove += (s, a) => { if (a.LeftButton == MouseButtonState.Released) { return; } Point position = a.GetPosition(this); float viewRotationAngleY = -(float)(position.Y - popPos.Y) / 80f; float viewRotationAngleZ = -(float)(position.X - popPos.X) / 80f; _viewRotation = Quaternion.RotationAxis(Vector3.UnitY, viewRotationAngleY) * Quaternion.RotationAxis(Vector3.UnitZ, viewRotationAngleZ) * _viewRotation; popPos = position; }; SharpDxElement.MouseWheel += (sender, args) => _distSum = Math.Max(3f, _distSum - args.Delta / 10f); }