Demos (master): egl/opengles1: Clean up "clear" demo.

Chia-I Wu olv at kemper.freedesktop.org
Fri Dec 10 03:43:22 UTC 2010


Module: Demos
Branch: master
Commit: 7371267a4a8326e4346e142fbc336e1bc9deded9
URL:    http://cgit.freedesktop.org/mesa/demos/commit/?id=7371267a4a8326e4346e142fbc336e1bc9deded9

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Fri Dec 10 11:39:24 2010 +0800

egl/opengles1: Clean up "clear" demo.

The demo was added in last commit.  I pushed it too early..

---

 src/egl/opengles1/Makefile.am |    1 +
 src/egl/opengles1/clear.c     |   30 ++++++++++++++++++++----------
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/egl/opengles1/Makefile.am b/src/egl/opengles1/Makefile.am
index 79c665b..752c3d1 100644
--- a/src/egl/opengles1/Makefile.am
+++ b/src/egl/opengles1/Makefile.am
@@ -66,6 +66,7 @@ render_tex_LDADD = $(X11_LIBS)
 texture_from_pixmap_LDADD = $(X11_LIBS)
 two_win_LDADD = $(X11_LIBS)
 
+# intentionally not link to GLESV1_LIBS
 clear_LDADD = ../eglut/libeglut_x11.la $(EGL_LIBS) $(X11_LIBS)
 clear_LDFLAGS =
 
diff --git a/src/egl/opengles1/clear.c b/src/egl/opengles1/clear.c
index 45f2626..9fe1b52 100644
--- a/src/egl/opengles1/clear.c
+++ b/src/egl/opengles1/clear.c
@@ -49,20 +49,30 @@ draw(void)
    fn_Clear(GL_COLOR_BUFFER_BIT);
 }
 
-static void
-init(void)
+static void *
+get_proc(const char *name)
 {
-   fn_ClearColor = (type_ClearColor) eglGetProcAddress("glClearColor");
-   if (!fn_ClearColor) {
-      printf("failed to find glClearColor\n");
-      exit(1);
-   }
-   fn_Clear = (type_Clear) eglGetProcAddress("glClear");
-   if (!fn_Clear) {
-      printf("failed to find glClear\n");
+   void *proc;
+
+   proc = (void *) eglGetProcAddress(name);
+   if (!proc) {
+      /*
+       * note that eglGetProcAddress is not required to support non-extension
+       * functions
+       */
+      printf("failed to find %s (not necessarily a bug)\n", name);
       exit(1);
    }
 
+   return proc;
+}
+
+static void
+init(void)
+{
+   fn_ClearColor = (type_ClearColor) get_proc("glClearColor");
+   fn_Clear = (type_Clear) get_proc("glClear");
+
    fn_ClearColor(1.0, 0.4, 0.4, 0.0);
 }
 




More information about the mesa-commit mailing list