2010/3/16 Jakob Reschke <[email protected]>:
> The test case code is attached (I hope this works on this mailing
> list, else I'm going to send another Email).
for whatever reason it attaches my C source file as an
application/octet-stream...
#include <agar/core.h>
#include <agar/gui.h>
AG_Timeout to1, to2;
Uint32
Timeout1(void *obj, Uint32 ival, void *arg)
{
printf("timeout 1\n");
return 0;
}
Uint32
Timeout2(void *obj, Uint32 ival, void *arg)
{
printf("timeout 2\n");
return 0;
}
void
ScheduleTimeouts(AG_Event *event)
{
printf("schedule timeout1 ival=1000\n");
AG_ScheduleTimeout(NULL, &to1, 1000);
printf("schedule timeout2 ival=2000\n");
AG_ScheduleTimeout(NULL, &to2, 2000);
AG_Object *ob;
AG_Timeout *to;
printf("timeout queue:\n");
/* print the timeout tailqueue */
AG_TAILQ_FOREACH(ob, &agTimeoutObjQ, tobjs) {
printf("---- obj %d : ", (int)ob);
AG_TAILQ_FOREACH(to, &ob->timeouts, timeouts) {
char *name;
if (to == &to1)
name = "timeout1";
else if (to == &to2)
name = "timeout2";
else
name = "unknown timeout";
printf("-- timeout %s at %d ticks ", name, to->ticks);
}
printf("\n");
}
}
int
main(int argc, char **argv)
{
AG_InitCore("timeouts", 0);
AG_InitVideo(320, 200, 32, 0);
AG_Window *win = AG_WindowNew(AG_WINDOW_PLAIN|AG_WINDOW_NOMOVE);
AG_Button *btn = AG_ButtonNewFn(win, 0, "Schedule timeouts",
ScheduleTimeouts, "");
AG_Expand(btn);
AG_WindowShow(win);
AG_SetTimeout(&to1, Timeout1, NULL, 0);
AG_SetTimeout(&to2, Timeout2, NULL, 0);
AG_EventLoop();
return 0;
}
_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html