/// <summary> /// Rendering-method /// </summary> public void Render() { if (deviceLost) { AttemptRecovery(); } if (deviceLost) { return; } if (_device == null) { return; } try { Rectangle screen = _parent.GetScreen(); double zoom = _parent.GetZoom(); //Clear the backbuffer _device.Clear(ClearFlags.Target, new SharpDX.Color(_deviceBackColor.R, _deviceBackColor.B, _deviceBackColor.G, _deviceBackColor.A), 1.0f, 0); //Begin the scene _device.BeginScene(); sprite.Transform = Matrix.Scaling((float)zoom, (float)zoom, 1f); sprite2.Begin(SpriteFlags.AlphaBlend); if (zoom > 1) { // If zoomin, just do near-neighbor scaling _device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.None); _device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.None); _device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.None); } sprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.DoNotModifyRenderState); // Render of scene here if (OnRender != null) { OnRender(this, new DeviceEventArgs(_device)); } sprite.Transform = Matrix.Scaling(1f, 1f, 1f); sprite.End(); sprite2.End(); //End the scene _device.EndScene(); _device.Present(); } catch (SharpDXException ex) { if (ex.ResultCode == ResultCode.DeviceLost) { deviceLost = true; } else { throw ex; } } }
/// <summary> /// Rendering-method /// </summary> public void Render() { if (deviceLost) { AttemptRecovery(); } if (deviceLost) { return; } if (_device == null) { return; } try { Rectangle screen = _parent.GetScreen(); double zoom = _parent.GetZoom(); //Clear the backbuffer _device.Clear(ClearFlags.Target, new SharpDX.Color(_deviceBackColor.R, _deviceBackColor.B, _deviceBackColor.G, _deviceBackColor.A), 1.0f, 0); //Begin the scene _device.BeginScene(); sprite.Transform = Matrix.Scaling((float)zoom, (float)zoom, 1f); sprite2.Begin(SpriteFlags.AlphaBlend); if (zoom > 1) { // If zoomin, just do near-neighbor scaling _device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point); _device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Point); _device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Point); } sprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.DoNotModifyRenderState); // Render of scene here if (OnRender != null) { OnRender(this, new DeviceEventArgs(_device)); } sprite.Transform = Matrix.Scaling(1f, 1f, 1f); Rectangle rect1 = new Rectangle(DrawWidth - screen.X, 0, Width - DrawWidth, Height); rect1.Intersect(new Rectangle(0, 0, screen.Width, screen.Height)); Rectangle rect2 = new Rectangle(0, DrawHeight - screen.Y, DrawWidth, Height - DrawHeight); rect2.Intersect(new Rectangle(0, 0, screen.Width, screen.Height)); DrawTexture(tx, new Rectangle(0, 0, rect1.Width, rect1.Height), new Vector3(0, 0, 0), new Vector3(rect1.X, rect1.Y, 0), SystemColors.Control); DrawTexture(tx, new Rectangle(0, 0, rect2.Width, rect2.Height), new Vector3(0, 0, 0), new Vector3(rect2.X, rect2.Y, 0), SystemColors.Control); sprite.End(); sprite2.End(); //End the scene _device.EndScene(); _device.Present(); } catch (SharpDXException ex) { if (ex.ResultCode == ResultCode.DeviceLost) { Editor.Instance.DeviceExceptionDialog(); } else { Editor.Instance.DeviceExceptionDialog(); } } }
private double GetZoom() { if (_parent == null) { return(1); } return(_parent.GetZoom()); }