summaryrefslogtreecommitdiffstats
path: root/progs/egl/demo1.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-04-22 21:17:14 +0000
committerBrian Paul <[email protected]>2005-04-22 21:17:14 +0000
commitfc06f9fb252264dd3fefe04afbb3820e885255ed (patch)
tree3af3c3d50e566c7d5fd467ee11295112ff356a51 /progs/egl/demo1.c
parent20d44dc9bc0f60afa93a6542ebcda44ee88f69ef (diff)
demo / test progs
Diffstat (limited to 'progs/egl/demo1.c')
-rw-r--r--progs/egl/demo1.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/progs/egl/demo1.c b/progs/egl/demo1.c
new file mode 100644
index 00000000000..9b9a2ed4aba
--- /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;
+}