2011-03-17 15:32:54 -04:00
|
|
|
#include <cogl/cogl.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2011-07-15 07:31:21 -04:00
|
|
|
CoglColor black;
|
|
|
|
|
2011-03-17 15:32:54 -04:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
CoglContext *ctx;
|
|
|
|
CoglOnscreen *onscreen;
|
|
|
|
CoglFramebuffer *fb;
|
|
|
|
GError *error = NULL;
|
|
|
|
CoglVertexP2C4 triangle_vertices[] = {
|
|
|
|
{0, 0.7, 0xff, 0x00, 0x00, 0x80},
|
|
|
|
{-0.7, -0.7, 0x00, 0xff, 0x00, 0xff},
|
|
|
|
{0.7, -0.7, 0x00, 0x00, 0xff, 0xff}
|
|
|
|
};
|
|
|
|
CoglPrimitive *triangle;
|
|
|
|
|
|
|
|
ctx = cogl_context_new (NULL, &error);
|
|
|
|
if (!ctx) {
|
|
|
|
fprintf (stderr, "Failed to create context: %s\n", error->message);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
onscreen = cogl_onscreen_new (ctx, 640, 480);
|
2011-05-04 06:10:54 -04:00
|
|
|
cogl_onscreen_show (onscreen);
|
|
|
|
|
2012-01-07 18:10:25 -05:00
|
|
|
fb = COGL_FRAMEBUFFER (onscreen);
|
2011-03-17 15:32:54 -04:00
|
|
|
cogl_push_framebuffer (fb);
|
|
|
|
|
|
|
|
triangle = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES,
|
|
|
|
3, triangle_vertices);
|
|
|
|
for (;;) {
|
2011-12-19 10:40:55 -05:00
|
|
|
CoglPollFD *poll_fds;
|
|
|
|
int n_poll_fds;
|
|
|
|
gint64 timeout;
|
|
|
|
|
2011-07-15 07:31:21 -04:00
|
|
|
cogl_clear (&black, COGL_BUFFER_BIT_COLOR);
|
2011-03-17 15:32:54 -04:00
|
|
|
cogl_primitive_draw (triangle);
|
|
|
|
cogl_framebuffer_swap_buffers (fb);
|
2011-12-19 10:40:55 -05:00
|
|
|
|
|
|
|
cogl_poll_get_info (ctx, &poll_fds, &n_poll_fds, &timeout);
|
|
|
|
g_poll ((GPollFD *) poll_fds, n_poll_fds, 0);
|
|
|
|
cogl_poll_dispatch (ctx, poll_fds, n_poll_fds);
|
2011-03-17 15:32:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|