[clutter/wip/cogl-winsys-egl: 29/37] Adds Cogl Hello World example app



commit db6d86579bc6281dce3d2fd6f77ad30ab18a38ed
Author: Robert Bragg <robert linux intel com>
Date:   Thu Mar 17 19:32:54 2011 +0000

    Adds Cogl Hello World example app

 clutter/cogl/configure.ac         |    1 +
 clutter/cogl/examples/Makefile.am |   31 ++++++++++++++++++++++++
 clutter/cogl/examples/hello.c     |   47 +++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/clutter/cogl/configure.ac b/clutter/cogl/configure.ac
index 0fc376b..732ad87 100644
--- a/clutter/cogl/configure.ac
+++ b/clutter/cogl/configure.ac
@@ -676,6 +676,7 @@ cogl/cogl-1.0.pc
 cogl/cogl-$COGL_MAJOR_VERSION.0.pc:cogl/cogl.pc.in
 cogl/cogl-defines.h
 pango/Makefile
+examples/Makefile
 po/Makefile.in
 )
 
diff --git a/clutter/cogl/examples/Makefile.am b/clutter/cogl/examples/Makefile.am
new file mode 100644
index 0000000..7633a0e
--- /dev/null
+++ b/clutter/cogl/examples/Makefile.am
@@ -0,0 +1,31 @@
+include $(top_srcdir)/build/autotools/Makefile.am.silent
+
+UNIT_TESTS = \
+	hello.c
+
+if X11_TESTS
+UNIT_TESTS += x11-foreign.c
+endif
+
+INCLUDES = \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/clutter/cogl \
+	-I$(top_builddir)/clutter/cogl
+
+common_ldadd = \
+	$(top_builddir)/cogl/libcogl.la \
+	$(top_builddir)/pango/libcoglpango.la
+
+noinst_PROGRAMS = hello
+
+if X11_TESTS
+noinst_PROGRAMS += x11-foreign
+endif
+
+hello_SOURCES = $(UNIT_TESTS)
+hello_CFLAGS = $(COGL_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS) -DCOGL_ENABLE_EXPERIMENTAL_2_0_API
+hello_CPPFLAGS = \
+	-DG_DISABLE_SINGLE_INCLUDES \
+	-DCOGL_DISABLE_DEPRECATED
+#hello_LDADD = $(COGL_DEP_LIBS) $(common_ldadd)
+hello_LDADD = $(common_ldadd)
diff --git a/clutter/cogl/examples/hello.c b/clutter/cogl/examples/hello.c
new file mode 100644
index 0000000..ace664f
--- /dev/null
+++ b/clutter/cogl/examples/hello.c
@@ -0,0 +1,47 @@
+#include <cogl/cogl.h>
+#include <glib.h>
+#include <stdio.h>
+
+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;
+    }
+    /* Eventually we want to get rid of any "default context" but for now it's
+     * needed...  */
+    cogl_set_default_context (ctx);
+
+    onscreen = cogl_onscreen_new (ctx, 640, 480);
+    /* Eventually there will be an implicit allocate on first use so this
+     * will become optional... */
+    fb = COGL_FRAMEBUFFER (onscreen);
+    if (!cogl_framebuffer_allocate (fb, &error)) {
+        fprintf (stderr, "Failed to allocate framebuffer: %s\n", error->message);
+        return 1;
+    }
+
+    cogl_push_framebuffer (fb);
+
+    triangle = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES,
+                                        3, triangle_vertices);
+    for (;;) {
+        cogl_primitive_draw (triangle);
+        cogl_framebuffer_swap_buffers (fb);
+    }
+
+    return 0;
+}



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