[Vala] Rewriting GLib C code in Vala



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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]