Game Development Reference
In-Depth Information
Finallythismethodmayposecertainchallengeswhenintegratingtodifferentgameengines
as their rendering systems vary, in particular there may be some complexity involved in
threaded environments, as the game data may be processed and updated in one thread, but
therenderingwilloccurinaseparatethread,inthissituationweendupneedingsomeform
ofcachingorsynchronizationsystemtopassthedatafromonethreadtoanother,ultimately
removing one of the key advantages of this method.
2.2.1 Polling
Polling refers to the action of sampling the status of a system over time. In games, this
means that we sample game data every frame for as long as we are interested in captur-
ing or displaying it. A good example is the player's health, the user interface does not and
should not keep the health of the player; it should only retrieve it directly from the player
and display it.
The game engine must provide the interfaces for the UI to be able to poll the data we need
to display. One approach is to create interfaces for the data that must be polled.
class IUIPlayerData
{
float GetHealth() const = 0;
float GetStamina() const = 0;
IUIWeaponData* GetWeaponData() const = 0;
}
class Player : public IUIPlayerData
{
float GetHealth() const { return m_health + m_bonusHealth; }
float GetStamina() const { return m_stamina; }
IUIWeaponData* GetWeaponData() const { return m_activeWeapon; }
};
In this way, it is the responsibility of the Player class to provide the implementation of the
interface that will allow the UI code to poll for the data.
2.2.2 Rendering Passes
Breaking up the UI rendering into passes is very important in modern games, not all user
interfaceelementsshouldberenderedatthesametime.Theorganizationofpassesdepends
on the type of game and the game engine's architecture, but there are at least three passes
that are important.
Search WWH ::




Custom Search