in vapi header :

 * Note that on systems with a working poll(2), that function is used
 * in place of g_poll(). Thus g_poll() must have the same signature as
 * poll(), meaning GPollFD must have the same layout as struct pollfd.

you can use posix "poll" function instead

first, pass an PollFD array to get_info function :

PollFD[] fds;
int64 timeout;
renderer.get_info (out fds, out timeout);
// ...
Posix.poll ((pollfd[])fds, (int)timeout);



2015-07-24 11:04 GMT+02:00 Dmitry Golovin <[email protected]>:

> Hello!
>
> I'm now transfering Cogl examples to Vala:
> https://github.com/tpimh/vala-cogl
>
> I'm a GLib newbie, so I need help with rewriting cogl-crate example:
> https://github.com/GNOME/cogl/blob/master/examples/cogl-crate.c
>
> Especially this part:
>
> ```c
>       while (1)
>         {
>           CoglPollFD *poll_fds;
>           int n_poll_fds;
>           int64_t timeout;
>
>           if (data.swap_ready)
>             {
>               paint (&data);
>               cogl_onscreen_swap_buffers (COGL_ONSCREEN (fb));
>             }
>
>           cogl_poll_renderer_get_info (cogl_context_get_renderer (ctx),
>                                        &poll_fds, &n_poll_fds, &timeout);
>
>           g_poll ((GPollFD *) poll_fds, n_poll_fds,
>                   timeout == -1 ? -1 : timeout / 1000);
>
>           cogl_poll_renderer_dispatch (cogl_context_get_renderer (ctx),
>                                        poll_fds, n_poll_fds);
>         }
> ```
>
> What I now have is:
>
> ```vala
>         while (true) {
>             Cogl.PollFD poll_fds;
>             int n_poll_fds;
>             int64 timeout;
>
>             if (swap_ready) {
>                 paint();
>                 ((Onscreen)fb).swap_buffers();
>             }
>
>           poll_renderer_get_info(ctx.get_renderer(), poll_fds, n_poll_fds,
> timeout);
>
>           /* poll? */
>
>           poll_renderer_dispatch(ctx.get_renderer(), poll_fds, n_poll_fds);
>         }
> ```
>
> I don't fully understand what PollFD is and what function in Vala GLib
> binding should be used for g_poll.
>
> Probably, I'm doing something terribly wrong. Maybe vapi line "public
> static int poll_renderer_get_info (Cogl.Renderer renderer, Cogl.PollFD
> poll_fds, int n_poll_fds, int64 timeout);" is wrong. You can find relevant
> vapi here:
> https://github.com/tpimh/vala-cogl/blob/master/vapi/cogl-2.0.vapi
>
> Thanks in advance!
>
> Regards,
> Dmitry
> _______________________________________________
> vala-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/vala-list
>
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to