The sample application framework builds upon the Base Application Framework and is designed to hide game specific logic from the main sample file, thus better illustrating the integration with Coherent UI.
You should have read the Base Application Framework page before continuing.
The sample framework contains:
The sample framework uses glm for cross-platform mathematical operations. You can check the manual at the official site
The FPS camera provides means for moving around a 3D world and getting back view and projection matrices needed for rendering. It can be located in the Coherent/Samples/UI/C++/Common/Camera.cpp
file.
The important methods for movement are Camera::AddMoveFlags
and Camera::AddMouseDelta
, which should be called whenever a key or mouse event occurs. Then, each frame the Camera::Update
method is called, which updates the matrices and resets flags and deltas. Check Sample 03 - Input in 3D for basic usage.
The game object stores geometry and transformation for the object and can be tested for intersection with a ray. It can be located in the Coherent/Samples/UI/C++/Common/GameObject.cpp
file.
ViewEventListenerBase
is the base class with very basic capabilities and derives directly from Coherent::UI::ViewListener
. It is derived by ViewEventListenerWin
and ViewEventListenerLinux
, which provide functionality for the OnDraw
, CreateSurface
and DestroySurface
methods. The listeners are configured to use a default renderer and shared memory strategy. By default the ViewEventListenerWin
uses the DirectX renderer with shared textures (as opposed to shared memory) and will only work on Windows Vista and later. The ViewEventListenerLinux
uses the OpenGL renderer with shared memory (the OpenGL renderer doesn't support shared textures).
On Linux the isn't much to configure, as OpenGL + shared memory is currently the only way to go.
On Windows, you can try using shared memory instead of shared textures, or use an OpenGL renderer. If you try the OpenGL renderer, bear in mind that you might have to change the creation of effects for some of the samples.
The platform header (Coherent/Samples/UI/C++/Common/Platform.h
) has defines for the IRenderer
type and the ViewListener type that are used by default. The user-defined View Listener should derive from PlatformViewListener
and define and/or override only the needed methods.
The base application is located in the Coherent/Samples/UI/C++/Common/Application.h
file. It has a PlatformWindow and an IRenderer. The renderer used is defined by the Platform header. The base application has virtual methods for all of the events that the PlatformWindow
exposes. Those methods are bound to the events of the PlatformWindow
and can be overridden to customize behavior.
The user should derive the ApplicationBase
class and override the event handler functions, such as ApplicationBase::OnIdle
. The derived application should be created either globally, or in the main loop (coherent_sample_main) and then its Run
method should be called. The overridden event handlers will then be called until the window is closed.
Check one of the samples for example usage of the sample framework.