[clutter/wip/cogl-winsys-egl: 9/30] Adds Cogl Hello World example application
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/cogl-winsys-egl: 9/30] Adds Cogl Hello World example application
- Date: Wed, 20 Apr 2011 12:58:50 +0000 (UTC)
commit 464d2f1de0f439d666b2dc7ec4670b7a016d4527
Author: Robert Bragg <robert linux intel com>
Date: Thu Mar 17 19:32:54 2011 +0000
Adds Cogl Hello World example application
This adds a simple standalone Cogl application that can be used to
smoke test a standalone build of Cogl without Clutter.
clutter/cogl/Makefile.am | 2 +-
clutter/cogl/configure.ac | 1 +
clutter/cogl/examples/Makefile.am | 31 ++++++++++++++++++++++++
clutter/cogl/examples/hello.c | 47 +++++++++++++++++++++++++++++++++++++
configure.ac | 1 +
5 files changed, 81 insertions(+), 1 deletions(-)
---
diff --git a/clutter/cogl/Makefile.am b/clutter/cogl/Makefile.am
index e695860..3d7dd3e 100644
--- a/clutter/cogl/Makefile.am
+++ b/clutter/cogl/Makefile.am
@@ -1,7 +1,7 @@
SUBDIRS = cogl pango
if COGL_STANDALONE_BUILD
-SUBDIRS += po
+SUBDIRS += po examples
endif
ACLOCAL_AMFLAGS = -I build/autotools ${ACLOCAL_FLAGS}
diff --git a/clutter/cogl/configure.ac b/clutter/cogl/configure.ac
index 40af0e6..11d65d0 100644
--- a/clutter/cogl/configure.ac
+++ b/clutter/cogl/configure.ac
@@ -661,6 +661,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;
+}
diff --git a/configure.ac b/configure.ac
index 6020c0a..33daa68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1242,6 +1242,7 @@ AC_CONFIG_FILES([
clutter/cogl/Makefile
clutter/cogl/po/Makefile.in
+ clutter/cogl/examples/Makefile
clutter/cogl/cogl/Makefile
clutter/cogl/cogl/cogl-defines.h
clutter/cogl/cogl/cogl-1.0.pc:clutter/cogl/cogl/cogl-1.0-clutter.pc.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]