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;
|
2012-01-07 21:59:04 -05:00
|
|
|
CoglPipeline *pipeline;
|
2011-03-17 15:32:54 -04:00
|
|
|
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
|
|
|
|
2012-02-06 12:08:58 -05:00
|
|
|
triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES,
|
2011-03-17 15:32:54 -04:00
|
|
|
3, triangle_vertices);
|
2012-01-07 21:59:04 -05:00
|
|
|
|
|
|
|
pipeline = cogl_pipeline_new ();
|
|
|
|
|
2011-03-17 15:32:54 -04:00
|
|
|
for (;;) {
|
2011-12-19 10:40:55 -05:00
|
|
|
CoglPollFD *poll_fds;
|
|
|
|
int n_poll_fds;
|
|
|
|
gint64 timeout;
|
|
|
|
|
2012-01-07 18:28:36 -05:00
|
|
|
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
|
2012-01-07 21:59:04 -05:00
|
|
|
cogl_framebuffer_draw_primitive (fb, pipeline, triangle);
|
2011-03-17 15:32:54 -04:00
|
|
|
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;
|
|
|
|
}
|