[Cogl] [PATCH] Rework sdl integration api

Neil Roberts neil at linux.intel.com
Thu Apr 12 04:05:53 PDT 2012

On Wed, 11 Apr 2012 22:07:18 +0100, Robert Bragg <robert at sixbynine.org> wrote:

>           int status = SDL_PollEvent (&event);
>           if (!status && data.redraw_queued)
>             break;
>           else if (!status)
>             {
>               cogl_sdl_idle (ctx);
>               if (!SDL_WaitEvent (&event))
>                 {
>                   fprintf (stderr, "Error waiting for SDL events");
>                   return 1;
>                 }
>             }

Just a minor nitpick, couldn't those two if-statements be simplified
like this equivalent code:

if (!SDL_PollEvent (&event))
    if (data.redraw_queued)

    cogl_sdl_idle (ctx);
    if (!SDL_WaitEvent (&event))
        fprintf (stderr, "Error waiting for SDL events");
        return 1;

Otherwise the patch looks good to me.

Reviewed-by: Neil Roberts <neil at linux.intel.com>

> Out of curiosity, I wonder if you think this setup would work on the
> Palm Pre which I recall you saying has some funky interactions between
> SDL and glib?

I think it won't work because Palm's implementation of SDL internally
uses GLib with the default context in a separate thread. That means if
you try to use the GLib main loop the dispatch functions end up running
in a secret thread internal to WebOS. My solution before was to run a
sed script over the symbols exported by glib and change the soname so
that the application ends up linking against two distinct glib libraries
so that they can have their own independent default context. This is a
bit nuts though.

- Neil

More information about the Cogl mailing list