/// <summary> /// Called when the render size has changed. /// </summary> /// <param name="sizeInfo">New size information.</param> protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) { base.OnRenderSizeChanged(sizeInfo); if (!GraphicsCore.IsInitialized) { return; } // Break here if we are in design mode if (this.IsInDesignMode()) { return; } // Update render size m_renderLoop.Camera.SetScreenSize((int)this.RenderSize.Width, (int)this.RenderSize.Height); //Resize render target only on greater size changes double resizeFactorWidth = sizeInfo.NewSize.Width > m_renderTargetWidth ? sizeInfo.NewSize.Width / m_renderTargetWidth : m_renderTargetWidth / sizeInfo.NewSize.Width; double resizeFactorHeight = sizeInfo.NewSize.Height > m_renderTargetHeight ? sizeInfo.NewSize.Height / m_renderTargetHeight : m_renderTargetHeight / sizeInfo.NewSize.Height; if ((resizeFactorWidth > 1.3) || (resizeFactorHeight > 1.3)) { m_renderLoop.SetCurrentViewSize((int)this.RenderSize.Width, (int)this.RenderSize.Height); } }
/// <summary> /// Update current configured view size on the render loop. /// </summary> private void UpdateRenderLoopViewSize() { Size2 viewSize = GetTargetRenderPixelSize(); m_renderLoop.Camera.SetScreenSize(viewSize.Width, viewSize.Height); m_renderLoop.SetCurrentViewSize( (int)viewSize.Width, (int)viewSize.Height); }
/// <summary> /// Called when the size of the target control has changed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="SizeChangedEventArgs"/> instance containing the event data.</param> private void OnTargetPanelSizeChanged(object sender, SizeChangedEventArgs e) { if (!GraphicsCore.IsInitialized) { return; } // Get the current pixel size and apply it on the camera Size2 viewSize = GetTargetRenderPixelSize(); m_renderLoop.Camera.SetScreenSize(viewSize.Width, viewSize.Height); //Resize render target only on greater size changes double resizeFactorWidth = (double)viewSize.Width > m_lastRefreshTargetSize.Width ? (double)viewSize.Width / m_lastRefreshTargetSize.Width : m_lastRefreshTargetSize.Width / (double)viewSize.Width; double resizeFactorHeight = (double)viewSize.Height > m_lastRefreshTargetSize.Height ? (double)viewSize.Height / m_lastRefreshTargetSize.Height : m_lastRefreshTargetSize.Height / (double)viewSize.Height; if ((resizeFactorWidth > 1.3) || (resizeFactorHeight > 1.3)) { m_renderLoop.SetCurrentViewSize(viewSize.Width, viewSize.Height); } }
/// <summary> /// Stops rendering. /// </summary> private void StartRendering() { if (this.DesignMode) { return; } if (!SeeingSharpApplication.IsInitialized) { return; } if (!GraphicsCore.IsInitialized) { return; } if (!m_renderLoop.IsRegisteredOnMainLoop) { m_renderLoop.SetCurrentViewSize(this.Width, this.Height); m_renderLoop.DiscardRendering = false; m_renderLoop.RegisterRenderLoop(); } }