void OnUpdate(float delta) { _frameArgs.DeltaTime = delta; if (Update != null) { Update(this, _frameArgs); } _frameArgs.ClearEvents(); _frameArgs.Time += delta; }
void OnUpdate() { bool lowMem = false; while (_events.Count > 0) { EventBase e; _events.TryDequeue(out e); _frame.Enqueue(e); if (e is Pause) { DoUpdate(); _link.RemoveFromRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); _link.Dispose(); return; } else if (e is LowMemory) { lowMem = true; } else if (e is Resize) { this.InvokeOnMainThread(() => { EAGLContext.SetCurrentContext(_glContext); this.Initialize(false); }); } } DoUpdate(); _frame.ClearEvents(); if (lowMem) { _lowMemHandled = true; } }
void IRenderer.OnDrawFrame(Javax.Microedition.Khronos.Opengles.IGL10 gl) { EventBase e; if (this.IsPaused) { while (_queue.TryPeek(out e)) { if (e is Resume) { this.IsPaused = false; return; } else { _queue.TryDequeue(out e); } } Thread.Sleep(_minFrameTicks); return; } var ticks = Environment.TickCount; var diffTicks = ticks - _lastTicks; if (diffTicks <= 0) { return; } if (diffTicks < _minFrameTicks) { Thread.Sleep(_minFrameTicks - diffTicks); ticks = Environment.TickCount; diffTicks = ticks - _lastTicks; } _lastTicks = ticks; _event.Time = (double)ticks / 1000.0; _event.DeltaTime = (float)diffTicks / 1000f; if (_loadFrame > 0) { _event.DeltaTime = 1f / 60f; _loadFrame--; } while (_queue.TryDequeue(out e)) { _event.Enqueue(e); if (e is Pause) { this.IsPaused = true; } } ThreadContext.Current.GLContext = this.Handle; if (this.Update != null) { this.Update(this, _event); } if (this.Render != null) { this.Render(this, _event); } _event.ClearEvents(); }