7 Jul 22:35
Re: Custom event loop, with a SDL+GL attached display surface
Hello again, Thanks, indeed I suppose this could help libraries integrating Agar. I will use the Agar version from latest SVN from now on. Maybe I will be able some day to contribute a patch, if needed. I was thinking too to making a variation of the Agar's snippet into my code, but your function is still more convenient. I will be unavailable for a bit more than 2 weeks but when I come back I will test it. Thanks again, Olivier. Le 07/07/2010 12:38, Julien Nadeau a écrit : > As of current SVN (r8820), this code has been moved into a separate > AG_SDL_TranslateEvent() function which you can now call from your > event loop to translate the SDL_Event to AG_DriverEvent. > > Note that it is still safe to just copy/paste the switch() statement > from AG_SDL_GetNextEvent() routine into your code, or otherwise > manually initialize the AG_DriverEvent. > > On Wed, Jun 30, 2010 at 06:24:33PM +0200, Olivier Boudeville wrote: > >> Hi, >> >> I had a look at customeventloop.c and at >> http://wiki.libagar.org/wiki/Integrating_Agar_in_an_existing_GL_application >> but something remains unclear to me: I used AG_InitVideoSDL, and with >> previous versions of Agar I was using in my event loop a call to >> 'SDL_PollEvent(& currentEvent )' which was returning a SDL_Event that I >> dispatched accordingly, possibly ending up in a 'AG_ProcessEvent(& >> currentEvent ) ;'. >> >> I am developping a library, using mostly SDL as a back-end, and >> *possibly* using Agar for the GUI. So I would like to keep as much as >> possible my already-available event-management logic, which routes >> (here, SDL) events to dedicated mouse/joystick/keyboard handlers; thus I >> would like to avoid as much as possible the use of the Agar >> encapsulation for these kinds of events (AG_PendingEvents, >> AG_GetNextEvent, AG_DRIVER_MOUSE_BUTTON_DOWN, etc.), since Agar may or >> may not used by the applications, and just be able to directly feed Agar >> with driver-specific (SDL) events. >> >> How would you proceed to do so? I was thinking to using the newer >> AG_ProcessEvent, however: >> - first argument is the driver: I do not know what to specify here >> in my case, NULL? (or a SDL-specific Agar driver?) >> - second is the Agar event, I thus need a SDL to Agar Event >> converter, for that I suppose I would need a subset of the code in >> AG_SDL_GetNextEvent, which performs two operations: the polling and the >> conversion, whereas I would need the latter only; another option would >> be to use directly AG_SDL_GetNextEvent and disable my own polling, but >> it would send all events to Agar, and force the rest of the library code >> to deal with Agar events instead of SDL ones, whereas Agar may be disabled >> >> Any hint? Best approach I would see would be to move the SDL -> Agar >> event conversion into a dedicated function that would be callable from >> my user code. >> >> Thanks in advance for any advice, >> Best regards, >> >> Olivier Boudeville. >> >> >> _______________________________________________ >> Agar mailing list >> Agar@... >> http://libagar.org/lists.html >> > >
RSS Feed