#include <cogl/cogl2-experimental.h>
#include <stdio.h>

int
main (int argc, char **argv)
{
  CoglContext *ctx;
  CoglOnscreen *onscreen1, *onscreen2;
  GError *error = NULL;
  CoglColor blue, green;

  ctx = cogl_context_new (NULL, &error);
  if (!ctx)
    {
      fprintf (stderr, "Failed to create context: %s\n", error->message);
      return 1;
    }

  onscreen1 = cogl_onscreen_new (ctx, 640, 480);
  cogl_onscreen_show (onscreen1);
  onscreen2 = cogl_onscreen_new (ctx, 640, 480);
  cogl_onscreen_show (onscreen2);

  cogl_color_set_from_4ub (&blue, 255, 128, 128, 255);
  cogl_color_set_from_4ub (&green, 128, 128, 255, 255);

  while (1)
    {
      cogl_push_framebuffer (COGL_FRAMEBUFFER (onscreen1));
      cogl_clear (&blue, COGL_BUFFER_BIT_COLOR);
      cogl_pop_framebuffer ();

      cogl_push_framebuffer (COGL_FRAMEBUFFER (onscreen2));
      cogl_clear (&green, COGL_BUFFER_BIT_COLOR);
      cogl_pop_framebuffer ();

      cogl_framebuffer_swap_buffers (COGL_FRAMEBUFFER (onscreen1));
      cogl_framebuffer_swap_buffers (COGL_FRAMEBUFFER (onscreen2));
    }

  return 0;
}
