This sample demonstrates redirecting the usage of on-demand views. It represents a simple application that draws a plane and some game units like in a real-time strategy game. Around every unit Coherent UI draws an animated element that in a real game could be a nameplate or a health bar. The sample shows the perfect synchonization of the game frame with the interface even though Coherent UI actually works completely asynchronously to the client application.
The sample solution is already configured and you only have to compile and run it.
It uses a sample mini game framework that provides very basic functionality.
The output will be in the Coherent/Samples/UI/bin directory.
On-demand views are created by specifyng the appropriate flag in the ViewInfo strucure:
Every frame the units move a bit and their new nameplate positions are sent to the interface and a new frame is requested.
After drawing the game frame the interface surface is fetched.
The order of operations is not casual. The best possible performance is gained when you structure your interaction with the view context as follows:
You should always try to put as much computation between the frame requests and their fetches as possible because Coherent UI renders in multi-threaded way. Thus by drawing the game frame simultaneously with the UI you maximise the chances that the interface will be already rendered when you try to fetch it, leveraging modern multi-core systems.