/// <summary> /// The engine life cycle. /// </summary> private static async void EngineCycle() { // Invoke the start event. OnStart?.Invoke(); while (AsciiRenderer.IsWindowOpen()) { // Calculate the delta time. float deltaTime = SystemAPI.ElapsedSeconds - time; // Update the time. time = SystemAPI.ElapsedSeconds; // Invoke the update event. OnUpdate?.Invoke(deltaTime); // Invoke the render event. OnRender?.Invoke(); // Render the buffer. AsciiRenderer.Render(); // Wait for the frame to end. await Task.Delay(1000 / frameRate); } // Invoke the close event. OnClose?.Invoke(); }
public void Render(Vector2 position) { Matrix transformationMatrix = Matrix.CreateScale(4f) * Matrix.CreateTranslation(position.X, position.Y, 0f); Draw.SpriteBatch.End(); Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, transformationMatrix); foreach (Entity entity in Engine.Scene.Tracker.GetEntities <TrailManager.Snapshot>()) { if (entity.Tag == tag) { entity.Render(); } } foreach (Entity entity2 in Engine.Scene.Tracker.GetEntities <SlashFx>()) { if (entity2.Tag == tag && entity2.Visible) { entity2.Render(); } } foreach (Entity entity3 in Engine.Scene.Tracker.GetEntities <SpeedRing>()) { if (entity3.Tag == tag) { entity3.Render(); } } if (Playback.Visible) { Playback.Render(); } OnRender?.Invoke(); Draw.SpriteBatch.End(); Draw.SpriteBatch.Begin(); }
//-------------------------------------------------------------------------------------- /// <summary> /// Render /// </summary> //-------------------------------------------------------------------------------------- public virtual void RenderMe(GameTime gameTime) { if (Renderer == null) { throw new InvalidOperationException("The Renderer property is null on " + this.GetType().Name + " with Name=" + Name); } Update(); if (!IsVisible) { return; } bool shouldClip = ClipToBounds || Rotate != 0 || FlipHorizontal || FlipVertical; if (shouldClip) { Renderer.BeginClipping(AbsoluteOffset, Size); } OnRender?.Invoke(gameTime, this); RenderChildren(gameTime); if (shouldClip) { float rotation = 0; Renderer.EndClipping( (float)(Rotate / 180.0 * Math.PI), new Vector2(.5f), new Vector2(1), FlipHorizontal, FlipVertical); } }
private void AddOnRenderNode() { var o = new OnRender(parent.ActivatedWorkSpaceData); o.AddChild(new DefaultAction(parent.ActivatedWorkSpaceData)); parent.Insert(o); }
/// <summary> /// Creates an instance of the renderer /// </summary> public Renderer() { instance = this; RootElement.OnRender += () => { OnRender?.Invoke(); }; RootElement.OnHUDRender += () => { OnHudRender?.Invoke(); }; }
protected override void OnPaint(PaintEventArgs e) { GLES20.Viewport(0, 0, Width, Height); OnRender?.Invoke(this, new EventArgs()); _display.SwapBuffers(); Invalidate(); }
public BodyViewer() { InitializeComponent(); move_timer = new Timer(); move_timer.Interval = 50; move_timer.Tick += new EventHandler(move_timer_Tick); Render += new OnRender(BodyViewer_Render); move_timer.Start(); }
//-------------------------------------------------------------------------------------- /// <summary> /// SetCustomRender - Clear out the Render event and replace with yours /// </summary> //-------------------------------------------------------------------------------------- public void SetCustomRender(Action <GameTime, VarmintWidget> render, bool removeDefaultRenderActions = true) { if (OnRender != null && removeDefaultRenderActions) { foreach (Action <GameTime, VarmintWidget> action in OnRender.GetInvocationList()) { OnRender -= action; } } OnRender += render; }
private void UpdateThread() { //Wait until first packet is read _pauseWaiter.WaitOne(); double lastLoopMs = 0; int _frames = 0; double _startTime = 0; while (!_finished || _buffer.Count > 0) { double deltaTime = (_timePassed.Elapsed.TotalMilliseconds - lastLoopMs) * PlaybackSpeed; CurrentTime += deltaTime; lastLoopMs = _timePassed.Elapsed.TotalMilliseconds; double loopStartMs = CurrentTime; double msPerTick = 1000d / FPSLimit; ReadQueue(loopStartMs); //Catch up on updates while (loopStartMs + msPerTick < _timePassed.Elapsed.TotalMilliseconds) { loopStartMs += msPerTick; ReadQueue(loopStartMs); } OnRender?.Invoke(this, Replay); ++_frames; //Updates average FPS if (_timePassed.ElapsedMilliseconds - _startTime > 500) { AverageFPS = (float)_frames / (_timePassed.Elapsed.TotalMilliseconds - _startTime) * 1000; _startTime = _timePassed.Elapsed.TotalMilliseconds; _frames = 0; } //Wait, if needed. Accurate enough TimeSpan waitTime = TimeSpan.FromMilliseconds((lastLoopMs + msPerTick) - _timePassed.Elapsed.TotalMilliseconds); if (waitTime.TotalMilliseconds > 0) { Thread.Sleep(waitTime); } //Wait when paused _pauseWaiter.WaitOne(); } }
public async Task RenderLoop() { while (Program.IsGameRunning) { OnRender?.Invoke(); AddNewDrawables(); UpdateDrawables(); DrawDrawables(); await Task.Delay(1000 / FramesPerSecond); } }
public void StartRendering() { while (Parent != null && Parent.Visible) { Application.DoEvents(); RenderContext.DispatchEvents(); var args = new OpenGLRenderEventsArgs(); RenderContext.Clear(Color.White); OnRender?.Invoke(RenderContext, args); Render(RenderContext, args); RenderContext.Display(); } }
public override void Render(IntPtr Resource, bool IsNewSurface) { //SharpDX.Configuration.EnableObjectTracking = true; if (Surface.ClientSize.Width != Width || Surface.ClientSize.Height != Height) { Width = Surface.ClientSize.Width; Height = Surface.ClientSize.Height; InitRenderTarget(); Resize(); } OnRender?.Invoke(); SwapChainRef.Present(0, PresentFlags.None); }
private void Core() { while (window.IsOpen) { if (!pause) { manager.Update(); } window.Clear(); window.DispatchEvents(); OnRender?.Invoke(window, EventArgs.Empty); window.Display(); } }
public override void Render(IntPtr Resource, bool IsNewSurface) { if (IsNewSurface) { Context.OutputMerger.ResetTargets(); InitRenderTargetSurface(Resource); Resize(); } Context.ClearRenderTargetView(RenderTargetViewRef, Color.Gray); RenderTarget2D?.BeginDraw(); OnRender?.Invoke(); RenderTarget2D?.EndDraw(); Context?.Flush(); }
private void RenderGraphics(List <Point> cells) { using (Graphics gridGraphics = PanGrid.CreateGraphics()) { using (BufferedGraphicsContext bgc = new BufferedGraphicsContext()) { using (BufferedGraphics bg = bgc.Allocate(gridGraphics, PanGrid.ClientRectangle)) { RenderCells(cells, bg); RenderGrid(bg); bg.Render(gridGraphics); } } } OnRender?.Invoke(_cells.Count); }
public virtual void Render(DwarfTime time, SpriteBatch batch) { Children.Sort( (child1, child2) => { return(child1.DrawOrder.CompareTo(child2.DrawOrder)); }); if (!IsVisible) { return; } OnRender.Invoke(); foreach (GUIComponent child in Children) { child.Render(time, batch); } }
private void HandleRenderVideoFrame() { // Render the screen into an image. var image = _video.Render(this, _spriteCoordinates, _flipScreen); // Convert the image into a bitmap format. byte[] bitmap = null; using (var steam = new MemoryStream()) { image.Save(steam, new SixLabors.ImageSharp.Formats.Bmp.BmpEncoder()); bitmap = steam.ToArray(); } // Delegate to the render event, passing the framebuffer to be rendered. _renderEventArgs.FrameBuffer = bitmap; OnRender?.Invoke(_renderEventArgs); }
protected override void OnRenderFrame(FrameEventArgs e) { GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //todo clear: make the camera clear by themselves if needed. GL.ClearDepth(1.0D); Action onRenderOnce; lock (_InvokeRenderLocker) { onRenderOnce = _InvokeOnRender; _InvokeOnRender = null; } onRenderOnce?.Invoke(); Layer.PhysicsEvent.WaitOne(); // wait for physics to be free Layer.UpdateRenderEvent.Reset(); // set update/render as busy foreach (Camera camera in Camera.Cameras) { camera.PrepareForRender(); } lock (MeshRenderer.ActiveMeshRenderersLocker) { Parallel.ForEach(MeshRenderer.ActiveMeshRenderers, mr => { mr.PrepareForRender(); }); } Time.ResetRender(); Time.BeginRender(); OnRender?.Invoke(new UpdateEventArgs(e.Time)); Time.EndRender(); Layer.UpdateRenderEvent.Set(); // set update/render as free SwapBuffers(); base.OnRenderFrame(e); }
private void GlControl_OnRender(object sender, GlControlEventArgs e) { if (Shader == null) { return; } var control = sender as GlControl; var vpx = 0; var vpy = 0; var vpw = control.ClientSize.Width; var vph = control.ClientSize.Height; Gl.Viewport(vpx, vpy, vpw, vph); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Gl.ClearColor(_bgColorVec.X, _bgColorVec.Y, _bgColorVec.Z, _bgColorVec.W); OnRender?.Invoke(sender, e); }
private void DrawCell(MouseEventArgs e) { if (e.Button != MouseButtons.Left && e.Button != MouseButtons.Right) { return; } using (Graphics graphics = PanGrid.CreateGraphics()) { int x = GetGridCoord(e.X, GridSize.Width); int y = GetGridCoord(e.Y, GridSize.Height); Brush cellBrush = e.Button == MouseButtons.Left ? Brushes.GreenYellow : Brushes.Black; Rectangle cellRect = new Rectangle(x, y, CellSize, CellSize); graphics.FillRectangle(cellBrush, cellRect); graphics.DrawRectangle(_gridPen, cellRect); UpdateLivingCellsList(e, x, y); OnRender?.Invoke(_cells.Count); } }
protected override void OnRenderFrame(FrameEventArgs e) { GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //todo clear: make the camera clear by themselves if needed. GL.ClearDepth(1.0D); Action onRenderOnce; lock (_InvokeRenderLocker) { onRenderOnce = _InvokeOnRender; _InvokeOnRender = null; } onRenderOnce?.Invoke(); Time.ResetRender(); Time.BeginRender(); OnRender?.Invoke(new UpdateEventArgs(e.Time)); Time.EndRender(); SwapBuffers(); base.OnRenderFrame(e); }
public async Task RenderCharacter(ushort address, byte value) { OnRender?.Invoke(this, new MockRemoteDisplayRenderEventArgs(address, value)); await Task.Delay(0); }
public virtual void Render() { OnRender.Apply(); }
public void Write(ushort address, byte value) { Memory[address] = value; OnRender?.Invoke(this, new AddressedByte(address, value)); }
public CloudPath(OnRender render) { this.render = render; }
public BoardControl_d3d() { Render += new OnRender(BoardControl_Render); //Mouse //Update += new DoUpdate( BoardControl_Update ); }
public override void RenderScene(DrawEventArgs args) { OnRender?.Invoke(this, args); }
public MotionManager OnRender(OnRender renderAnimation) { RenderAnimation = (layer, x, y, index, percent) => renderAnimation(layer, x, y); return(this); }
public static void Run(string title, int width, int height, ErrorHandler errorHandler) { App.errorHandler = errorHandler; if (errorHandler != null) { try { Run(); } catch (Exception e) { errorHandler(e); } } else { Run(); } void Run() { if (platform == null) { throw new Exception("App has not been initialized."); } if (Running) { throw new Exception("App is already running."); } Running = true; platform.Init(title, width, height); platform.CenterWindow(); platform.OnQuit += Quit; platform.OnWinClose += Quit; platform.OnWinFocusGained += () => Focused = true; platform.OnWinFocusLost += () => Focused = false; GL.Init(); Time.Init(1f / 60f); Screen.Init(); Mouse.Init(); Keyboard.Init(); Joystick.Init(); OnInit?.Invoke(); double prevTime = platform.GetTime(); double frameTimer = 0.0; while (Running) { platform.PollEvents(); if (!Focused && !UpdateWhileFocused) { prevTime = (float)platform.GetTime(); continue; } if (Running) { double currTime = platform.GetTime(); double deltaTime = currTime - prevTime; if (deltaTime > 0.0) { FPS = (int)(1.0 / (currTime - prevTime)); } prevTime = currTime; if (FixedFramerate) { if (!Screen.VSync) { frameTimer += deltaTime; while (frameTimer >= frameDuration) { frameTimer -= frameDuration; Update(frameDuration); } } else { Update(frameDuration); } } else { Update(deltaTime); } void Update(double dt) { Time.PreUpdate((float)dt); Mouse.PreUpdate(); OnUpdate?.Invoke(); Mouse.PostUpdate(); Keyboard.PostUpdate(); Joystick.PostUpdate(); Texture.UnbindAll(); DrawCall.Begin(); OnRender?.Invoke(); DrawCall.End(); platform.SwapBuffers(); } } } OnQuit?.Invoke(); platform.Quit(); } }
internal virtual void DoRender(DrawBatch2D batch) { OnRender?.Invoke(batch); }