![]() |
![]()
| ![]() |
![]()
NAME
SYNOPSIS#include <agar/core.h> #include <agar/gui.h> DESCRIPTIONIn general, most Agar GUI applications will use the standard Agar-Core event loop, AG_EventLoop(3), since it uses the most efficient event-notification mechanism available for the target platform (e.g., kqueue(2), select(2), etc.) However, Agar-GUI applications are not required
to use
CUSTOM EVENT LOOP EXAMPLEThe following event loop redraws Agar windows whenever needed (the redraw frequency being limited to some nomimal frame rate), processes input events, and executes timer callbacks (using an inefficient delay loop): void MY_GenericEventLoop(void *obj) { AG_Window *win; Uint32 t1, t2; t1 = AG_GetTicks(); for (;;) { t2 = AG_GetTicks(); if (t2 - t1 >= rNom) { AG_WindowDrawQueued(); t1 = AG_GetTicks(); rCur = rNom - (t1-t2); if (rCur < 1) { rCur = 1; } } else if (AG_PendingEvents(NULL)) { AG_DriverEvent dev; if (AG_GetNextEvent(NULL, &dev) == 1) AG_ProcessEvent(NULL, &dev); } else { AG_ProcessTimeouts(t2); AG_Delay(1); } AG_WindowProcessQueued(); } } SEE ALSOAG_Delay(3), AG_Driver(3), AG_Event(3), AG_EventLoop(3), AG_Timer(3), AG_Window(3) HISTORYThe
|