aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/Mesa_6.4.2/progs/egl
diff options
context:
space:
mode:
authorftrapero <frantracer@gmail.com>2017-06-27 12:08:38 +0200
committerftrapero <frantracer@gmail.com>2017-06-27 12:08:38 +0200
commitb30506dface604c78e445905ce263f166945d67b (patch)
tree1c23f91f36eb445850b654daa9c5e30bb47072e5 /nx-X11/extras/Mesa_6.4.2/progs/egl
parentc032f0e341c981036e9b3245a0e0710ad61599d0 (diff)
parent663631725ee2d633d9ec5821cd48953ffd188d00 (diff)
downloadnx-libs-b30506dface604c78e445905ce263f166945d67b.tar.gz
nx-libs-b30506dface604c78e445905ce263f166945d67b.tar.bz2
nx-libs-b30506dface604c78e445905ce263f166945d67b.zip
Include mesa-6.4.2 project
Diffstat (limited to 'nx-X11/extras/Mesa_6.4.2/progs/egl')
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/egl/Makefile65
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/egl/demo1.c145
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/egl/demo2.c190
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/egl/demo3.c636
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/egl/eglgears.c448
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/egl/eglinfo.c162
6 files changed, 1646 insertions, 0 deletions
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/egl/Makefile b/nx-X11/extras/Mesa_6.4.2/progs/egl/Makefile
new file mode 100644
index 000000000..41cadf97d
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/egl/Makefile
@@ -0,0 +1,65 @@
+# progs/egl/Makefile
+
+TOP = ../..
+include $(TOP)/configs/current
+
+
+INCLUDE_DIRS = -I$(TOP)/include
+
+HEADERS = $(TOP)/include/GLES/egl.h
+
+PROGRAMS = \
+ demo1 \
+ demo2 \
+ demo3 \
+ eglinfo \
+ eglgears
+
+
+.c.o:
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
+
+
+
+default: $(PROGRAMS)
+
+
+demo1: demo1.o $(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) demo1.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
+
+demo1.o: demo1.c $(HEADERS)
+ $(CC) -c $(CFLAGS) -I$(TOP)/include demo1.c
+
+
+demo2: demo2.o $(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) demo2.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
+
+demo2.o: demo2.c $(HEADERS)
+ $(CC) -c $(CFLAGS) -I$(TOP)/include demo2.c
+
+
+demo3: demo3.o $(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) demo3.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
+
+demo3.o: demo3.c $(HEADERS)
+ $(CC) -c $(CFLAGS) -I$(TOP)/include demo3.c
+
+
+eglinfo: eglinfo.o $(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) eglinfo.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
+
+eglinfo.o: eglinfo.c $(HEADERS)
+ $(CC) -c $(CFLAGS) -I$(TOP)/include eglinfo.c
+
+
+eglgears: eglgears.o $(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) eglgears.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
+
+eglgears.o: eglgears.c $(HEADERS)
+ $(CC) -c $(CFLAGS) -I$(TOP)/include eglgears.c
+
+
+clean:
+ rm -f *.o *~
+ rm -f *.so
+ rm -f $(PROGRAMS)
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/egl/demo1.c b/nx-X11/extras/Mesa_6.4.2/progs/egl/demo1.c
new file mode 100644
index 000000000..9ef17e38b
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/egl/demo1.c
@@ -0,0 +1,145 @@
+/*
+ * Exercise EGL API functions
+ */
+
+#include <GLES/egl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/**
+ * Test EGL_MESA_screen_surface functions
+ */
+static void
+TestScreens(EGLDisplay dpy)
+{
+#define MAX 8
+ EGLScreenMESA screens[MAX];
+ EGLint numScreens;
+ EGLint i;
+
+ eglGetScreensMESA(dpy, screens, MAX, &numScreens);
+ printf("Found %d screens\n", numScreens);
+ for (i = 0; i < numScreens; i++) {
+ printf(" Screen %d handle: %d\n", i, (int) screens[i]);
+ }
+}
+
+/**
+ * Print table of all available configurations.
+ */
+static void
+PrintConfigs(EGLDisplay d)
+{
+ EGLConfig *configs;
+ EGLint numConfigs, i;
+
+ eglGetConfigs(d, NULL, 0, &numConfigs);
+ configs = malloc(sizeof(*configs) *numConfigs);
+ eglGetConfigs(d, configs, numConfigs, &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);
+ }
+ free(configs);
+}
+
+
+
+int
+main(int argc, char *argv[])
+{
+ int maj, min;
+ EGLContext ctx;
+ EGLSurface pbuffer;
+ EGLConfig configs[10];
+ EGLBoolean b;
+ const EGLint pbufAttribs[] = {
+ EGL_WIDTH, 500,
+ EGL_HEIGHT, 500,
+ EGL_NONE
+ };
+
+ /*
+ EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ */
+ EGLDisplay d = eglGetDisplay("!fb_dri");
+ 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));
+
+ PrintConfigs(d);
+
+ 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);
+
+ TestScreens(d);
+
+ eglDestroySurface(d, pbuffer);
+ eglDestroyContext(d, ctx);
+ eglTerminate(d);
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/egl/demo2.c b/nx-X11/extras/Mesa_6.4.2/progs/egl/demo2.c
new file mode 100644
index 000000000..7abe947b9
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/egl/demo2.c
@@ -0,0 +1,190 @@
+/*
+ * Exercise EGL API functions
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <GLES/egl.h>
+
+/*#define FRONTBUFFER*/
+
+static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+{
+ glBegin( GL_QUADS );
+ glVertex2f( x1, y1 );
+ glVertex2f( x2, y1 );
+ glVertex2f( x2, y2 );
+ glVertex2f( x1, y2 );
+ glEnd();
+}
+
+
+static void redraw(EGLDisplay dpy, EGLSurface surf, int rot)
+{
+ printf("Redraw event\n");
+
+#ifdef FRONTBUFFER
+ glDrawBuffer( GL_FRONT );
+#else
+ glDrawBuffer( GL_BACK );
+#endif
+
+ glClearColor( rand()/(float)RAND_MAX,
+ rand()/(float)RAND_MAX,
+ rand()/(float)RAND_MAX,
+ 1);
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glColor3f( rand()/(float)RAND_MAX,
+ rand()/(float)RAND_MAX,
+ rand()/(float)RAND_MAX );
+ glPushMatrix();
+ glRotatef(rot, 0, 0, 1);
+ glScalef(.5, .5, .5);
+ _subset_Rectf( -1, -1, 1, 1 );
+ glPopMatrix();
+
+#ifdef FRONTBUFFER
+ glFlush();
+#else
+ eglSwapBuffers( dpy, surf );
+#endif
+ glFinish();
+}
+
+
+/**
+ * Test EGL_MESA_screen_surface functions
+ */
+static void
+TestScreens(EGLDisplay dpy)
+{
+#define MAX 8
+ EGLScreenMESA screens[MAX];
+ EGLint numScreens;
+ EGLint i;
+
+ eglGetScreensMESA(dpy, screens, MAX, &numScreens);
+ printf("Found %d screens\n", numScreens);
+ for (i = 0; i < numScreens; i++) {
+ printf(" Screen %d handle: %d\n", i, (int) screens[i]);
+ }
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ int maj, min;
+ EGLContext ctx;
+ EGLSurface pbuffer, screen_surf;
+ EGLConfig configs[10];
+ EGLint numConfigs, i;
+ EGLBoolean b;
+ const EGLint pbufAttribs[] = {
+ EGL_WIDTH, 500,
+ EGL_HEIGHT, 500,
+ EGL_NONE
+ };
+ const EGLint screenAttribs[] = {
+ EGL_WIDTH, 1024,
+ EGL_HEIGHT, 768,
+ EGL_NONE
+ };
+ EGLModeMESA mode;
+ EGLScreenMESA screen;
+ EGLint count;
+
+ /*
+ EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ */
+ EGLDisplay d = eglGetDisplay("!fb_dri");
+ 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);
+ }
+
+ eglGetScreensMESA(d, &screen, 1, &count);
+ eglGetModesMESA(d, screen, &mode, 1, &count);
+
+ 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);
+
+ screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
+ if (screen_surf == EGL_NO_SURFACE) {
+ printf("failed to create screen surface\n");
+ return 0;
+ }
+
+ eglShowSurfaceMESA(d, screen, screen_surf, mode);
+
+ b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
+ if (!b) {
+ printf("make current failed\n");
+ return 0;
+ }
+
+ glViewport(0, 0, 1024, 768);
+ glDrawBuffer( GL_FRONT );
+
+ glClearColor( 0,
+ 1.0,
+ 0,
+ 1);
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+
+ TestScreens(d);
+
+ glShadeModel( GL_FLAT );
+
+ for (i = 0; i < 6; i++) {
+ redraw(d, screen_surf, i*10 );
+
+ printf("sleep(1)\n");
+ sleep(1);
+ }
+
+ eglDestroySurface(d, pbuffer);
+ eglDestroyContext(d, ctx);
+ eglTerminate(d);
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/egl/demo3.c b/nx-X11/extras/Mesa_6.4.2/progs/egl/demo3.c
new file mode 100644
index 000000000..2693c3720
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/egl/demo3.c
@@ -0,0 +1,636 @@
+/*
+ * Exercise EGL API functions
+ */
+
+#include <GLES/egl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+
+#define PIXEL_CENTER(x) ((long)(x) + 0.5)
+
+#define GAP 10
+#define ROWS 3
+#define COLS 4
+
+#define OPENGL_WIDTH 48
+#define OPENGL_HEIGHT 13
+
+
+GLenum rgb, doubleBuffer, windType;
+GLint windW, windH;
+
+GLenum mode1, mode2;
+GLint boxW, boxH;
+GLubyte OpenGL_bits[] = {
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01,
+ 0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x3e, 0x8f, 0xb7, 0xf9, 0xfc, 0x01,
+ 0x63, 0xdb, 0xb0, 0x8d, 0x0d, 0x00,
+ 0x63, 0xdb, 0xb7, 0x8d, 0x0d, 0x00,
+ 0x63, 0xdb, 0xb6, 0x8d, 0x0d, 0x00,
+ 0x63, 0x8f, 0xf3, 0xcc, 0x0d, 0x00,
+ 0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0a,
+ 0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0e,
+ 0x63, 0x00, 0x00, 0x8c, 0xed, 0x0e,
+ 0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00,
+};
+
+
+static void Init(void)
+{
+
+ mode1 = GL_TRUE;
+ mode2 = GL_TRUE;
+}
+
+static void Reshape(int width, int height)
+{
+
+ windW = (GLint)width;
+ windH = (GLint)height;
+}
+
+#if 0
+static void RotateColorMask(void)
+{
+ static GLint rotation = 0;
+
+ rotation = (rotation + 1) & 0x3;
+ switch (rotation) {
+ case 0:
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glIndexMask( 0xff );
+ break;
+ case 1:
+ glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glIndexMask(0xFE);
+ break;
+ case 2:
+ glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE);
+ glIndexMask(0xFD);
+ break;
+ case 3:
+ glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE);
+ glIndexMask(0xFB);
+ break;
+ }
+}
+#endif
+
+static void Viewport(GLint row, GLint column)
+{
+ GLint x, y;
+
+ boxW = (windW - (COLS + 1) * GAP) / COLS;
+ boxH = (windH - (ROWS + 1) * GAP) / ROWS;
+
+ x = GAP + column * (boxW + GAP);
+ y = GAP + row * (boxH + GAP);
+
+ glViewport(x, y, boxW, boxH);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-boxW/2, boxW/2, -boxH/2, boxH/2, 0.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+
+ glEnable(GL_SCISSOR_TEST);
+ glScissor(x, y, boxW, boxH);
+}
+
+enum {
+ COLOR_BLACK = 0,
+ COLOR_RED,
+ COLOR_GREEN,
+ COLOR_YELLOW,
+ COLOR_BLUE,
+ COLOR_MAGENTA,
+ COLOR_CYAN,
+ COLOR_WHITE
+};
+
+static float RGBMap[9][3] = {
+ {0, 0, 0},
+ {1, 0, 0},
+ {0, 1, 0},
+ {1, 1, 0},
+ {0, 0, 1},
+ {1, 0, 1},
+ {0, 1, 1},
+ {1, 1, 1},
+ {0.5, 0.5, 0.5}
+};
+
+static void SetColor(int c)
+{
+ glColor3fv(RGBMap[c]);
+}
+
+static void Point(void)
+{
+ GLint i;
+
+ glBegin(GL_POINTS);
+ SetColor(COLOR_WHITE);
+ glVertex2i(0, 0);
+ for (i = 1; i < 8; i++) {
+ GLint j = i * 2;
+ SetColor(COLOR_BLACK+i);
+ glVertex2i(-j, -j);
+ glVertex2i(-j, 0);
+ glVertex2i(-j, j);
+ glVertex2i(0, j);
+ glVertex2i(j, j);
+ glVertex2i(j, 0);
+ glVertex2i(j, -j);
+ glVertex2i(0, -j);
+ }
+ glEnd();
+}
+
+static void Lines(void)
+{
+ GLint i;
+
+ glPushMatrix();
+
+ glTranslatef(-12, 0, 0);
+ for (i = 1; i < 8; i++) {
+ SetColor(COLOR_BLACK+i);
+ glBegin(GL_LINES);
+ glVertex2i(-boxW/4, -boxH/4);
+ glVertex2i(boxW/4, boxH/4);
+ glEnd();
+ glTranslatef(4, 0, 0);
+ }
+
+ glPopMatrix();
+
+ glBegin(GL_LINES);
+ glVertex2i(0, 0);
+ glEnd();
+}
+
+static void LineStrip(void)
+{
+
+ glBegin(GL_LINE_STRIP);
+ SetColor(COLOR_RED);
+ glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4));
+ SetColor(COLOR_GREEN);
+ glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4));
+ SetColor(COLOR_BLUE);
+ glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4));
+ SetColor(COLOR_WHITE);
+ glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4));
+ glEnd();
+
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(0, 0);
+ glEnd();
+}
+
+static void LineLoop(void)
+{
+
+ glBegin(GL_LINE_LOOP);
+ SetColor(COLOR_RED);
+ glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4));
+ SetColor(COLOR_GREEN);
+ glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4));
+ SetColor(COLOR_BLUE);
+ glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4));
+ SetColor(COLOR_WHITE);
+ glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4));
+ glEnd();
+
+ glEnable(GL_LOGIC_OP);
+ glLogicOp(GL_XOR);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE);
+
+ SetColor(COLOR_MAGENTA);
+ glBegin(GL_LINE_LOOP);
+ glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(-boxH/8));
+ glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8));
+ glEnd();
+ glBegin(GL_LINE_LOOP);
+ glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8+5));
+ glVertex2f(PIXEL_CENTER(boxW/8), PIXEL_CENTER(boxH/8+5));
+ glEnd();
+ glDisable(GL_LOGIC_OP);
+ glDisable(GL_BLEND);
+
+ SetColor(COLOR_GREEN);
+ glBegin(GL_POINTS);
+ glVertex2i(0, 0);
+ glEnd();
+
+ glBegin(GL_LINE_LOOP);
+ glVertex2i(0, 0);
+ glEnd();
+}
+
+static void Bitmap(void)
+{
+
+ glBegin(GL_LINES);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/2, 0);
+ glVertex2i(boxW/2, 0);
+ glVertex2i(0, -boxH/2);
+ glVertex2i(0, boxH/2);
+ SetColor(COLOR_RED);
+ glVertex2i(0, -3);
+ glVertex2i(0, -3+OPENGL_HEIGHT);
+ SetColor(COLOR_BLUE);
+ glVertex2i(0, -3);
+ glVertex2i(OPENGL_WIDTH, -3);
+ glEnd();
+
+ SetColor(COLOR_GREEN);
+
+ glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glRasterPos2i(0, 0);
+ glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, 0, 3, 0.0, 0.0, OpenGL_bits);
+}
+
+static void Triangles(void)
+{
+
+ glBegin(GL_TRIANGLES);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, -boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/8, -boxH/16);
+ SetColor(COLOR_BLUE);
+ glVertex2i(boxW/8, -boxH/16);
+
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/8, boxH/16);
+ SetColor(COLOR_BLUE);
+ glVertex2i(boxW/8, boxH/16);
+ glEnd();
+
+ glBegin(GL_TRIANGLES);
+ glVertex2i(0, 0);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void TriangleStrip(void)
+{
+
+ glBegin(GL_TRIANGLE_STRIP);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, -boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/4, boxH/4);
+ SetColor(COLOR_BLUE);
+ glVertex2i(0, -boxH/4);
+ SetColor(COLOR_WHITE);
+ glVertex2i(0, boxH/4);
+ SetColor(COLOR_CYAN);
+ glVertex2i(boxW/4, -boxH/4);
+ SetColor(COLOR_YELLOW);
+ glVertex2i(boxW/4, boxH/4);
+ glEnd();
+
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2i(0, 0);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void TriangleFan(void)
+{
+ GLint vx[8][2];
+ GLint x0, y0, x1, y1, x2, y2, x3, y3;
+ GLint i;
+
+ y0 = -boxH/4;
+ y1 = y0 + boxH/2/3;
+ y2 = y1 + boxH/2/3;
+ y3 = boxH/4;
+ x0 = -boxW/4;
+ x1 = x0 + boxW/2/3;
+ x2 = x1 + boxW/2/3;
+ x3 = boxW/4;
+
+ vx[0][0] = x0; vx[0][1] = y1;
+ vx[1][0] = x0; vx[1][1] = y2;
+ vx[2][0] = x1; vx[2][1] = y3;
+ vx[3][0] = x2; vx[3][1] = y3;
+ vx[4][0] = x3; vx[4][1] = y2;
+ vx[5][0] = x3; vx[5][1] = y1;
+ vx[6][0] = x2; vx[6][1] = y0;
+ vx[7][0] = x1; vx[7][1] = y0;
+
+ glBegin(GL_TRIANGLE_FAN);
+ SetColor(COLOR_WHITE);
+ glVertex2i(0, 0);
+ for (i = 0; i < 8; i++) {
+ SetColor(COLOR_WHITE-i);
+ glVertex2iv(vx[i]);
+ }
+ glEnd();
+
+ glBegin(GL_TRIANGLE_FAN);
+ glVertex2i(0, 0);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void Rect(void)
+{
+
+ SetColor(COLOR_GREEN);
+ glRecti(-boxW/4, -boxH/4, boxW/4, boxH/4);
+}
+
+static void PolygonFunc(void)
+{
+ GLint vx[8][2];
+ GLint x0, y0, x1, y1, x2, y2, x3, y3;
+ GLint i;
+
+ y0 = -boxH/4;
+ y1 = y0 + boxH/2/3;
+ y2 = y1 + boxH/2/3;
+ y3 = boxH/4;
+ x0 = -boxW/4;
+ x1 = x0 + boxW/2/3;
+ x2 = x1 + boxW/2/3;
+ x3 = boxW/4;
+
+ vx[0][0] = x0; vx[0][1] = y1;
+ vx[1][0] = x0; vx[1][1] = y2;
+ vx[2][0] = x1; vx[2][1] = y3;
+ vx[3][0] = x2; vx[3][1] = y3;
+ vx[4][0] = x3; vx[4][1] = y2;
+ vx[5][0] = x3; vx[5][1] = y1;
+ vx[6][0] = x2; vx[6][1] = y0;
+ vx[7][0] = x1; vx[7][1] = y0;
+
+ glBegin(GL_POLYGON);
+ for (i = 0; i < 8; i++) {
+ SetColor(COLOR_WHITE-i);
+ glVertex2iv(vx[i]);
+ }
+ glEnd();
+
+ glBegin(GL_POLYGON);
+ glVertex2i(0, 0);
+ glVertex2i(100, 100);
+ glEnd();
+}
+
+static void Quads(void)
+{
+
+ glBegin(GL_QUADS);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, -boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/8, -boxH/16);
+ SetColor(COLOR_BLUE);
+ glVertex2i(boxW/8, -boxH/16);
+ SetColor(COLOR_WHITE);
+ glVertex2i(boxW/4, -boxH/4);
+
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/8, boxH/16);
+ SetColor(COLOR_BLUE);
+ glVertex2i(boxW/8, boxH/16);
+ SetColor(COLOR_WHITE);
+ glVertex2i(boxW/4, boxH/4);
+ glEnd();
+
+ glBegin(GL_QUADS);
+ glVertex2i(0, 0);
+ glVertex2i(100, 100);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void QuadStrip(void)
+{
+
+ glBegin(GL_QUAD_STRIP);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, -boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/4, boxH/4);
+ SetColor(COLOR_BLUE);
+ glVertex2i(0, -boxH/4);
+ SetColor(COLOR_WHITE);
+ glVertex2i(0, boxH/4);
+ SetColor(COLOR_CYAN);
+ glVertex2i(boxW/4, -boxH/4);
+ SetColor(COLOR_YELLOW);
+ glVertex2i(boxW/4, boxH/4);
+ glEnd();
+
+ glBegin(GL_QUAD_STRIP);
+ glVertex2i(0, 0);
+ glVertex2i(100, 100);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void Draw(EGLDisplay dpy, EGLSurface surf)
+{
+
+ glViewport(0, 0, windW, windH);
+ glDisable(GL_SCISSOR_TEST);
+
+ glPushAttrib(GL_COLOR_BUFFER_BIT);
+
+ glColorMask(1, 1, 1, 1);
+ glIndexMask(~0);
+
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glPopAttrib();
+
+ if (mode1) {
+ glShadeModel(GL_SMOOTH);
+ } else {
+ glShadeModel(GL_FLAT);
+ }
+
+ if (mode2) {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ } else {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ }
+
+ Viewport(0, 0); Point();
+ Viewport(0, 1); Lines();
+ Viewport(0, 2); LineStrip();
+ Viewport(0, 3); LineLoop();
+
+ Viewport(1, 0); Bitmap();
+
+ Viewport(1, 1); TriangleFan();
+ Viewport(1, 2); Triangles();
+ Viewport(1, 3); TriangleStrip();
+
+ Viewport(2, 0); Rect();
+ Viewport(2, 1); PolygonFunc();
+ Viewport(2, 2); Quads();
+ Viewport(2, 3); QuadStrip();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ eglSwapBuffers(dpy, surf);
+ }
+}
+
+static void
+write_ppm(const char *filename, const GLubyte *buffer, int width, int height)
+{
+ const int binary = 0;
+ FILE *f = fopen( filename, "w" );
+ if (f) {
+ int i, x, y;
+ const GLubyte *ptr = buffer;
+ if (binary) {
+ fprintf(f,"P6\n");
+ fprintf(f,"# ppm-file created by osdemo.c\n");
+ fprintf(f,"%i %i\n", width,height);
+ fprintf(f,"255\n");
+ fclose(f);
+ f = fopen( filename, "ab" ); /* reopen in binary append mode */
+ for (y=height-1; y>=0; y--) {
+ for (x=0; x<width; x++) {
+ i = (y*width + x) * 4;
+ fputc(ptr[i], f); /* write red */
+ fputc(ptr[i+1], f); /* write green */
+ fputc(ptr[i+2], f); /* write blue */
+ }
+ }
+ }
+ else {
+ /*ASCII*/
+ int counter = 0;
+ fprintf(f,"P3\n");
+ fprintf(f,"# ascii ppm file created by osdemo.c\n");
+ fprintf(f,"%i %i\n", width, height);
+ fprintf(f,"255\n");
+ for (y=height-1; y>=0; y--) {
+ for (x=0; x<width; x++) {
+ i = (y*width + x) * 4;
+ fprintf(f, " %3d %3d %3d", ptr[i], ptr[i+1], ptr[i+2]);
+ counter++;
+ if (counter % 5 == 0)
+ fprintf(f, "\n");
+ }
+ }
+ }
+ fclose(f);
+ }
+}
+
+#include "../src/egl/main/egldisplay.h"
+
+typedef struct fb_display
+{
+ _EGLDisplay Base; /* base class/object */
+ void *pFB;
+} fbDisplay;
+
+
+int
+main(int argc, char *argv[])
+{
+ int maj, min;
+ EGLContext ctx;
+ EGLSurface screen_surf;
+ EGLConfig configs[10];
+ EGLScreenMESA screen;
+ EGLModeMESA mode;
+ EGLint numConfigs, count;
+ EGLBoolean b;
+ const EGLint screenAttribs[] = {
+ EGL_WIDTH, 1024,
+ EGL_HEIGHT, 768,
+ EGL_NONE
+ };
+
+ /*
+ EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ */
+ EGLDisplay d = eglGetDisplay(":0");
+ 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);
+ eglGetScreensMESA(d, &screen, 1, &count);
+ eglGetModesMESA(d, screen, &mode, 1, &count);
+
+ ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
+ if (ctx == EGL_NO_CONTEXT) {
+ printf("failed to create context\n");
+ return 0;
+ }
+
+ screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
+ if (screen_surf == EGL_NO_SURFACE) {
+ printf("failed to create screen surface\n");
+ return 0;
+ }
+
+ eglShowSurfaceMESA(d, screen, screen_surf, mode);
+
+ b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
+ if (!b) {
+ printf("make current failed\n");
+ return 0;
+ }
+ glViewport(0, 0, 1024, 768);
+
+
+ Init();
+ Reshape(1024, 768);
+
+ glDrawBuffer( GL_FRONT );
+ glClearColor( 0, 1.0, 0, 1);
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ doubleBuffer = 1;
+ glDrawBuffer( GL_BACK );
+
+ Draw(d, screen_surf);
+
+ write_ppm("dump.ppm", ((struct fb_display *)_eglLookupDisplay(d))->pFB, 1024, 768);
+
+ eglDestroySurface(d, screen_surf);
+ eglDestroyContext(d, ctx);
+ eglTerminate(d);
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/egl/eglgears.c b/nx-X11/extras/Mesa_6.4.2/progs/egl/eglgears.c
new file mode 100644
index 000000000..0c3da565f
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/egl/eglgears.c
@@ -0,0 +1,448 @@
+/*
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * This is a port of the infamous "glxgears" demo to straight EGL
+ * Port by Dane Rushton 10 July 2005
+ *
+ * No command line options.
+ * Program runs for 5 seconds then exits, outputing framerate to console
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <GL/gl.h>
+#include <GLES/egl.h>
+#include <assert.h>
+
+
+#define BENCHMARK
+
+#ifdef BENCHMARK
+
+/* XXX this probably isn't very portable */
+
+#include <sys/time.h>
+#include <unistd.h>
+
+/* return current time (in seconds) */
+static double
+current_time(void)
+{
+ struct timeval tv;
+#ifdef __VMS
+ (void) gettimeofday(&tv, NULL );
+#else
+ struct timezone tz;
+ (void) gettimeofday(&tv, &tz);
+#endif
+ return (double) tv.tv_sec + tv.tv_usec / 1000000.0;
+}
+
+#else /*BENCHMARK*/
+
+/* dummy */
+static double
+current_time(void)
+{
+ /* update this function for other platforms! */
+ static double t = 0.0;
+ static int warn = 1;
+ if (warn) {
+ fprintf(stderr, "Warning: current_time() not implemented!!\n");
+ warn = 0;
+ }
+ return t += 1.0;
+}
+
+#endif /*BENCHMARK*/
+
+
+#ifndef M_PI
+#define M_PI 3.14159265
+#endif
+
+
+static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
+static GLint gear1, gear2, gear3;
+static GLfloat angle = 0.0;
+
+//static GLfloat eyesep = 5.0; /* Eye separation. */
+//static GLfloat fix_point = 40.0; /* Fixation point distance. */
+//static GLfloat left, right, asp; /* Stereo frustum params. */
+
+
+/*
+ *
+ * Draw a gear wheel. You'll probably want to call this function when
+ * building a display list since we do a lot of trig here.
+ *
+ * Input: inner_radius - radius of hole at center
+ * outer_radius - radius at center of teeth
+ * width - width of gear
+ * teeth - number of teeth
+ * tooth_depth - depth of tooth
+ */
+static void
+gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
+ GLint teeth, GLfloat tooth_depth)
+{
+ GLint i;
+ GLfloat r0, r1, r2;
+ GLfloat angle, da;
+ GLfloat u, v, len;
+
+ r0 = inner_radius;
+ r1 = outer_radius - tooth_depth / 2.0;
+ r2 = outer_radius + tooth_depth / 2.0;
+
+ da = 2.0 * M_PI / teeth / 4.0;
+
+ glShadeModel(GL_FLAT);
+
+ glNormal3f(0.0, 0.0, 1.0);
+
+ /* draw front face */
+ glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++) {
+ angle = i * 2.0 * M_PI / teeth;
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
+ if (i < teeth) {
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+ width * 0.5);
+ }
+ }
+ glEnd();
+
+ /* draw front sides of teeth */
+ glBegin(GL_QUADS);
+ da = 2.0 * M_PI / teeth / 4.0;
+ for (i = 0; i < teeth; i++) {
+ angle = i * 2.0 * M_PI / teeth;
+
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
+ glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
+ width * 0.5);
+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+ width * 0.5);
+ }
+ glEnd();
+
+ glNormal3f(0.0, 0.0, -1.0);
+
+ /* draw back face */
+ glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++) {
+ angle = i * 2.0 * M_PI / teeth;
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
+ if (i < teeth) {
+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+ -width * 0.5);
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
+ }
+ }
+ glEnd();
+
+ /* draw back sides of teeth */
+ glBegin(GL_QUADS);
+ da = 2.0 * M_PI / teeth / 4.0;
+ for (i = 0; i < teeth; i++) {
+ angle = i * 2.0 * M_PI / teeth;
+
+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+ -width * 0.5);
+ glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
+ -width * 0.5);
+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
+ }
+ glEnd();
+
+ /* draw outward faces of teeth */
+ glBegin(GL_QUAD_STRIP);
+ for (i = 0; i < teeth; i++) {
+ angle = i * 2.0 * M_PI / teeth;
+
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
+ u = r2 * cos(angle + da) - r1 * cos(angle);
+ v = r2 * sin(angle + da) - r1 * sin(angle);
+ len = sqrt(u * u + v * v);
+ u /= len;
+ v /= len;
+ glNormal3f(v, -u, 0.0);
+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
+ glNormal3f(cos(angle), sin(angle), 0.0);
+ glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
+ width * 0.5);
+ glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
+ -width * 0.5);
+ u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
+ v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
+ glNormal3f(v, -u, 0.0);
+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+ width * 0.5);
+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+ -width * 0.5);
+ glNormal3f(cos(angle), sin(angle), 0.0);
+ }
+
+ glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
+ glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
+
+ glEnd();
+
+ glShadeModel(GL_SMOOTH);
+
+ /* draw inside radius cylinder */
+ glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++) {
+ angle = i * 2.0 * M_PI / teeth;
+ glNormal3f(-cos(angle), -sin(angle), 0.0);
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
+ }
+ glEnd();
+}
+
+
+static void
+draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glPushMatrix();
+ glRotatef(view_rotx, 1.0, 0.0, 0.0);
+ glRotatef(view_roty, 0.0, 1.0, 0.0);
+ glRotatef(view_rotz, 0.0, 0.0, 1.0);
+
+ glPushMatrix();
+ glTranslatef(-3.0, -2.0, 0.0);
+ glRotatef(angle, 0.0, 0.0, 1.0);
+ glCallList(gear1);
+ glPopMatrix();
+
+ glPushMatrix();
+ glTranslatef(3.1, -2.0, 0.0);
+ glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
+ glCallList(gear2);
+ glPopMatrix();
+
+ glPushMatrix();
+ glTranslatef(-3.1, 4.2, 0.0);
+ glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
+ glCallList(gear3);
+ glPopMatrix();
+
+ glPopMatrix();
+}
+
+
+/* new window size or exposure */
+static void
+reshape(int width, int height)
+{
+ glViewport(0, 0, (GLint) width, (GLint) height);
+
+ GLfloat h = (GLfloat) height / (GLfloat) width;
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -40.0);
+}
+
+
+
+static void
+init(void)
+{
+ static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
+ static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
+ static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
+ static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
+
+ glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_DEPTH_TEST);
+
+ /* make the gears */
+ gear1 = glGenLists(1);
+ glNewList(gear1, GL_COMPILE);
+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
+ gear(1.0, 4.0, 1.0, 20, 0.7);
+ glEndList();
+
+ gear2 = glGenLists(1);
+ glNewList(gear2, GL_COMPILE);
+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
+ gear(0.5, 2.0, 2.0, 10, 0.7);
+ glEndList();
+
+ gear3 = glGenLists(1);
+ glNewList(gear3, GL_COMPILE);
+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
+ gear(1.3, 2.0, 0.5, 10, 0.7);
+ glEndList();
+
+ glEnable(GL_NORMALIZE);
+}
+
+
+
+
+static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
+{
+ double st = current_time();
+ double ct = st;
+ int frames = 0;
+ while (ct - st < ttr)
+ {
+ double tt = current_time();
+ double dt = tt - ct;
+ ct = tt;
+
+ /* advance rotation for next frame */
+ angle += 70.0 * dt; /* 70 degrees per second */
+ if (angle > 3600.0)
+ angle -= 3600.0;
+
+ draw();
+
+ // DBR : Swap the Buffers
+ eglSwapBuffers(dpy, surf);
+
+
+ frames++;
+ }
+
+ GLfloat seconds = ct - st;
+ GLfloat fps = frames / seconds;
+ printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
+
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ int maj, min;
+ EGLContext ctx;
+ EGLSurface screen_surf;
+ EGLConfig configs[10];
+ EGLint numConfigs, i;
+ EGLBoolean b;
+
+ const EGLint screenAttribs[] = {
+ EGL_WIDTH, 1024,
+ EGL_HEIGHT, 768,
+ EGL_NONE
+ };
+
+ EGLModeMESA mode;
+ EGLScreenMESA screen;
+ EGLint count;
+ GLboolean printInfo = GL_FALSE;
+
+ for (i = 1; i < argc; i++)
+ {
+ if (strcmp(argv[i], "-info") == 0)
+ {
+ printInfo = GL_TRUE;
+ }
+ else
+ printf("Warning: unknown parameter: %s\n", argv[i]);
+ }
+
+ // DBR : Create EGL context/surface etc
+ EGLDisplay d = eglGetDisplay(":0");
+ 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);
+ eglGetScreensMESA(d, &screen, 1, &count);
+ eglGetModesMESA(d, screen, &mode, 1, &count);
+
+ ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
+ if (ctx == EGL_NO_CONTEXT) {
+ printf("failed to create context\n");
+ return 0;
+ }
+
+ screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
+ if (screen_surf == EGL_NO_SURFACE) {
+ printf("failed to create screen surface\n");
+ return 0;
+ }
+
+ eglShowSurfaceMESA(d, screen, screen_surf, mode);
+
+ b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
+ if (!b) {
+ printf("make current failed\n");
+ return 0;
+ }
+ // DBR
+
+ if (printInfo)
+ {
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+ printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
+ }
+
+ init(); // Initialise the GL visual
+ reshape(1024,768);
+
+ glDrawBuffer( GL_BACK );
+
+ // DBR : Run the simulation
+ run_gears(d, screen_surf, 5.0);
+
+
+ // DBR : Destroy EGL context/surface etc
+ eglDestroySurface(d, screen_surf);
+ eglDestroyContext(d, ctx);
+ eglTerminate(d);
+ // DBR
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/egl/eglinfo.c b/nx-X11/extras/Mesa_6.4.2/progs/egl/eglinfo.c
new file mode 100644
index 000000000..4826fd094
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/egl/eglinfo.c
@@ -0,0 +1,162 @@
+/*
+ * 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
+#define MAX_SCREENS 10
+
+
+/**
+ * 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(extensions, "EGL_MESA_screen_surface")) {
+ EGLScreenMESA screens[MAX_SCREENS];
+ EGLint numScreens = 1, scrn;
+ EGLModeMESA modes[MAX_MODES];
+
+ eglGetScreensMESA(d, screens, MAX_SCREENS, &numScreens);
+ printf("Number of Screens: %d\n\n", numScreens);
+
+ for (scrn = 0; scrn < numScreens; scrn++) {
+ EGLint numModes, i;
+
+ eglGetModesMESA(d, screens[scrn], modes, MAX_MODES, &numModes);
+
+ printf("Screen %d Modes:\n", scrn);
+ printf(" id width height refresh name\n");
+ printf("-----------------------------------------\n");
+ for (i = 0; i < numModes; i++) {
+ EGLint id, w, h, r;
+ const char *str;
+ 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);
+ str = eglQueryModeStringMESA(d, modes[i]);
+ printf("0x%02x %5d %5d %.3f %s\n", id, w, h, r / 1000.0, str);
+ }
+ }
+ }
+#endif
+}
+
+
+
+int
+main(int argc, char *argv[])
+{
+ int maj, min;
+ /*EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);*/
+ EGLDisplay d = eglGetDisplay("!r200_dri");
+
+ 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;
+}