Thanks, I've updated the article. This is the right way to cast
between AG_DriverSw and AG_Driver.

For the "Uint32 Tr1, Tr2" bit, you need to compile with
_USE_AGAR_TYPES, else Uint32 won't be defined.

The agIdleThresh test is really not necessary, that can be replaced
by just an "else".

On Sun, Apr 18, 2010 at 05:53:16PM -0400, Tim Oertel wrote:
> Got it to compile, with approximately the following changes.  I
> don't know if this is really the right way to cast the driver
> object between AG_DriverSw and AG_Driver, but it seems to work...
> This was a concat of the two files from the wiki.
> 
> ***************
> *** 209,215 ****
>         x = ev->data.button.x;
>         y = ev->data.button.y;
> 
> !       if (showUI && AG_WindowFocusAtPos(AGDRIVER_SW(drv), x,y)){
>             if (bgFocused) {
>                   bgFocused = 0;
>                   vz -= 1.0;     /* Move shape back */
> --- 209,215 ----
>         x = ev->data.button.x;
>         y = ev->data.button.y;
> 
> !       if (showUI && AG_WindowFocusAtPos(drv, x,y)){
>             if (bgFocused) {
>                   bgFocused = 0;
>                   vz -= 1.0;     /* Move shape back */
> ***************
> *** 253,259 ****
>   MyEventLoop(AG_Driver *drv)
>   {
>       AG_Window *win;
> !     int Tr1, Tr2 = 0;
> 
>       Tr1 = AG_GetTicks();
>       for (;;){
> --- 253,259 ----
>   MyEventLoop(AG_Driver *drv)
>   {
>       AG_Window *win;
> !     Uint32 Tr1, Tr2 = 0;
> 
>       Tr1 = AG_GetTicks();
>       for (;;){
> ***************
> *** 285,291 ****
>                */
>               AG_DriverEvent ev;
>               do {
> !                 if (AG_GetNextEvent(drv, &ev)) {
>                     if (MyEventProcessor(drv, &ev) == -1)
>                         return;
>                   }
> --- 285,291 ----
>                */
>               AG_DriverEvent ev;
>               do {
> !                 if (AG_GetNextEvent(drv, &ev) {
>                     if (MyEventProcessor(drv, &ev) == -1)
>                         return;
>                   }
> ***************
> *** 295,301 ****
>                * Process expired timers
>                */
>             AG_ProcessTimeouts(Tr2);
> !       } else if (AGDRIVER_SW(drv)->rCur > agIdleThresh) {
>               /* Idle */
>             AG_Delay(1);
>         }
> --- 295,301 ----
>                * Process expired timers
>                */
>             AG_ProcessTimeouts(Tr2);
> !       } else if (agView->rCur > agIdleThresh) {
>               /* Idle */
>             AG_Delay(1);
>         }
> ***************
> *** 367,373 ****
>        * Enter our custom event loop; agDriverSw is a pointer to the 
>        (single-window)
>        * driver instance which was created AG_InitVideo().
>        */
> !     MyEventLoop((AG_Driver *) agDriverSw);
> 
>       AG_Destroy();
>       return (0);
> --- 367,373 ----
>        * Enter our custom event loop; agDriverSw is a pointer to the 
>        (single-window)
>        * driver instance which was created AG_InitVideo().
>        */
> !     MyEventLoop(agDriverSw);
> 
>       AG_Destroy();
>       return (0);
> 
> 
> Tim Oertel wrote:
> >Thanks for the response,
> >
> >The current code on the website won't compile for me.  I fixed an
> >obvious missing parenthesis, but after fixing that, there seems to still
> >be a problem with the use of AG_Driver & AG_DriverSw... and I don't know
> >agar well enough to figure out how to solve that yet.
> >
> >
> >Julien Nadeau wrote:
> >>Hi,
> >>
> >>I've just updated that article (along with other articles on the wiki)
> >>to reflect agar-1.4.
> >>
> >>I wouldn't recommend staying with 1.3. Integration into existing SDL/gl
> >>applications works just as well in 1.4, but some (trivial) changes are
> >>needed to the event loop. Most importantly, event processing is done
> >>in a "driver-independent" fashion, so you need use AG_PendingEvents()
> >>to check for events, AG_GetNextEvent() to retrieve them, and then
> >>AG_ProcessEvent() to process them. This is documented under:
> >>http://libagar.org/man3/AG_Driver.
> >>
> >>On Sun, Apr 11, 2010 at 11:13:40AM -0400, Tim Oertel wrote:
> >>>I've been trying to integrate agar with an existing SDL/opengl program
> >>>of mine.  I wasn't getting too far, so backed off that for the moment,
> >>>and tried to just get OpenGL working with agar.
> >>>
> >>>I was trying to follow: 
> >>>http://wiki.libagar.org/wiki/Integrating_Agar_in_an_existing_GL_application
> >>>but that seems to be quite a bit out of date (compared with svn trunk).
> >>>
> >>>I replaced most of the MyEventLoop() code with the MyEventLoop() code 
> >>>from the
> >>>customeventloop in the demos.
> >>>
> >>>I got it to compile, but it doesn't display any opengl stuff, and the 
> >>>one window that
> >>>seems to be displayed doesn't respond to the mouse...
> >>>
> >>>(I've attached my version for reference.)
> >>>
> >>>Is there a better starting point?  My goal is to use agar for widgets on 
> >>>top
> >>>of my SDL/opengl program.  I'd prefer to continue to use the SDL 
> >>>interface,
> >>>so perhaps I'd be better off using agar 1.3 (just a guess) instead?
> >>>
> >>>
> >>
> >>>_______________________________________________
> >>>Agar mailing list
> >>>[email protected]
> >>>http://libagar.org/lists.html
> >
> >_______________________________________________
> >Agar mailing list
> >[email protected]
> >http://libagar.org/lists.html
> >
> 
> -- 
>                      |"Why should I be content to simply
> Twitter: manax2      | live in this world, when I, as a
> IM: [email protected] | human being, can CREATE it?!"
> my website: http://www.heroicproportions.org

_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html

Reply via email to