Timer routines
- ALLEGRO_TIMER
- ALLEGRO_USECS_TO_SECS
- ALLEGRO_MSECS_TO_SECS
- ALLEGRO_BPS_TO_SECS
- ALLEGRO_BPM_TO_SECS
- al_create_timer
- al_start_timer
- al_stop_timer
- al_get_timer_started
- al_destroy_timer
- al_get_timer_count
- al_set_timer_count
- al_add_timer_count
- al_get_timer_speed
- al_set_timer_speed
- al_get_timer_event_source
これらの関数はAllegroメインヘッダファイルで宣言されています。
#include <allegro5/allegro.h>
ALLEGRO_TIMER
タイマーオブジェクトを表す抽象型です。
typedef struct ALLEGRO_TIMER ALLEGRO_TIMER;
ALLEGRO_USECS_TO_SECS
マイクロ秒から秒に変換します。
#define ALLEGRO_USECS_TO_SECS(x) ((x) / 1000000.0)
ALLEGRO_MSECS_TO_SECS
ミリ秒から秒に変換します。
#define ALLEGRO_MSECS_TO_SECS(x) ((x) / 1000.0)
ALLEGRO_BPS_TO_SECS
BPSから秒に変換します。
#define ALLEGRO_BPS_TO_SECS(x) (1.0 / (x))
ALLEGRO_BPM_TO_SECS
BPMから秒に変換します。
#define ALLEGRO_BPM_TO_SECS(x) (60.0 / (x))
al_create_timer
新しいタイマーをインストールします。成功した場合、新しいタイマーオブジェクトを返し、失敗した場合はNULLを返します。speed_secsは"tick"の発生間隔(秒)で、正の値でなければいけません。新しいタイマーは停止しています。この関数が呼び出される前に、システムのドライバがインストールされている必要があります。
ALLEGRO_TIMER* al_create_timer(double speed_secs)
使用上の注意:一般的な精度はマイクロ秒オーダーですが、いくつかのドライバの場合はミリ秒かもしれません。
関連項目: al_start_timer, al_destroy_timer
al_start_timer
指定されたタイマーを開始します。タイマーのカウンターが一定速度でインクリメントされ、イベントの生成を開始します。既にタイマーが開始している場合、何も処理を行いません。
void al_start_timer(ALLEGRO_TIMER *timer)
関連項目: al_stop_timer, al_get_timer_started
al_stop_timer
指定されたタイマーを停止します。タイマーのカウンターのインクリメントを停止し、イベントを生成を停止します。既にタイマーが停止している場合、何も処理を行いません。
void al_stop_timer(ALLEGRO_TIMER *timer)
関連項目: al_start_timer, al_get_timer_started
al_get_timer_started
指定されたタイマーが開始された状態の場合、trueを返します。
bool al_get_timer_started(const ALLEGRO_TIMER *timer)
al_destroy_timer
指定されたタイマーをアンインストールします。タイマーが開始されている場合は、アンインストール前に自動的に停止します。また、任意のイベントキューとタイマーを解除します。
NULLポインタが渡された場合は何も処理を行いません。
void al_destroy_timer(ALLEGRO_TIMER *timer)
関連項目: al_create_timer
al_get_timer_count
指定されたタイマーのカウンター値を返します。指定するタイマーは開始済み、停止中のどちらでも利用可能です。
int64_t al_get_timer_count(const ALLEGRO_TIMER *timer)
関連項目: al_set_timer_count
al_set_timer_count
タイマーのカウンタの値を設定します。指定するタイマーは開始済み、停止中のどちらでも利用可能です。カウント値は、正または負の値が設定されますが、常に各刻みで1ずつインクリメントされます。
void al_set_timer_count(ALLEGRO_TIMER *timer, int64_t new_count)
関連項目: al_get_timer_count, al_add_timer_count
al_add_timer_count
void al_add_timer_count(ALLEGRO_TIMER *timer, int64_t diff)
Add diff to the timer's counter value. This is similar to writing:
al_set_timer_count(timer, al_get_timer_count(timer) + diff);
except that the addition is performed atomically, so no ticks will be lost.
See also: al_set_timer_count
al_get_timer_speed
double al_get_timer_speed(const ALLEGRO_TIMER *timer)
Return the timer's speed, in seconds.
See also: al_set_timer_speed
al_set_timer_speed
void al_set_timer_speed(ALLEGRO_TIMER *timer, double new_speed_secs)
Set the timer's speed, i.e. the rate at which its counter will be incremented when it is started. This can be done when the timer is started or stopped. If the timer is currently running, it is made to look as though the speed change occured precisely at the last tick.
speed_secs has exactly the same meaning as with al_create_timer.
See also: al_get_timer_speed
al_get_timer_event_source
ALLEGRO_EVENT_SOURCE *al_get_timer_event_source(ALLEGRO_TIMER *timer)
Retrieve the associated event source.
最終更新:2012年02月05日 17:44