protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (isStarting) { if (gdm != null) { // Frame buffer was created, so now we have a graphics device to create: gdm.InternalCreateDevice(this); } if (game != null) { game.DoStartup(); // Need to draw something to the back buffer and swap it, to avoid // having a black frame appear between the splash screen // and the game itself: TimeSpan target = gameLoop.TargetElapsedTime; if (!game.iOSFasterStartup) { updateGameTime.Update(target); game.Update(updateGameTime); } drawGameTime.Update(target); game.DoDraw(drawGameTime); // This will swap buffers } } }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); if (GraphicsContext == null || GraphicsContext.IsDisposed) { return; } //Should not happen at all.. if (!GraphicsContext.IsCurrent) { MakeCurrent(); } if (game != null) { _drawGameTime.Update(_now - _lastUpdate); _lastUpdate = _now; game.DoDraw(_drawGameTime); } try { SwapBuffers(); } catch (Exception ex) { Android.Util.Log.Error("Error in swap buffers", ex.ToString()); } }
private void OnRenderFrame(object sender, FrameEventArgs e) { if (GraphicsContext.CurrentContext == null || GraphicsContext.CurrentContext.IsDisposed) { return; } //Should not happen at all.. if (!GraphicsContext.CurrentContext.IsCurrent) { OpenTkGameWindow.MakeCurrent(); } if (Game != null) { _drawGameTime.Update(_now - _lastDrawTime); _lastDrawTime = _now; Game.DoDraw(_drawGameTime); } // GG EDIT flush to clear out buffers #if FALSE #if NACL OpenTK.Graphics.ES20.GL.Finish(); #else OpenTK.Graphics.OpenGL.GL.Flush(); #endif #endif OpenTkGameWindow.SwapBuffers(); }
private void OnRenderFrame(object sender, FrameEventArgs e) { if (GraphicsContext.CurrentContext == null || GraphicsContext.CurrentContext.IsDisposed) { return; } //Should not happen at all.. if (!GraphicsContext.CurrentContext.IsCurrent) { OpenTkGameWindow.MakeCurrent(); } if (Game != null) { _now = DateTime.Now; _updateGameTime.Update(_now - _lastUpdate); Game.DoUpdate(_updateGameTime); _drawGameTime.Update(_now - _lastUpdate); _lastUpdate = _now; Game.DoDraw(_drawGameTime); } OpenTkGameWindow.SwapBuffers(); }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); // This code was commented to make the code base more iPhone like. // More speed testing is required, to see if this is worse or better // game.DoStep(); if (game != null) { _drawGameTime.Update(_now - _lastUpdate); _lastUpdate = _now; game.DoDraw(_drawGameTime); } }
private void OnRenderFrame(object sender, FrameEventArgs e) { if (GraphicsContext.CurrentContext == null || GraphicsContext.CurrentContext.IsDisposed) { return; } //Should not happen at all.. if (!GraphicsContext.CurrentContext.IsCurrent) { window.MakeCurrent(); } // we should wait until window's not fullscreen to resize if (updateClientBounds && window.WindowState == WindowState.Normal) { // it seems, at least on linux, we can't resize if we disallow user resizing // make next state the current state _transitiveAllowUserResizing = AllowUserResizing; // allow resize to resize window window.WindowBorder = WindowBorder.Resizable; window.ClientRectangle = new System.Drawing.Rectangle(clientBounds.X, clientBounds.Y, clientBounds.Width, clientBounds.Height); updateClientBounds = false; } else if (_transitiveAllowUserResizing != _allowUserResizing) { // reset previous value AllowUserResizing = _transitiveAllowUserResizing; } if (window.WindowState != windowState) { window.WindowState = windowState; } if (Game != null) { _drawGameTime.Update(_now - _lastUpdate); _lastUpdate = _now; Game.DoDraw(_drawGameTime); } window.SwapBuffers(); }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); if (GraphicsContext == null || GraphicsContext.IsDisposed) { return; } //Should not happen at all.. if (!GraphicsContext.IsCurrent) { MakeCurrent(); } if (game != null) { _drawGameTime.Update(_now - _lastUpdate); _lastUpdate = _now; game.DoDraw(_drawGameTime); } SwapBuffers(); }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); // FIXME: Since Game.Exit may be called during an Update loop (and // in fact that is quite likely to happen), this code is now // littered with checks to _platform.IsRunning. It would be // nice if there weren't quite so many. The move to a // Game.Tick-centric architecture may eliminate this problem // automatically. if (_game != null) { _now = DateTime.Now; if (_isFirstTime) { // Initialize GameTime _updateGameTime = new GameTime(); _drawGameTime = new GameTime(); _lastUpdate = DateTime.Now; _isFirstTime = false; } if (_needsToResetElapsedTime) { _drawGameTime.ResetElapsedTime(); _needsToResetElapsedTime = false; } // Try to catch up with frames _drawGameTime.Update(_now - _lastUpdate); TimeSpan catchup = _drawGameTime.ElapsedGameTime; if (catchup > _game.TargetElapsedTime) { while (catchup > _game.TargetElapsedTime) { //Console.WriteLine("Catching up " + (catchup - _game.TargetElapsedTime)); catchup -= _game.TargetElapsedTime; _drawGameTime.ElapsedGameTime = _game.TargetElapsedTime; if (_platform.IsRunning) { _game.DoUpdate(_drawGameTime); } _extraElapsedTime += catchup; } if (_extraElapsedTime > _game.TargetElapsedTime) { //Console.WriteLine("FastForward " + _extraElapsedTime); if (_platform.IsRunning) { _game.DoUpdate(_drawGameTime); } _extraElapsedTime = TimeSpan.Zero; } } else { if (_platform.IsRunning) { _game.DoUpdate(_drawGameTime); } } //Console.WriteLine("Render " + _drawGameTime.ElapsedGameTime); // _game.DoUpdate(_drawGameTime); if (_platform.IsRunning) { _game.DoDraw(_drawGameTime); } _lastUpdate = _now; } }
protected override void OnRenderFrame(FrameEventArgs e) { PerformanceCounter.EndMensure("!OnRenderFrame"); PerformanceCounter.BeginMensure("OnRenderFrame"); if (inBackground) { return; } base.OnRenderFrame(e); MakeCurrent(); // This code was commented to make the code base more iPhone like. // More speed testing is required, to see if this is worse or better // game.DoStep(); if (game != null) { _nowDraw = DateTime.Now; //PerformanceCounter.Event ("Now", (int)_nowDraw.Millisecond); _drawGameTime.Update(_nowDraw - _lastDraw); _lastDraw = _nowDraw; game.DoDraw(_drawGameTime); } //PerformanceCounter.Event("SwapBuffers", true); PerformanceCounter.BeginMensure("SwapBuffers"); if (game.IsFixedTimeStep) { var now = DateTime.Now; var elapsed = now - _lastSwap; var remainder = (game.TargetElapsedTime - elapsed); if (remainder.TotalMilliseconds > 0) { _lastSwap = now + remainder; // don't measure when swap actually happened, count when it was supposed to // allow for drift if frame is a bit too slow. Thread.Sleep(remainder); } else { _lastSwap = now; } } SwapBuffers(); //PerformanceCounter.Event("EndSwap", true); PerformanceCounter.EndMensure("SwapBuffers"); /* var cc = GC.CollectionCount(0); * if(cc != lastCollectCount0) * { * Console.WriteLine("Collect0!"); * lastCollectCount0 = cc; * } * cc = GC.CollectionCount(1); * if(cc != lastCollectCount1) * { * Console.WriteLine("Collect1!"); * lastCollectCount1 = cc; * } * cc = GC.CollectionCount(2); * if(cc != lastCollectCount2) * { * Console.WriteLine("Collect2!"); * lastCollectCount2 = cc; * } * cc = GC.CollectionCount(3); * if(cc != lastCollectCount3) * { * Console.WriteLine("Collect3!"); * lastCollectCount3 = cc; * }*/ PerformanceCounter.EndMensure("OnRenderFrame"); PerformanceCounter.BeginMensure("!OnRenderFrame"); }