public void Present() { if (ComponentsPerfMonitor.Updatable) { ComponentsPerfMonitor.StartMesure("GPU Rendering", "Draw"); Engine.SwapChain.Present(_vSync, PresentFlags.None); // Send BackBuffer to screen ComponentsPerfMonitor.StopMesure("GPU Rendering", "Draw"); } else { Engine.SwapChain.Present(_vSync, PresentFlags.None); // Send BackBuffer to screen } HLSLShaderWrap.ResetEffectStateTracker(); VertexBuffer.ResetVertexStateTracker(); if (_framelimiterTime > 0) { while (_framelimiter.ElapsedMilliseconds <= _framelimiterTime) { Thread.Sleep(1); } _framelimiter.Restart(); } //Frame limiter, will hold the frame for a minimum amount of time }
/// <summary> /// Fixed Time Step Update /// </summary> /// <param name="TimeSpend">The fixed amount of time between 2 FTSUpdate call</param> public virtual void FTSUpdate(GameTime TimeSpend) { _currentlyUpdatingComponents.Clear(); for (int i = 0; i < _enabledUpdatable.Count; i++) { _currentlyUpdatingComponents.Add(_enabledUpdatable[i]); } for (int i = 0; i < _currentlyUpdatingComponents.Count; i++) { if (isCurrentlyUpdatingComponentsDirty) { isCurrentlyUpdatingComponentsDirty = false; break; } if (ComponentsPerfMonitor.Updatable) { ComponentsPerfMonitor.StartMesure(_currentlyUpdatingComponents[i], "Update"); _currentlyUpdatingComponents[i].FTSUpdate(TimeSpend); ComponentsPerfMonitor.StopMesure(_currentlyUpdatingComponents[i], "Update"); } else { _currentlyUpdatingComponents[i].FTSUpdate(TimeSpend); } } }
public virtual void Draw() { //Init New Frame before drawing components Engine.ImmediateContext.ClearRenderTargetView(Engine.RenderTarget, BackBufferColor); Engine.ImmediateContext.ClearDepthStencilView(Engine.DepthStencilTarget, DepthStencilClearFlags.Depth, 1.0f, 0); //Draw everything for (int i = 0; i < _visibleDrawable.Count; i++) { DrawableComponentHolder drawComponent = _visibleDrawable[i]; if (ComponentsPerfMonitor.Updatable) { ComponentsPerfMonitor.StartMesure(drawComponent.DrawableComponent, "Draw", drawComponent.DrawOrder.DrawID); drawComponent.DrawableComponent.Draw(Engine.ImmediateContext, drawComponent.DrawOrder.DrawID); ComponentsPerfMonitor.StopMesure(drawComponent.DrawableComponent, "Draw", drawComponent.DrawOrder.DrawID); } else { drawComponent.DrawableComponent.Draw(Engine.ImmediateContext, drawComponent.DrawOrder.DrawID); } } Present(); }