2011-03-17 19:32:54 +00:00
|
|
|
#include <cogl/cogl.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2011-07-15 11:31:21 +00:00
|
|
|
CoglColor black;
|
|
|
|
|
2011-03-17 19:32:54 +00:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
CoglContext *ctx;
|
|
|
|
CoglOnscreen *onscreen;
|
|
|
|
CoglFramebuffer *fb;
|
2012-01-08 02:59:04 +00:00
|
|
|
CoglPipeline *pipeline;
|
2011-03-17 19:32:54 +00: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 10:10:54 +00:00
|
|
|
cogl_onscreen_show (onscreen);
|
2012-01-07 23:10:25 +00:00
|
|
|
fb = COGL_FRAMEBUFFER (onscreen);
|
2011-03-17 19:32:54 +00:00
|
|
|
|
2012-02-06 17:08:58 +00:00
|
|
|
triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES,
|
2011-03-17 19:32:54 +00:00
|
|
|
3, triangle_vertices);
|
2012-01-08 02:59:04 +00:00
|
|
|
|
2012-02-18 16:03:10 +00:00
|
|
|
pipeline = cogl_pipeline_new (ctx);
|
2012-01-08 02:59:04 +00:00
|
|
|
|
2011-03-17 19:32:54 +00:00
|
|
|
for (;;) {
|
2011-12-19 15:40:55 +00:00
|
|
|
CoglPollFD *poll_fds;
|
|
|
|
int n_poll_fds;
|
|
|
|
gint64 timeout;
|
|
|
|
|
2012-01-07 23:28:36 +00:00
|
|
|
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
|
2012-01-08 02:59:04 +00:00
|
|
|
cogl_framebuffer_draw_primitive (fb, pipeline, triangle);
|
2012-02-08 23:46:16 +00:00
|
|
|
cogl_onscreen_swap_buffers (onscreen);
|
2011-12-19 15:40:55 +00: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 19:32:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|