Note: The Agar manual pages follow certain conventions, notably
concerning function return values. Please read
AG_Intro(3)
first.
SYNOPSIS
#include <agar/core.h>
#include <agar/gui.h>
|
DESCRIPTION
|
The event loop of an Agar application typically waits for events, invokes
GUI rendering routines and processes timer events.
Applications can either use the stock event loop routine,
AG_EventLoop(), or a custom event loop.
|
GENERIC EVENT LOOP
void AG_EventLoop (void)
void AG_EventLoop_FixedFPS (void)
void AG_EventLoop_Drv (AG_Driver *drv)
|
The
AG_EventLoop() routine enters a generic Agar event loop, which performs the following
tasks:
- Render GUI elements to the graphics system as necessary.
- Process incoming events from the system.
- Invoke timed callback functions (see
AG_Timeout(3)).
- Let the application idle if possible.
AG_EventLoop() is a general-purpose event loop suitable for most common applications.
The
AG_EventLoop_FixedFPS() variant tries to guarantee a constant display refresh rate (at the potential
cost of reduced accuracy of time-sensitive events).
Both
AG_EventLoop() and
AG_EventLoop_FixedFPS() assume that the application is using a single Agar driver, as it is the
case for most applications.
The
AG_EventLoop_Drv() variant allows applications which may want to use different Agar drivers
concurrently, to specify a driver instance via the
drv argument.
|
CUSTOM EVENT LOOPS
|
As of Agar-1.4.0, it is possible to write custom event loops in a
driver-independent fashion, using the functions
AG_PendingEvents(), AG_GetNextEvent() and
AG_ProcessEvent(). Low-level driver events are represented by the
AG_DriverEvent structure.
See
AG_Driver(3) for more information.
|
EXAMPLES
|
See
AG_Driver(3). Also see
demos/customeventloop in the Agar distribution for an example of an application using a custom
event loop.
|
SEE ALSO
HISTORY
|
The
AG_EventLoop routine first appeared in
Agar 1.0.
While custom event loops were possible with
Agar 1.3, an official API for
low-level event processing only appeared in
Agar 1.4.0.
|