summaryrefslogtreecommitdiffstats
path: root/progs
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-04-22 21:17:14 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-04-22 21:17:14 +0000
commitfc06f9fb252264dd3fefe04afbb3820e885255ed (patch)
tree3af3c3d50e566c7d5fd467ee11295112ff356a51 /progs
parent20d44dc9bc0f60afa93a6542ebcda44ee88f69ef (diff)
downloadexternal_mesa3d-fc06f9fb252264dd3fefe04afbb3820e885255ed.zip
external_mesa3d-fc06f9fb252264dd3fefe04afbb3820e885255ed.tar.gz
external_mesa3d-fc06f9fb252264dd3fefe04afbb3820e885255ed.tar.bz2
demo / test progs
Diffstat (limited to 'progs')
-rw-r--r--progs/egl/Makefile42
-rw-r--r--progs/egl/demo1.c76
-rw-r--r--progs/egl/eglinfo.c153
3 files changed, 271 insertions, 0 deletions
diff --git a/progs/egl/Makefile b/progs/egl/Makefile
new file mode 100644
index 0000000..2778866
--- /dev/null
+++ b/progs/egl/Makefile
@@ -0,0 +1,42 @@
+# progs/egl/Makefile
+
+TOP = ../..
+include $(TOP)/configs/current
+
+
+INCLUDE_DIRS = -I$(TOP)/include
+
+HEADERS = $(TOP)/include/GLES/egl.h
+
+PROGRAMS = \
+ demo1 \
+ eglinfo
+
+
+.c.o:
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
+
+
+
+default: $(PROGRAMS)
+
+
+demo1: demo1.o $(LIB_DIR)/libEGL.so
+ $(CC) demo1.o -L$(LIB_DIR) -lEGL -o $@
+
+demo1.o: demo1.c $(HEADERS)
+ $(CC) -c $(CFLAGS) -I$(TOP)/include demo1.c
+
+
+eglinfo: eglinfo.o $(LIB_DIR)/libEGL.so
+ $(CC) eglinfo.o -L$(LIB_DIR) -lEGL -o $@
+
+eglinfo.o: eglinfo.c $(HEADERS)
+ $(CC) -c $(CFLAGS) -I$(TOP)/include eglinfo.c
+
+
+
+clean:
+ rm -f *.o *~
+ rm -f *.so
+ rm -f $(PROGRAMS)
diff --git a/progs/egl/demo1.c b/progs/egl/demo1.c
new file mode 100644
index 0000000..9b9a2ed
--- /dev/null
+++ b/progs/egl/demo1.c
@@ -0,0 +1,76 @@
+/*
+ * Exercise EGL API functions
+ */
+
+#include <GLES/egl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+
+int
+main(int argc, char *argv[])
+{
+ int maj, min;
+ EGLContext ctx;
+ EGLSurface pbuffer;
+ EGLConfig configs[10];
+ EGLint numConfigs, i;
+ EGLBoolean b;
+ const EGLint pbufAttribs[] = {
+ EGL_WIDTH, 500,
+ EGL_HEIGHT, 500,
+ EGL_NONE
+ };
+
+ /*
+ EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ */
+ EGLDisplay d = eglGetDisplay("!demo");
+ assert(d);
+
+ if (!eglInitialize(d, &maj, &min)) {
+ printf("demo: eglInitialize failed\n");
+ exit(1);
+ }
+
+ printf("EGL version = %d.%d\n", maj, min);
+ printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
+
+ eglGetConfigs(d, configs, 10, &numConfigs);
+ printf("Got %d EGL configs:\n", numConfigs);
+ for (i = 0; i < numConfigs; i++) {
+ EGLint id, red, depth;
+ eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id);
+ eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red);
+ eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth);
+ printf("%2d: Red Size = %d Depth Size = %d\n", id, red, depth);
+ }
+
+ ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
+ if (ctx == EGL_NO_CONTEXT) {
+ printf("failed to create context\n");
+ return 0;
+ }
+
+ pbuffer = eglCreatePbufferSurface(d, configs[0], pbufAttribs);
+ if (pbuffer == EGL_NO_SURFACE) {
+ printf("failed to create pbuffer\n");
+ return 0;
+ }
+
+ b = eglMakeCurrent(d, pbuffer, pbuffer, ctx);
+ if (!b) {
+ printf("make current failed\n");
+ return 0;
+ }
+
+ b = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+
+ eglDestroySurface(d, pbuffer);
+ eglDestroyContext(d, ctx);
+ eglTerminate(d);
+
+ return 0;
+}
diff --git a/progs/egl/eglinfo.c b/progs/egl/eglinfo.c
new file mode 100644
index 0000000..7e29ce7
--- /dev/null
+++ b/progs/egl/eglinfo.c
@@ -0,0 +1,153 @@
+/*
+ * eglinfo - like glxinfo but for EGL
+ *
+ * Brian Paul
+ * 11 March 2005
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * 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
+ * BRIAN PAUL 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.
+ */
+
+
+#include <GLES/egl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAX_CONFIGS 1000
+#define MAX_MODES 1000
+
+
+/**
+ * Print table of all available configurations.
+ */
+static void
+PrintConfigs(EGLDisplay d)
+{
+ EGLConfig configs[MAX_CONFIGS];
+ EGLint numConfigs, i;
+
+ eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
+
+ printf("Configurations:\n");
+ printf(" bf lv d st colorbuffer dp st supported \n");
+ printf(" id sz l b ro r g b a th cl surfaces \n");
+ printf("----------------------------------------------\n");
+ for (i = 0; i < numConfigs; i++) {
+ EGLint id, size, level;
+ EGLint red, green, blue, alpha;
+ EGLint depth, stencil;
+ EGLint surfaces;
+ EGLint doubleBuf = 1, stereo = 0;
+ char surfString[100] = "";
+
+ eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id);
+ eglGetConfigAttrib(d, configs[i], EGL_BUFFER_SIZE, &size);
+ eglGetConfigAttrib(d, configs[i], EGL_LEVEL, &level);
+
+ eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red);
+ eglGetConfigAttrib(d, configs[i], EGL_GREEN_SIZE, &green);
+ eglGetConfigAttrib(d, configs[i], EGL_BLUE_SIZE, &blue);
+ eglGetConfigAttrib(d, configs[i], EGL_ALPHA_SIZE, &alpha);
+ eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth);
+ eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil);
+ eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces);
+
+ if (surfaces & EGL_WINDOW_BIT)
+ strcat(surfString, "win,");
+ if (surfaces & EGL_PBUFFER_BIT)
+ strcat(surfString, "pb,");
+ if (surfaces & EGL_PIXMAP_BIT)
+ strcat(surfString, "pix,");
+ if (strlen(surfString) > 0)
+ surfString[strlen(surfString) - 1] = 0;
+
+ printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %-12s\n",
+ id, size, level,
+ doubleBuf ? 'y' : '.',
+ stereo ? 'y' : '.',
+ red, green, blue, alpha,
+ depth, stencil, surfString);
+ }
+}
+
+
+/**
+ * Print table of all available configurations.
+ */
+static void
+PrintModes(EGLDisplay d)
+{
+#ifdef EGL_MESA_screen_surface
+ const char *extensions = eglQueryString(d, EGL_EXTENSIONS);
+ if (strstr("EGL_MESA_screen_surface", extensions)) {
+ EGLint scrn, numScreens = 1;
+ EGLModeMESA modes[MAX_MODES];
+ EGLint numModes, i;
+
+ for (scrn = 0; scrn < numScreens; scrn++) {
+ eglGetModesMESA(d, scrn, modes, MAX_MODES, &numModes);
+
+ printf("Screen %d Modes:\n", scrn);
+ printf(" id width height refresh\n");
+ printf("-------------------------\n");
+ for (i = 0; i < numModes; i++) {
+ EGLint id, w, h, r;
+ eglGetModeAttribMESA(d, modes[i], EGL_MODE_ID_MESA, &id);
+ eglGetModeAttribMESA(d, modes[i], EGL_WIDTH, &w);
+ eglGetModeAttribMESA(d, modes[i], EGL_HEIGHT, &h);
+ eglGetModeAttribMESA(d, modes[i], EGL_REFRESH_RATE_MESA, &r);
+ printf("0x%02x %5d %5d %.3f\n", id, w, h, r / 1000.0);
+ }
+ }
+ }
+#endif
+}
+
+
+
+int
+main(int argc, char *argv[])
+{
+ int maj, min;
+ EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+
+ if (!eglInitialize(d, &maj, &min)) {
+ printf("eglinfo: eglInitialize failed\n");
+ exit(1);
+ }
+
+ printf("EGL API version: %d.%d\n", maj, min);
+ printf("EGL vendor string: %s\n", eglQueryString(d, EGL_VENDOR));
+ printf("EGL version string: %s\n", eglQueryString(d, EGL_VERSION));
+ printf("EGL extensions string:\n");
+ printf(" %s\n", eglQueryString(d, EGL_EXTENSIONS));
+ printf("\n");
+
+ PrintConfigs(d);
+
+ printf("\n");
+
+ PrintModes(d);
+
+ eglTerminate(d);
+
+ return 0;
+}