/// <summary> /// Main render function; draws all the assets on the screen and refresh /// the screen with the speicified framerate. /// </summary> /// <param name="clock">Frame clock: gives all timing informations.</param> protected virtual void RenderFunction(IFrameBasedClock clock) { Resource.IDescriptor[] graphicResources; lock (ResourceStash) { // - Gets geometry resources which needs to be loaded var res = ResourceStash.TakeAll(x => x is Shape.Descriptor); graphicResources = res.ToArray(); } // - Prepare all attachments Renderer.LoadAttachments(graphicResources); using (var assets = GraphicRenderBuffer.Get(UsageType.Read)) { // - Render a frame Renderer.Render(assets.Value); } if (GraphicGameLoop.ExitRequest) { Renderer.CloseRendering(); } }
/// <summary> /// Main update function; all game logic MUST be executed in this /// context, keep passing the clock on each update call. /// </summary> /// <param name="clock">Frame clock: gives all timing informations.</param> protected virtual void UpdateFunction(IFrameBasedClock clock) { // - Update the game tree state RunningGame.Update(clock); // - Gets the game tree resources var descriptor = RunningGame.GetDescriptor(UpdateGameLoop.Scheduler); // - Dispatch resource loading lock (ResourceStash) { foreach (var resource in descriptor.Resources) { ResourceStash.Add(resource); } } // - Send the render assets to the graphic renderer using (var lk = GraphicRenderBuffer.Get(UsageType.Write)) lk.Value = descriptor.Assets; }