Demos (master): egl/opengles1:

Chia-I Wu olv at kemper.freedesktop.org
Fri Dec 10 02:48:01 UTC 2010


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

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

egl/opengles1:

---

 src/egl/opengles1/Makefile.am |    4 ++
 src/egl/opengles1/clear.c     |   85 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+), 0 deletions(-)

diff --git a/src/egl/opengles1/Makefile.am b/src/egl/opengles1/Makefile.am
index 90d592d..79c665b 100644
--- a/src/egl/opengles1/Makefile.am
+++ b/src/egl/opengles1/Makefile.am
@@ -40,6 +40,7 @@ if HAVE_EGL
 if HAVE_GLESV1
 noinst_PROGRAMS = \
 	bindtex \
+	clear \
 	drawtex_screen \
 	drawtex_x11 \
 	es1_info \
@@ -65,6 +66,9 @@ render_tex_LDADD = $(X11_LIBS)
 texture_from_pixmap_LDADD = $(X11_LIBS)
 two_win_LDADD = $(X11_LIBS)
 
+clear_LDADD = ../eglut/libeglut_x11.la $(EGL_LIBS) $(X11_LIBS)
+clear_LDFLAGS =
+
 drawtex_screen_SOURCES = drawtex.c
 gears_screen_SOURCES = gears.c
 torus_screen_SOURCES = torus.c
diff --git a/src/egl/opengles1/clear.c b/src/egl/opengles1/clear.c
new file mode 100644
index 0000000..45f2626
--- /dev/null
+++ b/src/egl/opengles1/clear.c
@@ -0,0 +1,85 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.9
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Chia-I Wu <olv at lunarg.com>
+ */
+
+/*
+ * This demo tests eglGetProcAddress and glClear.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+
+#include "eglut.h"
+
+typedef void (GL_APIENTRY *type_ClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+typedef void (GL_APIENTRY *type_Clear)(GLbitfield mask);
+
+static type_ClearColor fn_ClearColor;
+static type_Clear fn_Clear;
+
+static void
+draw(void)
+{
+   fn_Clear(GL_COLOR_BUFFER_BIT);
+}
+
+static void
+init(void)
+{
+   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");
+      exit(1);
+   }
+
+   fn_ClearColor(1.0, 0.4, 0.4, 0.0);
+}
+
+int
+main(int argc, char *argv[])
+{
+   eglutInitWindowSize(300, 300);
+   eglutInitAPIMask(EGLUT_OPENGL_ES1_BIT);
+   eglutInit(argc, argv);
+
+   eglutCreateWindow("clear");
+
+   eglutDisplayFunc(draw);
+
+   init();
+
+   eglutMainLoop();
+
+   return 0;
+}




More information about the mesa-commit mailing list