public void OnRender(object sender, FrameArgs e) { if (_isVisible) { this.OnDraw(e); } }
public virtual void Start(object sender, Start args) { var frameArgs = new FrameArgs(); frameArgs.Enqueue(args); frameArgs.Enqueue(new Resize(args.Size, args.PixelScale)); OnUpdate(sender, frameArgs); }
void FadeTo(Scene nextScene, Start startArgs, FrameArgs frameArgs) { if (_scene == null) { throw new InvalidOperationException("No current scene to crossfade from!"); } var prevScene = _scene; _scene = nextScene; _t = 0; _fading = true; if (_duration <= 0) { Skip(); } else { if (_prevTexture == null) { _prevTexture = new Texture(new System.Drawing.Size((int)startArgs.Size.X, (int)startArgs.Size.Y)); } if (_nextTexture == null) { _nextTexture = new Texture(new System.Drawing.Size((int)startArgs.Size.X, (int)startArgs.Size.Y)); } if (_prevFBO == null) { _prevFBO = new FrameBuffer(_prevTexture); } if (_nextFBO == null) { _nextFBO = new FrameBuffer(_nextTexture); } using (_prevFBO.Begin()) { if (prevScene != null) { prevScene.DrawNow(frameArgs); } else { base.OnDraw(frameArgs); } } View.RenderNow(); } if (prevScene != null && _disposeCurrent) { prevScene.Dispose(); } View.LoadFrame(); }
void IHandler <Resize> .Handle(FrameArgs frame, Resize e) { _cam = new Camera2D(e.Size, 2); if (_quad != null) { _quad.Dispose(); } _quad = new Quad(new Vector4(0, 0, e.Size.X, e.Size.Y), Vector4.One); }
public AndroidGameView (Context context, int maxFramesPerSecond = 60) : base(context) { _event = new FrameArgs (); _queue = new ConcurrentQueue<EventBase> (); _enabledGestures = new HashSet<GestureType> (); this.SetEGLContextClientVersion (2); this.SetRenderer (this); _minFrameTicks = 1000 / maxFramesPerSecond; Sounds.Init (); }
void IUpdater.Update(FrameArgs e) { var obj = this as CoroutineList <FrameArgs>; if (obj != null) { obj.Update(e); } else { this.Update(); } }
protected virtual void OnDraw(FrameArgs e) { #if __ANDROID__ GL.Enable(All.DepthTest); GL.Enable(All.Blend); GL.BlendFunc(All.One, All.OneMinusSrcAlpha); #else GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); #endif GL.DepthMask(true); GL.ClearColor(this.ClearColor); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); }
protected sealed override void OnDraw(FrameArgs e) { if (_scene == null) { base.OnDraw(e); return; } if (_fading) { if (_t > 0) { using (_nextFBO.Begin()) { _scene.DrawNow(e); } } OnComposeScenes(e, _prevTexture, _nextTexture, _t); } }
protected virtual void OnComposeScenes(FrameArgs e, Texture prevTexture, Texture nextTexture, float t) { using (_cam.Begin()) { var origColor = ClearColor; ClearColor = System.Drawing.Color.Black; base.OnDraw(e); ClearColor = origColor; _mat.Texture = prevTexture; _mat.Color = Vector4.One; using (_mat.Begin()) { _quad.Draw(0, 0, 0); } if (_t > 0) { _mat.Texture = nextTexture; _mat.Color = new Vector4(t, t, t, t); using (_mat.Begin()) { _quad.Draw(0, 0, 1); } } } }
public void Update(FrameArgs e) { if (_newScene != null) { if (_scene != null) { _scene.IsVisible = false; _scene.IsUpdating = false; } _scene = _newScene; _newScene = null; _scene.IsUpdating = true; _scene.IsVisible = true; _scene.Start(this, new GameStack.Start(this.View.Size, this.View.PixelScale)); } if (_nextScene != null) { _scene.IsVisible = false; this.FadeTo(_nextScene, new Start(this.View.Size, this.View.PixelScale), e); _nextScene = null; _scene.IsVisible = false; _scene.IsUpdating = true; _scene.Start(this, new GameStack.Start(this.View.Size, this.View.PixelScale)); _scene.IsUpdating = _freezeNext; } if (_fading) { _t += e.DeltaTime / _duration; if (_t > 1f) { Skip(); } } }
public void DrawNow(FrameArgs e) { this.OnDraw(e); }
public void OnUpdate(object sender, FrameArgs e) { if (!_isUpdating) { return; } int count = 0; try { foreach (var evt in e.Events) { var t = evt.GetType(); _handlerArgs[0] = e; _handlerArgs[1] = evt; List <Delegate> actionList; if (_actions.TryGetValue(t, out actionList)) { count = actionList.Count; for (var i = 0; i < count; i++) { if (actionList[i] != null) { actionList[i].DynamicInvoke(_handlerArgs); } } } List <KeyValuePair <object, MethodInfo> > handlerList; if (_handlers.TryGetValue(t, out handlerList)) { count = handlerList.Count; for (var i = 0; i < count; i++) { var kv = handlerList[i]; if (kv.Value != null) { kv.Value.Invoke(kv.Key, _handlerArgs); } } } } } catch (TargetInvocationException ex) { if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.ToString()); } #if DEBUG throw; #endif } try { count = _updaters.Count; for (var i = 0; i < count; i++) { if (_updaters[i] != null) { _updaters[i].Update(e); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); #if DEBUG throw; #endif } // cleanup foreach (var list in _actions.Values) { list.RemoveAll(o => o == null); } foreach (var list in _handlers.Values) { list.RemoveAll(o => o.Value == null); } _updaters.RemoveAll(o => o == null); }
public void Update(FrameArgs frame) { this.Update(frame.DeltaTime); }
public void Update (FrameArgs e) { if(_isRunning) this.Apply(e.Time - _startTime); }
void IUpdater.Update(FrameArgs frame) { this.Update(frame.DeltaTime); }
void IHandler <Start> .Handle(FrameArgs frame, Start e) { _mat = new SpriteMaterial(new SpriteShader(), null); }