aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/Mesa_6.4.2/progs/tests
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/extras/Mesa_6.4.2/progs/tests')
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/.cvsignore2
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/Makefile135
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/Makefile.win44
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/antialias.c229
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/api_speed.c146
-rwxr-xr-xnx-X11/extras/Mesa_6.4.2/progs/tests/api_speed.py143
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/arbfpspec.c194
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptest1.c210
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptexture.c153
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptrig.c156
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/arbnpot.c174
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptest1.c164
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptest3.c128
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptorus.c191
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/arbvpwarpmesh.c246
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/auxbuffer.c499
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/blendminmax.c209
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/blendsquare.c178
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/bufferobj.c359
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/bug_3101.c128
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/bug_3195.c275
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/crossbar.c235
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/cva.c164
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/debugger.c733
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/descrip.mms84
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/dinoshade.c914
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/ext422square.c258
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/fbotest1.c190
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/fbotexture.c288
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/floattex.c169
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/fogcoord.c102
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/fptest1.c220
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/fptexture.c151
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/getprocaddress.c438
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/getprocaddress.py93
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/invert.c195
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/jkrahntest.c177
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/manytex.c381
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/multipal.c377
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/multitexarray.c238
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/multiwindow.c169
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/no_s3tc.c97
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/packedpixels.c299
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/pbo.c283
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/projtex.c1028
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/seccolor.c145
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/sharedtex.c438
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/stencil_wrap.c257
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/stencilwrap.c281
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/tex1d.c139
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/texcmp.c414
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/texgenmix.c640
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/texline.c269
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/texobjshare.c219
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/texrect.c360
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/texwrap.c303
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/vparray.c294
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/vpeval.c231
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/vptest1.c170
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/vptest2.c151
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/vptest3.c120
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/vptorus.c174
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/vpwarpmesh.c236
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/yuvrect.c193
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/yuvsquare.c232
-rw-r--r--nx-X11/extras/Mesa_6.4.2/progs/tests/zreaddraw.c116
66 files changed, 16628 insertions, 0 deletions
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/.cvsignore b/nx-X11/extras/Mesa_6.4.2/progs/tests/.cvsignore
new file mode 100644
index 000000000..d0f2a87a8
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/.cvsignore
@@ -0,0 +1,2 @@
+.cvsignore
+getproclist.h
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/Makefile b/nx-X11/extras/Mesa_6.4.2/progs/tests/Makefile
new file mode 100644
index 000000000..768820cf3
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/Makefile
@@ -0,0 +1,135 @@
+# progs/tests/Makefile
+
+
+# These programs aren't intended to be included with the normal distro.
+# They're not too interesting but they're good for testing.
+
+TOP = ../..
+include $(TOP)/configs/current
+
+
+LIBS = $(APP_LIB_DEPS)
+
+SOURCES = antialias.c \
+ arbfpspec.c \
+ arbfptest1.c \
+ arbfptexture.c \
+ arbfptrig.c \
+ arbvptest1.c \
+ arbvptest3.c \
+ arbvptorus.c \
+ arbvpwarpmesh.c \
+ blendminmax.c \
+ blendsquare.c \
+ bufferobj.c \
+ bug_3101.c \
+ bug_3195.c \
+ crossbar.c \
+ cva.c \
+ dinoshade.c \
+ floattex.c \
+ fbotest1.c \
+ fbotexture.c \
+ fogcoord.c \
+ fptest1.c \
+ fptexture.c \
+ getprocaddress.c \
+ invert.c \
+ manytex.c \
+ multipal.c \
+ no_s3tc.c \
+ packedpixels.c \
+ pbo.c \
+ projtex.c \
+ seccolor.c \
+ sharedtex.c \
+ stencilwrap.c \
+ stencil_wrap.c \
+ tex1d.c \
+ texline.c \
+ texobjshare.c \
+ texrect.c \
+ texwrap.c \
+ vparray.c \
+ vptest1.c \
+ vptest2.c \
+ vptest3.c \
+ vptorus.c \
+ vpwarpmesh.c \
+ yuvrect.c \
+ yuvsquare.c \
+ zreaddraw.c
+
+PROGS = $(SOURCES:%.c=%)
+
+INCLUDES = -I. -I$(TOP)/include
+
+UTIL_FILES = readtex.h readtex.c
+
+
+##### RULES #####
+
+.SUFFIXES:
+.SUFFIXES: .c
+
+.c:
+ $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
+
+.c.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+.S.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+
+##### TARGETS #####
+
+default: $(UTIL_FILES) $(PROGS)
+
+clean:
+ rm -f $(PROGS)
+ rm -f *.o
+ rm -f getproclist.h
+
+
+# auto code generation
+getprocaddress: getprocaddress.c getproclist.h
+
+getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.py
+ python getprocaddress.py > getproclist.h
+
+
+texrect: texrect.o readtex.o
+ $(CC) texrect.o readtex.o $(LIBS) -o $@
+
+texrect.o: texrect.c readtex.h
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+bug_3195: bug_3195.o readtex.o
+ $(CC) $(CFLAGS) bug_3195.o readtex.o $(LIBS) -o $@
+
+bug_3195.o: bug_3195.c readtex.h
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+invert: invert.o readtex.o
+ $(CC) invert.o readtex.o $(LIBS) -o $@
+
+invert.o: invert.c readtex.h
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+readtex.o: readtex.c
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+
+readtex.h: $(TOP)/progs/util/readtex.h
+ ln -s $(TOP)/progs/util/readtex.h .
+
+readtex.c: $(TOP)/progs/util/readtex.c
+ ln -s $(TOP)/progs/util/readtex.c .
+
+
+
+
+# Emacs tags
+tags:
+ etags `find . -name \*.[ch]` `find ../include`
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/Makefile.win b/nx-X11/extras/Mesa_6.4.2/progs/tests/Makefile.win
new file mode 100644
index 000000000..0de6c42e3
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/Makefile.win
@@ -0,0 +1,44 @@
+# $Id: Makefile.win,v 1.1 2002/01/16 01:03:25 kschultz Exp $
+
+# Mesa 3-D graphics library
+# Version: 3.5
+# Copyright (C) 1995-2001 Brian Paul
+
+# Makefile for GLUT-based demo programs for Windows
+
+!include <win32.mak>
+
+##### MACROS #####
+
+TOP = ..
+INCDIR = ..\include
+LIBDIR = ..\lib
+
+SRCS = cva.c \
+ dinoshade.c \
+ fogcoord.c \
+ manytex.c \
+ multipal.c \
+ projtex.c \
+ seccolor.c \
+# sharedtex.c \
+ texline.c \
+ texwrap.c \
+ vptest1.c \
+ vptest2.c \
+ vptest3.c \
+ vptorus.c \
+ vpwarpmesh.c
+
+!include "../mesawin32.mak"
+
+##### TARGETS #####
+
+clean::
+
+clobber::
+ @del readtex.c readtex.h
+
+$(EXES) :$*.obj
+ @echo $@
+ $(link) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS)
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/antialias.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/antialias.c
new file mode 100644
index 000000000..79b5ab75c
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/antialias.c
@@ -0,0 +1,229 @@
+/* $Id: antialias.c,v 1.2 2003/03/29 16:42:57 brianp Exp $ */
+
+/*
+ * Test multisampling and polygon smoothing.
+ *
+ * Brian Paul
+ * 4 November 2002
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+static GLfloat Zrot = 0;
+static GLboolean Anim = GL_TRUE;
+static GLboolean HaveMultisample = GL_TRUE;
+
+
+static void
+PrintString(const char *s)
+{
+ while (*s) {
+ glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
+ s++;
+ }
+}
+
+
+static void
+Polygon( GLint verts, GLfloat radius, GLfloat z )
+{
+ int i;
+ for (i = 0; i < verts; i++) {
+ float a = (i * 2.0 * 3.14159) / verts;
+ float x = radius * cos(a);
+ float y = radius * sin(a);
+ glVertex3f(x, y, z);
+ }
+}
+
+
+static void
+DrawObject( void )
+{
+ glLineWidth(3.0);
+ glColor3f(1, 1, 1);
+ glBegin(GL_LINE_LOOP);
+ Polygon(12, 1.2, 0);
+ glEnd();
+
+ glLineWidth(1.0);
+ glColor3f(1, 1, 1);
+ glBegin(GL_LINE_LOOP);
+ Polygon(12, 1.1, 0);
+ glEnd();
+
+ glColor3f(1, 0, 0);
+ glBegin(GL_POLYGON);
+ Polygon(12, 0.4, 0.3);
+ glEnd();
+
+ glColor3f(0, 1, 0);
+ glBegin(GL_POLYGON);
+ Polygon(12, 0.6, 0.2);
+ glEnd();
+
+ glColor3f(0, 0, 1);
+ glBegin(GL_POLYGON);
+ Polygon(12, 0.8, 0.1);
+ glEnd();
+
+ glColor3f(1, 1, 1);
+ glBegin(GL_POLYGON);
+ Polygon(12, 1.0, 0);
+ glEnd();
+}
+
+
+static void
+Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glColor3f(1, 1, 1);
+ if (HaveMultisample) {
+ glRasterPos2f(-3.1, -1.6);
+ PrintString("MULTISAMPLE");
+ }
+ glRasterPos2f(-0.8, -1.6);
+ PrintString("No antialiasing");
+ glRasterPos2f(1.6, -1.6);
+ PrintString("GL_POLYGON_SMOOTH");
+
+ /* multisample */
+ if (HaveMultisample) {
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_MULTISAMPLE_ARB);
+ glPushMatrix();
+ glTranslatef(-2.5, 0, 0);
+ glPushMatrix();
+ glRotatef(Zrot, 0, 0, 1);
+ DrawObject();
+ glPopMatrix();
+ glPopMatrix();
+ glDisable(GL_MULTISAMPLE_ARB);
+ glDisable(GL_DEPTH_TEST);
+ }
+
+ /* non-aa */
+ glEnable(GL_DEPTH_TEST);
+ glPushMatrix();
+ glTranslatef(0, 0, 0);
+ glPushMatrix();
+ glRotatef(Zrot, 0, 0, 1);
+ DrawObject();
+ glPopMatrix();
+ glPopMatrix();
+ glDisable(GL_DEPTH_TEST);
+
+ /* polygon smooth */
+ glEnable(GL_POLYGON_SMOOTH);
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
+ glPushMatrix();
+ glTranslatef(2.5, 0, 0);
+ glPushMatrix();
+ glRotatef(Zrot, 0, 0, 1);
+ DrawObject();
+ glPopMatrix();
+ glPopMatrix();
+ glDisable(GL_LINE_SMOOTH);
+ glDisable(GL_POLYGON_SMOOTH);
+ glDisable(GL_BLEND);
+
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(-2.0*ar, 2.0*ar, -2.0, 2.0, -1.0, 1.0);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+}
+
+
+static void
+Idle( void )
+{
+ Zrot = 0.01 * glutGet(GLUT_ELAPSED_TIME);
+ glutPostRedisplay();
+}
+
+
+static void
+Key( unsigned char key, int x, int y )
+{
+ const GLfloat step = 1.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'z':
+ Zrot = (int) (Zrot - step);
+ break;
+ case 'Z':
+ Zrot = (int) (Zrot + step);
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init( void )
+{
+ /* GLUT imposes the four samples/pixel requirement */
+ int s;
+ glGetIntegerv(GL_SAMPLES_ARB, &s);
+ if (!glutExtensionSupported("GL_ARB_multisample") || s < 1) {
+ printf("Warning: multisample antialiasing not supported.\n");
+ HaveMultisample = GL_FALSE;
+ }
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_SAMPLES_ARB = %d\n", s);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE);
+
+ glGetIntegerv(GL_MULTISAMPLE_ARB, &s);
+ printf("GL_MULTISAMPLE_ARB = %d\n", s);
+}
+
+
+int
+main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 600, 300 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE |
+ GLUT_DEPTH | GLUT_MULTISAMPLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc( Idle );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/api_speed.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/api_speed.c
new file mode 100644
index 000000000..aed65b35f
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/api_speed.c
@@ -0,0 +1,146 @@
+/*
+ * (C) Copyright IBM Corporation 2002
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 (including the next
+ * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+/**
+ * \file api_speed.c
+ * Simple test to measure the overhead of making GL calls.
+ *
+ * The main purpose of this test is to measure the difference in calling
+ * overhead of different dispatch methods. Since it uses asm/timex.h to
+ * access the Pentium's cycle counters, it will probably only compile on
+ * Linux (though most architectures have a get_cycles function in timex.h).
+ * That is why it isn't in the default Makefile.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+#include <GL/glext.h>
+#include <GL/glut.h>
+
+#define inline __inline__
+#include <asm/timex.h>
+
+static float Width = 400;
+static float Height = 400;
+static unsigned count = 1000000;
+
+
+static void Idle( void )
+{
+ glutPostRedisplay();
+}
+
+#define DO_FUNC(f,p) \
+ do { \
+ t0 = get_cycles(); \
+ for ( i = 0 ; i < count ; i++ ) { \
+ f p ; \
+ } \
+ t1 = get_cycles(); \
+ printf("%u calls to % 20s required %llu cycles.\n", count, # f, t1 - t0); \
+ } while( 0 )
+
+/**
+ * Main display function. This is the place to add more API calls.
+ */
+static void Display( void )
+{
+ int i;
+ const float v[3] = { 1.0, 0.0, 0.0 };
+ cycles_t t0;
+ cycles_t t1;
+
+ glBegin(GL_TRIANGLE_STRIP);
+
+ DO_FUNC( glColor3fv, (v) );
+ DO_FUNC( glNormal3fv, (v) );
+ DO_FUNC( glTexCoord2fv, (v) );
+ DO_FUNC( glTexCoord3fv, (v) );
+ DO_FUNC( glMultiTexCoord2fv, (GL_TEXTURE0, v) );
+ DO_FUNC( glMultiTexCoord2f, (GL_TEXTURE0, 0.0, 0.0) );
+ DO_FUNC( glFogCoordfvEXT, (v) );
+ DO_FUNC( glFogCoordfEXT, (0.5) );
+
+ glEnd();
+
+ exit(0);
+}
+
+
+static void Reshape( int width, int height )
+{
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(0.0, width, 0.0, height, -1.0, 1.0);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowSize( (int) Width, (int) Height );
+ glutInitWindowPosition( 0, 0 );
+
+ glutInitDisplayMode( GLUT_RGB );
+
+ glutCreateWindow( argv[0] );
+
+ if ( argc > 1 ) {
+ count = strtoul( argv[1], NULL, 0 );
+ if ( count == 0 ) {
+ fprintf( stderr, "Usage: %s [iterations]\n", argv[0] );
+ exit(1);
+ }
+ }
+
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ glutIdleFunc( Idle );
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/api_speed.py b/nx-X11/extras/Mesa_6.4.2/progs/tests/api_speed.py
new file mode 100755
index 000000000..0ddaf5836
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/api_speed.py
@@ -0,0 +1,143 @@
+#!/usr/bin/env python2
+
+# (C) Copyright IBM Corporation 2004
+# 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
+# on the rights to use, copy, modify, merge, publish, distribute, sub
+# license, 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 (including the next
+# paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+# IBM AND/OR ITS SUPPLIERS 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:
+# Ian Romanick <idr@us.ibm.com>
+
+
+# This script is used to run api_speed against several different libGL
+# libraries and compare the results. See the show_usage function for more
+# details on how to use it.
+
+
+import re, os, sys, getopt
+
+class results:
+ def process_file(self, f):
+ self.cycles = {}
+ self.iterations = -1
+
+ for line in f.readlines():
+ m = re.match("(\d+) calls to (.{20}) required (\d+) cycles.", line)
+
+ if self.iterations != -1 and int(m.group(1)) != self.iterations:
+ raise
+
+ # This could be done with lstrip, but the version of
+ # the Python library on my system doesn't have it.
+ # The installed version of Python is quite old. :(
+
+ temp = m.group(2)
+ function_name = None
+ for i in range(len(temp)):
+ if temp[i] != ' ':
+ function_name = temp[i:]
+ break
+
+ if function_name == None:
+ raise
+
+ self.cycles[ function_name ] = int(m.group(3))
+ self.iterations = int(m.group(1))
+
+
+ def show_results(self):
+ for name in self.cycles:
+ print "%s -> %f" % (name, float(self.cycles[name]) / self.iterations)
+
+
+ def compare_results(self, other):
+ for name in self.cycles:
+ if other.cycles.has_key(name):
+ a = float(self.cycles[name]) / float(self.iterations)
+ b = float(other.cycles[name]) / float(other.iterations)
+ if abs( a ) < 0.000001:
+ print "a = %f, b = %f" % (a, b)
+ else:
+ p = (100.0 * b / a) - 100.0
+ print "%- 20s %7.2f - %7.2f = % -6.2f (%+.1f%%)" % (name, a, b, a - b, p)
+ return
+
+
+def make_execution_string(lib, iterations):
+ if lib == None:
+ return "./api_speed %u" % (iterations)
+ else:
+ return "LD_PRELOAD=%s ./api_speed %u" % (lib, iterations)
+
+
+def show_usage():
+ print """Usage: %s [-i iterations] {library ...}
+
+The full path to one or more libGL libraries (including the full name of the
+library) can be included on the command-line. Each library will be tested,
+and the results compared. The first library listed will be used as the
+"base line" for all comparisons.""" % (sys.argv[0])
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "i:")
+ except Exception,e:
+ show_usage()
+
+ iterations = 1000000
+ try:
+ for (arg,val) in args:
+ if arg == "-i":
+ iterations = int(val)
+ except Exception,e:
+ show_usage()
+
+
+ # If no libraries were specifically named, just run the test against
+ # the default system libGL.
+
+ if len(trail) == 0:
+ trail.append(None)
+
+
+ result_array = []
+ names = []
+
+ for lib in trail:
+ s = make_execution_string( lib, iterations )
+ r = results()
+ r.process_file( os.popen(s) )
+ names.append(lib)
+ result_array.append(r)
+
+
+ # If the test was only run against one library, just show the results
+ # of the test run. Otherwise, compare each successive run against
+ # the first run.
+
+ if len( result_array ) == 1:
+ result_array[0].show_results()
+ else:
+ for i in range(1, len( result_array )):
+ print "%s vs. %s" % (names[0], names[i])
+ result_array[0].compare_results( result_array[i] )
+ print ""
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfpspec.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfpspec.c
new file mode 100644
index 000000000..73c55369e
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfpspec.c
@@ -0,0 +1,194 @@
+/*
+ * To demo that specular color gets lost someplace after vertex
+ * program completion and fragment program startup
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static float Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
+static GLboolean Anim = GL_TRUE;
+
+
+static void Idle( void )
+{
+ Xrot += .3;
+ Yrot += .4;
+ Zrot += .2;
+ glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+ glutSolidTorus(0.75, 2.0, 10, 20);
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -12.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case ' ':
+ Xrot = Yrot = Zrot = 0;
+ break;
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'z':
+ Zrot -= 5.0;
+ break;
+ case 'Z':
+ Zrot += 5.0;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum, fprognum;
+
+ static const char prog[] =
+ "!!ARBvp1.0\n"
+ "DP4 result.position.x, state.matrix.mvp.row[0], vertex.position ;\n"
+ "DP4 result.position.y, state.matrix.mvp.row[1], vertex.position ;\n"
+ "DP4 result.position.z, state.matrix.mvp.row[2], vertex.position ;\n"
+ "DP4 result.position.w, state.matrix.mvp.row[3], vertex.position ;\n"
+ "MOV result.color.front.primary, {.5, .5, .5, 1};\n"
+ "MOV result.color.front.secondary, {1, 1, 1, 1};\n"
+ "END";
+
+ static const char fprog[] =
+ "!!ARBfp1.0\n"
+ "MOV result.color, fragment.color.secondary;\n"
+ "END";
+
+ if (!glutExtensionSupported("GL_ARB_vertex_program")) {
+ printf("Sorry, this program requires GL_ARB_vertex_program");
+ exit(1);
+ }
+
+ if (!glutExtensionSupported("GL_ARB_fragment_program")) {
+ printf("Sorry, this program requires GL_ARB_fragment_program");
+ exit(1);
+ }
+
+
+
+ glGenProgramsARB(1, &prognum);
+ glGenProgramsARB(1, &fprognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog), (const GLubyte *) prog);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fprognum);
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(fprog), (const GLubyte *) fprog);
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+
+ glEnable(GL_VERTEX_PROGRAM_ARB);
+ glEnable(GL_FRAGMENT_PROGRAM_ARB);
+ glEnable(GL_DEPTH_TEST);
+ glClearColor(0.3, 0.3, 0.3, 1);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptest1.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptest1.c
new file mode 100644
index 000000000..45d05125b
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptest1.c
@@ -0,0 +1,210 @@
+/* Test GL_ARB_fragment_program */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+
+ glColor4f(0, 0.5, 0, 1);
+ glColor4f(0, 1, 0, 1);
+ glBegin(GL_POLYGON);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 0, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+static void load_program(const char *prog, GLuint prognum)
+{
+ int a;
+ GLint errorpos, errno;
+
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog), (const GLubyte *) prog);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+
+ for (a=-10; a<10; a++)
+ {
+ if ((errorpos+a < 0) || (errorpos+a >= strlen(prog))) continue;
+ printf("%c", prog[errorpos+a]);
+ }
+ printf("\n");
+ exit(1);
+ }
+}
+
+static void Init( void )
+{
+ static const char *prog0 =
+ "!!ARBfp1.0\n"
+ "TEMP R0, RC, HC, H0, H1, H2, H3, H30 ;\n"
+ "MUL result.color, R0, fragment.position; \n"
+ "ADD result.color, H3, fragment.texcoord; \n"
+ "ADD_SAT result.color, H3, fragment.texcoord; \n"
+ "MUL result.color.xy, R0.wzyx, fragment.position; \n"
+ "MUL result.color, H0, fragment.position; \n"
+ "MUL result.color, -H0, fragment.position; \n"
+ "MOV RC, H1; \n"
+ "MOV HC, H2; \n"
+ "END \n"
+ ;
+ /* masked updates, defines, declarations */
+ static const char *prog1 =
+ "!!ARBfp1.0\n"
+ "PARAM foo = {1., 2., 3., 4.}; \n"
+ "PARAM foo2 = 5.; \n"
+ "PARAM foo3 = {5., 6., 7., 8.}; \n"
+ "PARAM bar = 3.; \n"
+ "TEMP R0, R1, RC, EQ, NE, bar2; \n"
+ "ALIAS bar3 = bar; \n"
+ "MOV result.color.xy, R0; \n"
+ "MOV result.color, R0; \n"
+ "MOV result.color.xyzw, R0; \n"
+ "MOV result.color.xy, R0; \n"
+ "MOV RC.x, R1.x; \n"
+ "KIL NE; \n"
+ "KIL EQ.xyxy; \n"
+ "END \n"
+ ;
+
+ /* texture instructions */
+ static const char *prog2 =
+ "!!ARBfp1.0\n"
+ "TEMP R0, R1, R2, R3;\n"
+ "TEX R0, fragment.texcoord, texture[1], 2D; \n"
+ "TEX R1, fragment.texcoord[1], texture[1], CUBE; \n"
+ "TEX R2, fragment.texcoord[2], texture[2], 3D; \n"
+ "TXP R3, fragment.texcoord[3], texture[3], RECT; \n"
+ "MUL result.color, R0, fragment.color; \n"
+ "END \n"
+ ;
+
+ /* test negation, absolute value */
+ static const char *prog3 =
+ "!!ARBfp1.0\n"
+ "TEMP R0, R1;\n"
+ "MOV R0, R1; \n"
+ "MOV R0, -R1; \n"
+ "MOV result.color, R0; \n"
+ "END \n"
+ ;
+
+ /* literal constant sources */
+ static const char *prog4 =
+ "!!ARBfp1.0\n"
+ "TEMP R0, R1;\n"
+ "PARAM Pi = 3.14159; \n"
+ "MOV R0, {1., -2., +3., 4.}; \n"
+ "MOV R0, 5.; \n"
+ "MOV R0, -5.; \n"
+ "MOV R0, 5.; \n"
+ "MOV R0, Pi; \n"
+ "MOV result.color, R0; \n"
+ "END \n"
+ ;
+
+ /* change the fragment color in a simple way */
+ static const char *prog10 =
+ "!!ARBfp1.0\n"
+ "PARAM blue = {0., 0., 1., 0.};\n"
+ "PARAM color = {1., 0., 0., 1.};\n"
+ "TEMP R0; \n"
+ "MOV R0, fragment.color; \n"
+ "#ADD result.color, R0, fragment.color; \n"
+ "#ADD result.color, blue, fragment.color; \n"
+ "#ADD result.color, {1., 0., 0., 0.}, fragment.color; \n"
+ "ADD result.color, color, fragment.color; \n"
+ "END \n"
+ ;
+
+ GLuint progs[20];
+
+ glGenProgramsARB(20, progs);
+ assert(progs[0]);
+ assert(progs[1]);
+ assert(progs[0] != progs[1]);
+
+
+ printf("program 0:\n");
+ load_program(prog0, progs[0]);
+ printf("program 1:\n");
+ load_program(prog1, progs[1]);
+ printf("program 2:\n");
+ load_program(prog2, progs[2]);
+ printf("program 3:\n");
+ load_program(prog3, progs[3]);
+ printf("program 4:\n");
+ load_program(prog4, progs[4]);
+ printf("program 10:\n");
+ load_program(prog10, progs[5]);
+
+
+ glEnable(GL_FRAGMENT_PROGRAM_ARB);
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_ALWAYS, 0.0);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptexture.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptexture.c
new file mode 100644
index 000000000..a854908c3
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptexture.c
@@ -0,0 +1,153 @@
+/* GL_ARB_fragment_program texture test */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#include "readtex.c"
+
+
+#define TEXTURE_FILE "../images/girl.rgb"
+
+static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+
+ glBegin(GL_POLYGON);
+#define Q 2
+ glColor4f(1.0, 1.0, 1.0, 1); glTexCoord4f(0, 0, 0, Q); glVertex2f(-1, -1);
+ glColor4f(0.2, 0.2, 1.0, 1); glTexCoord4f(1, 0, 0, Q); glVertex2f( 1, -1);
+ glColor4f(0.2, 1.0, 0.2, 1); glTexCoord4f(1, 1, 0, Q); glVertex2f( 1, 1);
+ glColor4f(1.0, 0.2, 0.2, 1); glTexCoord4f(0, 1, 0, Q); glVertex2f(-1, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -8.0 );
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ float step = 3.0;
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot += step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot -= step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ static const char *modulate2D =
+ "!!ARBfp1.0\n"
+ "TEMP R0;\n"
+ "TEX R0, fragment.texcoord[0], texture[0], 2D; \n"
+ "MUL result.color, R0, fragment.color; \n"
+ "END"
+ ;
+ GLuint modulateProg;
+ GLuint Texture;
+
+ if (!glutExtensionSupported("GL_ARB_fragment_program")) {
+ printf("Error: GL_ARB_fragment_program not supported!\n");
+ exit(1);
+ }
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ /* Setup the fragment program */
+ glGenProgramsARB(1, &modulateProg);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(modulate2D), (const GLubyte *)modulate2D);
+
+ printf("glGetError = 0x%x\n", (int) glGetError());
+ printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
+ (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ assert(glIsProgramARB(modulateProg));
+
+ glEnable(GL_FRAGMENT_PROGRAM_ARB);
+
+ /* Load texture */
+ glGenTextures(1, &Texture);
+ glBindTexture(GL_TEXTURE_2D, Texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
+ printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE);
+ exit(1);
+ }
+ /* XXX this enable shouldn't really be needed!!! */
+ glEnable(GL_TEXTURE_2D);
+
+ glClearColor(.3, .3, .3, 0);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptrig.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptrig.c
new file mode 100644
index 000000000..26b68c6b4
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbfptrig.c
@@ -0,0 +1,156 @@
+/* GL_ARB_fragment_program texture test */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#include "readtex.c"
+
+
+#define TEXTURE_FILE "../images/girl.rgb"
+
+static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
+
+#define PI 3.141592
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+
+ glBegin(GL_POLYGON);
+ glTexCoord2f(-PI, 0); glVertex2f(-1, -1);
+ glTexCoord2f(PI, 0); glVertex2f( 1, -1);
+ glTexCoord2f(PI, 1); glVertex2f( 1, 1);
+ glTexCoord2f(-PI, 1); glVertex2f(-1, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -8.0 );
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ float step = 3.0;
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot += step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot -= step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ static const char *modulate2D =
+ "!!ARBfp1.0\n"
+ "TEMP R0;\n"
+ "MOV R0, {0,0,0,1};\n"
+ "SCS R0, fragment.texcoord[0].x; \n"
+ "ADD R0, R0, {1.0}.x;\n"
+ "MUL R0, R0, {0.5}.x;\n"
+ "MOV result.color, R0; \n"
+ "END"
+ ;
+ GLuint modulateProg;
+ GLuint Texture;
+
+ if (!glutExtensionSupported("GL_ARB_fragment_program")) {
+ printf("Error: GL_ARB_fragment_program not supported!\n");
+ exit(1);
+ }
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ /* Setup the fragment program */
+ glGenProgramsARB(1, &modulateProg);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(modulate2D), (const GLubyte *)modulate2D);
+
+ printf("glGetError = 0x%x\n", (int) glGetError());
+ printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
+ (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ assert(glIsProgramARB(modulateProg));
+
+ glEnable(GL_FRAGMENT_PROGRAM_ARB);
+
+ /* Load texture */
+ glGenTextures(1, &Texture);
+ glBindTexture(GL_TEXTURE_2D, Texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
+ printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE);
+ exit(1);
+ }
+ /* XXX this enable shouldn't really be needed!!! */
+ glEnable(GL_TEXTURE_2D);
+
+ glClearColor(.3, .3, .3, 0);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/arbnpot.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbnpot.c
new file mode 100644
index 000000000..8107717e2
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbnpot.c
@@ -0,0 +1,174 @@
+/*
+ * Test NPOT textures with the GL_ARB_texture_non_power_of_two extension.
+ * Brian Paul
+ * 2 July 2003
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#include "../util/readtex.c"
+
+#define IMAGE_FILE "../images/girl.rgb"
+
+static GLfloat Zrot = 0;
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Zrot, 0, 0, 1);
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0);
+ glVertex2f(-1, -1);
+ glTexCoord2f(1, 0);
+ glVertex2f(1, -1);
+ glTexCoord2f(1, 1);
+ glVertex2f(1, 1);
+ glTexCoord2f(0, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -7.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'z':
+ Zrot -= 1.0;
+ break;
+ case 'Z':
+ Zrot += 1.0;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ GLubyte *image;
+ int imgWidth, imgHeight, minDim, w;
+ GLenum imgFormat;
+
+ if (!glutExtensionSupported("GL_ARB_texture_non_power_of_two")) {
+ printf("Sorry, this program requires GL_ARB_texture_non_power_of_two\n");
+ exit(1);
+ }
+
+#if 1
+ image = LoadRGBImage( IMAGE_FILE, &imgWidth, &imgHeight, &imgFormat );
+ if (!image) {
+ printf("Couldn't read %s\n", IMAGE_FILE);
+ exit(0);
+ }
+#else
+ int i, j;
+ imgFormat = GL_RGB;
+ imgWidth = 3;
+ imgHeight = 3;
+ image = malloc(imgWidth * imgHeight * 3);
+ for (i = 0; i < imgHeight; i++) {
+ for (j = 0; j < imgWidth; j++) {
+ int k = (i * imgWidth + j) * 3;
+ if ((i + j) & 1) {
+ image[k+0] = 255;
+ image[k+1] = 0;
+ image[k+2] = 0;
+ }
+ else {
+ image[k+0] = 0;
+ image[k+1] = 255;
+ image[k+2] = 0;
+ }
+ }
+ }
+#endif
+
+ printf("Read %d x %d\n", imgWidth, imgHeight);
+
+ minDim = imgWidth < imgHeight ? imgWidth : imgHeight;
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, imgWidth, 0,
+ imgFormat, GL_UNSIGNED_BYTE, image);
+ assert(glGetError() == GL_NO_ERROR);
+
+ glTexImage1D(GL_PROXY_TEXTURE_1D, 0, GL_RGB, imgWidth, 0,
+ imgFormat, GL_UNSIGNED_BYTE, image);
+ glGetTexLevelParameteriv(GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &w);
+ assert(w == imgWidth);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0,
+ imgFormat, GL_UNSIGNED_BYTE, image);
+ assert(glGetError() == GL_NO_ERROR);
+
+ glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0,
+ imgFormat, GL_UNSIGNED_BYTE, image);
+ glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
+ assert(w == imgWidth);
+
+ glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0,
+ imgFormat, GL_UNSIGNED_BYTE, image);
+ assert(glGetError() == GL_NO_ERROR);
+
+ glTexImage3D(GL_PROXY_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0,
+ imgFormat, GL_UNSIGNED_BYTE, image);
+ glGetTexLevelParameteriv(GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &w);
+ assert(w == imgWidth);
+
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB,
+ minDim, minDim, 0,
+ imgFormat, GL_UNSIGNED_BYTE, image);
+ assert(glGetError() == GL_NO_ERROR);
+
+ glTexImage2D(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_RGB,
+ minDim, minDim, 0,
+ imgFormat, GL_UNSIGNED_BYTE, image);
+ glGetTexLevelParameteriv(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_WIDTH, &w);
+ assert(w == minDim);
+
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glEnable(GL_TEXTURE_2D);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 400, 400 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptest1.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptest1.c
new file mode 100644
index 000000000..5c462c42c
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptest1.c
@@ -0,0 +1,164 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+
+ glBegin(GL_POLYGON);
+ glVertexAttrib2fNV(0, -1, -1);
+ glVertexAttrib2fNV(0, 1, -1);
+ glVertexAttrib2fNV(0, 0, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+static void load_program(const char *prog, GLuint prognum)
+{
+ int a;
+ GLint errorpos, errno;
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog), (const GLubyte *) prog);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+
+ for (a=-10; a<10; a++)
+ {
+ if ((errorpos+a < 0) || (errorpos+a >= strlen(prog))) continue;
+ printf("%c", prog[errorpos+a]);
+ }
+ printf("\n");
+ exit(1);
+ }
+}
+
+static void Init( void )
+{
+ GLuint prognum[4];
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "TEMP R0;\n"
+ "MUL result.color.primary.xyz, R0, program.local[35]; \n"
+ "END\n";
+ static const char *prog2 =
+ "!!ARBvp1.0\n"
+ "#\n"
+ "# c[0-3] = modelview projection (composite) matrix\n"
+ "# c[32] = normalized light direction in object-space\n"
+ "# c[35] = yellow diffuse material, (1.0, 1.0, 0.0, 1.0)\n"
+ "# c[64].x = 0.0\n"
+ "# c[64].z = 0.125, a scaling factor\n"
+ "TEMP R0, R1;\n"
+ "#\n"
+ "# outputs diffuse illumination for color and perturbed position\n"
+ "#\n"
+ "DP3 R0, program.local[32], vertex.normal; # light direction DOT normal\n"
+ "MUL result.color.primary.xyz, R0, program.local[35]; \n"
+ "MAX R0, program.local[64].x, R0; \n"
+ "MUL R0, R0, vertex.normal; \n"
+ "MUL R0, R0, program.local[64].z; \n"
+ "ADD R1, vertex.position, -R0; # perturb object space position\n"
+ "DP4 result.position.x, state.matrix.mvp.row[3], R1; \n"
+ "DP4 result.position.y, state.matrix.mvp.row[1], R1; \n"
+ "DP4 result.position.z, state.matrix.mvp.row[2], R1; \n"
+ "DP4 result.position.w, state.matrix.mvp.row[3], R1; \n"
+ "END\n";
+ static const char *prog3 =
+ "!!ARBvp1.0\n"
+ "TEMP R0, R1, R2, R3;\n"
+ "DP4 result.position.x, state.matrix.mvp.row[0], vertex.position;\n"
+ "DP4 result.position.y, state.matrix.mvp.row[1], vertex.position;\n"
+ "DP4 result.position.z, state.matrix.mvp.row[2], vertex.position;\n"
+ "DP4 result.position.w, state.matrix.mvp.row[3], vertex.position;\n"
+ "DP3 R0.x, state.matrix.modelview.inverse.row[0], vertex.normal;\n"
+ "DP3 R0.y, state.matrix.modelview.inverse.row[1], vertex.normal;\n"
+ "DP3 R0.z, state.matrix.modelview.inverse.row[2], vertex.normal;\n"
+ "DP3 R1.x, program.env[32], R0; # R1.x = Lpos DOT n'\n"
+ "DP3 R1.y, program.env[33], R0; # R1.y = hHat DOT n'\n"
+ "MOV R1.w, program.local[38].x; # R1.w = specular power\n"
+ "LIT R2, R1; # Compute lighting values\n"
+ "MAD R3, program.env[35].x, R2.y, program.env[35].y; # diffuse + emissive\n"
+ "MAD result.color.primary.xyz, program.env[36], R2.z, R3; # + specular\n"
+ "END\n";
+ static const char *prog4 =
+ "!!ARBvp1.0\n"
+ "TEMP R2, R3;\n"
+ "PARAM foo = {0., 0., 0., 1.};\n"
+ "PARAM blah[] = { program.local[0..8] };\n"
+ "ADDRESS A0;\n"
+ "ARL A0.x, foo.x;\n"
+ "DP4 R2, R3, blah[A0.x].x;\n"
+ "DP4 R2, R3, blah[A0.x + 5];\n"
+ "DP4 result.position, R3, blah[A0.x - 4];\n"
+ "END\n";
+
+ glGenProgramsNV(4, prognum);
+
+ load_program(prog1, prognum[0]);
+ load_program(prog2, prognum[1]);
+ load_program(prog3, prognum[2]);
+ load_program(prog4, prognum[3]);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptest3.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptest3.c
new file mode 100644
index 000000000..5f6d4f7e9
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptest3.c
@@ -0,0 +1,128 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static float Zrot = 0.0;
+
+
+static void Display( void )
+{
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+ glLoadIdentity();
+ glRotatef(Zrot, 0, 0, 1);
+
+ glPushMatrix();
+
+ glVertexAttrib3fARB(3, 1, 0.5, 0.25);
+ glBegin(GL_TRIANGLES);
+#if 1
+ glVertexAttrib3fARB(3, 1.0, 0.0, 0.0);
+ glVertexAttrib2fARB(0, -0.5, -0.5);
+ glVertexAttrib3fARB(3, 0.0, 1.0, 0.0);
+ glVertexAttrib2fARB(0, 0.5, -0.5);
+ glVertexAttrib3fARB(3, 0.0, 0.0, 1.0);
+ glVertexAttrib2fARB(0, 0, 0.5);
+#else
+ glVertex2f( -1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 0, 1);
+#endif
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ /* glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/
+ glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ /*glTranslatef( 0.0, 0.0, -15.0 );*/
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'z':
+ Zrot -= 5.0;
+ break;
+ case 'Z':
+ Zrot += 5.0;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "MOV result.color, vertex.color;\n"
+
+ "DP4 result.position.x, vertex.position, state.matrix.modelview.row[0];\n"
+ "DP4 result.position.y, vertex.position, state.matrix.modelview.row[1];\n"
+ "DP4 result.position.z, vertex.position, state.matrix.modelview.row[2];\n"
+ "DP4 result.position.w, vertex.position, state.matrix.modelview.row[3];\n"
+ "END\n";
+
+ glGenProgramsARB(1, &prognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog1), (const GLubyte *) prog1);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptorus.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptorus.c
new file mode 100644
index 000000000..c1e2d0b76
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvptorus.c
@@ -0,0 +1,191 @@
+/*
+ * A lit, rotating torus via vertex program
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static float Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
+static GLboolean Anim = GL_TRUE;
+
+
+static void Idle( void )
+{
+ Xrot += .3;
+ Yrot += .4;
+ Zrot += .2;
+ glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+ glutSolidTorus(0.75, 2.0, 10, 20);
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -12.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case ' ':
+ Xrot = Yrot = Zrot = 0;
+ break;
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'z':
+ Zrot -= 5.0;
+ break;
+ case 'Z':
+ Zrot += 5.0;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ /* borrowed from an nvidia demo:
+ * c[0..3] = modelview matrix
+ * c[4..7] = invtrans modelview matrix
+ * c[32] = light pos
+ * c[35] = diffuse color
+ */
+ static const char prog[] =
+ "!!ARBvp1.0\n"
+ "TEMP R0, R1; \n"
+ "#Simple transform and diffuse lighting\n"
+ "# object x MVP -> clip\n"
+ "DP4 result.position.x, state.matrix.mvp.row[0], vertex.position ;\n"
+ "DP4 result.position.y, state.matrix.mvp.row[1], vertex.position ;\n"
+ "DP4 result.position.z, state.matrix.mvp.row[2], vertex.position ;\n"
+ "DP4 result.position.w, state.matrix.mvp.row[3], vertex.position ;\n"
+
+ "# normal x MV-1T -> lighting normal\n"
+ "DP3 R1.x, state.matrix.modelview.invtrans.row[0], vertex.normal ;\n"
+ "DP3 R1.y, state.matrix.modelview.invtrans.row[1], vertex.normal;\n"
+ "DP3 R1.z, state.matrix.modelview.invtrans.row[2], vertex.normal;\n"
+
+ "DP3 R0, program.local[32], R1; # L.N\n"
+#if 0
+ "MUL result.color.xyz, R0, program.local[35] ; # col = L.N * diffuse\n"
+#else
+ "MUL result.color.primary.xyz, R0, program.local[35] ; # col = L.N * diffuse\n"
+#endif
+ "MOV result.texcoord, vertex.texcoord;\n"
+ "END";
+
+ if (!glutExtensionSupported("GL_ARB_vertex_program")) {
+ printf("Sorry, this program requires GL_ARB_vertex_program");
+ exit(1);
+ }
+
+
+ glGenProgramsARB(1, &prognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog), (const GLubyte *) prog);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+
+ /* Light position */
+ glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 32, 2, 2, 4, 1);
+ /* Diffuse material color */
+ glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 35, 0.25, 0, 0.25, 1);
+
+ glEnable(GL_VERTEX_PROGRAM_ARB);
+ glEnable(GL_DEPTH_TEST);
+ glClearColor(0.3, 0.3, 0.3, 1);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvpwarpmesh.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvpwarpmesh.c
new file mode 100644
index 000000000..a9e2564bc
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/arbvpwarpmesh.c
@@ -0,0 +1,246 @@
+/*
+ * Warp a triangle mesh with a vertex program.
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static float Xrot = -60.0, Yrot = 0.0, Zrot = 0.0;
+static GLboolean Anim = GL_TRUE;
+static GLfloat Phi = 0.0;
+
+
+static void Idle( void )
+{
+ Phi += 0.01;
+ glutPostRedisplay();
+}
+
+
+static void DrawMesh( int rows, int cols )
+{
+ static const GLfloat colorA[3] = { 0, 1, 0 };
+ static const GLfloat colorB[3] = { 0, 0, 1 };
+ const float dx = 2.0 / (cols - 1);
+ const float dy = 2.0 / (rows - 1);
+ float x, y;
+ int i, j;
+
+#if 1
+#define COLOR3FV(c) glVertexAttrib3fvARB(3, c)
+#define VERTEX2F(x, y) glVertexAttrib2fARB(0, x, y)
+#else
+#define COLOR3FV(c) glColor3fv(c)
+#define VERTEX2F(x, y) glVertex2f(x, y)
+#endif
+
+ y = -1.0;
+ for (i = 0; i < rows - 1; i++) {
+ glBegin(GL_QUAD_STRIP);
+ x = -1.0;
+ for (j = 0; j < cols; j++) {
+ if ((i + j) & 1)
+ COLOR3FV(colorA);
+ else
+ COLOR3FV(colorB);
+ VERTEX2F(x, y);
+ VERTEX2F(x, y + dy);
+ x += dx;
+ }
+ glEnd();
+ y += dy;
+ }
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+
+ /* Position the gravity source */
+ {
+ GLfloat x, y, z, r = 0.5;
+ x = r * cos(Phi);
+ y = r * sin(Phi);
+ z = 1.0;
+ glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 30, x, y, z, 1);
+ glDisable(GL_VERTEX_PROGRAM_ARB);
+ glBegin(GL_POINTS);
+ glColor3f(1,1,1);
+ glVertex3f(x, y, z);
+ glEnd();
+ }
+
+ glEnable(GL_VERTEX_PROGRAM_ARB);
+ DrawMesh(8, 8);
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ float ar = (float) width / (float) height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0 * ar, 1.0 * ar, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -12.0 );
+ glScalef(2, 2, 2);
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'p':
+ Phi += 0.2;
+ break;
+ case 'z':
+ Zrot -= 5.0;
+ break;
+ case 'Z':
+ Zrot += 5.0;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ GLuint prognum;
+ GLint errno;
+
+ /*
+ * c[0..3] = modelview matrix
+ * c[4..7] = inverse modelview matrix
+ * c[30] = gravity source location
+ * c[31] = gravity source strength
+ * c[32] = light pos
+ * c[35] = diffuse color
+ */
+ static const char prog[] =
+ "!!ARBvp1.0\n"
+ "TEMP R1, R2, R3; "
+
+ "# Compute distance from vertex to gravity source\n"
+ "ADD R1, program.local[30], -vertex.position; # vector from vertex to gravity\n"
+ "DP3 R2, R1, R1; # dot product\n"
+ "RSQ R2, R2.x; # square root = distance\n"
+ "MUL R2, R2, program.local[31].xxxx; # scale by the gravity factor\n"
+
+ "# Displace vertex by gravity factor along R1 vector\n"
+ "MAD R3, R1, R2, vertex.position;\n"
+
+ "# Continue with typical modelview/projection\n"
+ "DP4 result.position.x, state.matrix.mvp.row[0], R3 ; # object x MVP -> clip\n"
+ "DP4 result.position.y, state.matrix.mvp.row[1], R3 ;\n"
+ "DP4 result.position.z, state.matrix.mvp.row[2], R3 ;\n"
+ "DP4 result.position.w, state.matrix.mvp.row[3], R3 ;\n"
+
+ "MOV result.color, vertex.color;\n # copy input color to output color\n"
+
+ "END";
+
+ if (!glutExtensionSupported("GL_ARB_vertex_program")) {
+ printf("Sorry, this program requires GL_ARB_vertex_program\n");
+ exit(1);
+ }
+
+ glGenProgramsARB(1, &prognum);
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog), (const GLubyte *)prog);
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+
+ /* Light position */
+ glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 32, 2, 2, 4, 1);
+ /* Diffuse material color */
+ glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 35, 0.25, 0, 0.25, 1);
+
+ /* Gravity strength */
+ glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 31, .5, 0, 0, 0);
+
+ glEnable(GL_DEPTH_TEST);
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glShadeModel(GL_FLAT);
+ glPointSize(3);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/auxbuffer.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/auxbuffer.c
new file mode 100644
index 000000000..70f0b7391
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/auxbuffer.c
@@ -0,0 +1,499 @@
+/*
+ * Test AUX buffer rendering
+ * Use GLX since GLUT doesn't support AUX buffers
+ */
+
+
+/*
+ * 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 "gears" demo to straight GLX (i.e. no GLUT)
+ * Port by Brian Paul 23 March 2001
+ *
+ * Command line options:
+ * -info print GL implementation information
+ *
+ */
+
+
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <GL/gl.h>
+#include <GL/glx.h>
+
+
+static int
+current_time(void)
+{
+ return 0;
+}
+
+
+
+
+#ifndef M_PI
+#define M_PI 3.14159265
+#endif
+
+static int WinWidth = 300, WinHeight = 300;
+static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
+static GLint gear1, gear2, gear3;
+static GLfloat angle = 0.0;
+
+
+/*
+ *
+ * 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)
+{
+ GLfloat h = (GLfloat) height / (GLfloat) width;
+
+ WinWidth = width;
+ WinHeight = height;
+ glViewport(0, 0, (GLint) width, (GLint) height);
+ 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 };
+ int i;
+
+ glGetIntegerv(GL_AUX_BUFFERS, &i);
+ printf("AUX BUFFERS: %d\n", i);
+
+ 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);
+}
+
+
+/*
+ * Create an RGB, double-buffered window.
+ * Return the window and context handles.
+ */
+static void
+make_window( Display *dpy, const char *name,
+ int x, int y, int width, int height,
+ Window *winRet, GLXContext *ctxRet)
+{
+ int attrib[] = { GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ GLX_DEPTH_SIZE, 1,
+ GLX_AUX_BUFFERS, 1,
+ None };
+ int scrnum;
+ XSetWindowAttributes attr;
+ unsigned long mask;
+ Window root;
+ Window win;
+ GLXContext ctx;
+ XVisualInfo *visinfo;
+
+ scrnum = DefaultScreen( dpy );
+ root = RootWindow( dpy, scrnum );
+
+ visinfo = glXChooseVisual( dpy, scrnum, attrib );
+ if (!visinfo) {
+ printf("Error: couldn't get an RGB, Double-buffered visual\n");
+ exit(1);
+ }
+
+ /* window attributes */
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+ win = XCreateWindow( dpy, root, 0, 0, width, height,
+ 0, visinfo->depth, InputOutput,
+ visinfo->visual, mask, &attr );
+
+ /* set hints and properties */
+ {
+ XSizeHints sizehints;
+ sizehints.x = x;
+ sizehints.y = y;
+ sizehints.width = width;
+ sizehints.height = height;
+ sizehints.flags = USSize | USPosition;
+ XSetNormalHints(dpy, win, &sizehints);
+ XSetStandardProperties(dpy, win, name, name,
+ None, (char **)NULL, 0, &sizehints);
+ }
+
+ ctx = glXCreateContext( dpy, visinfo, NULL, True );
+ if (!ctx) {
+ printf("Error: glXCreateContext failed\n");
+ exit(1);
+ }
+
+ XFree(visinfo);
+
+ *winRet = win;
+ *ctxRet = ctx;
+}
+
+
+static void
+event_loop(Display *dpy, Window win)
+{
+ while (1) {
+ while (XPending(dpy) > 0) {
+ XEvent event;
+ XNextEvent(dpy, &event);
+ switch (event.type) {
+ case Expose:
+ /* we'll redraw below */
+ break;
+ case ConfigureNotify:
+ reshape(event.xconfigure.width, event.xconfigure.height);
+ break;
+ case KeyPress:
+ {
+ char buffer[10];
+ int r, code;
+ code = XLookupKeysym(&event.xkey, 0);
+ if (code == XK_Left) {
+ view_roty += 5.0;
+ }
+ else if (code == XK_Right) {
+ view_roty -= 5.0;
+ }
+ else if (code == XK_Up) {
+ view_rotx += 5.0;
+ }
+ else if (code == XK_Down) {
+ view_rotx -= 5.0;
+ }
+ else {
+ r = XLookupString(&event.xkey, buffer, sizeof(buffer),
+ NULL, NULL);
+ if (buffer[0] == 27) {
+ /* escape */
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ /* next frame */
+ angle += 2.0;
+
+ /* draw to aux buffer */
+ glDrawBuffer(GL_AUX0);
+
+ draw();
+
+ /* Copy aux buffer image to back color buffer */
+ glReadBuffer(GL_AUX0);
+ glDrawBuffer(GL_BACK);
+ glWindowPos2iARB(0, 0);
+ glDisable(GL_DEPTH_TEST);
+ glCopyPixels(0, 0, WinWidth, WinHeight, GL_COLOR);
+ glEnable(GL_DEPTH_TEST);
+
+ glXSwapBuffers(dpy, win);
+
+ /* calc framerate */
+ {
+ static int t0 = -1;
+ static int frames = 0;
+ int t = current_time();
+
+ if (t0 < 0)
+ t0 = t;
+
+ frames++;
+
+ if (t - t0 >= 5.0) {
+ GLfloat seconds = t - t0;
+ GLfloat fps = frames / seconds;
+ printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
+ fps);
+ t0 = t;
+ frames = 0;
+ }
+ }
+ }
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ Display *dpy;
+ Window win;
+ GLXContext ctx;
+ char *dpyName = ":0";
+ GLboolean printInfo = GL_FALSE;
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-display") == 0) {
+ dpyName = argv[i+1];
+ i++;
+ }
+ else if (strcmp(argv[i], "-info") == 0) {
+ printInfo = GL_TRUE;
+ }
+ }
+
+ dpy = XOpenDisplay(dpyName);
+ if (!dpy) {
+ printf("Error: couldn't open display %s\n", dpyName);
+ return -1;
+ }
+
+ make_window(dpy, "glxgears", 0, 0, WinWidth, WinHeight, &win, &ctx);
+ XMapWindow(dpy, win);
+ glXMakeCurrent(dpy, win, ctx);
+
+ 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();
+
+ event_loop(dpy, win);
+
+ glXDestroyContext(dpy, ctx);
+ XDestroyWindow(dpy, win);
+ XCloseDisplay(dpy);
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/blendminmax.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/blendminmax.c
new file mode 100644
index 000000000..2aab1a39d
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/blendminmax.c
@@ -0,0 +1,209 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 (including the next
+ * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+/**
+ * \file blendminmax.c
+ *
+ * Simple test of GL_EXT_blend_minmax functionality. Four squares are drawn
+ * with different blending modes, but all should be rendered with the same
+ * final color.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int Width = 400;
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+ glClearColor(0.2, 0.2, 0.8, 0);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+
+ /* This is the "reference" square.
+ */
+
+ glTranslatef(-4.5, 0, 0);
+ glBlendEquation( GL_FUNC_ADD );
+ glBlendFunc( GL_ONE, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ /* GL_MIN and GL_MAX are supposed to ignore the blend function setting.
+ * To test that, we set the blend function to GL_ZERO for both color and
+ * alpha each time GL_MIN or GL_MAX is used.
+ *
+ * Apple ships an extension called GL_ATI_blend_weighted_minmax (supported
+ * on Mac OS X 10.2 and later). I believe the difference with that
+ * extension is that it uses the blend function. However, I have no idea
+ * what the enums are for it. The extension is listed at Apple's developer
+ * site, but there is no documentation.
+ *
+ * http://developer.apple.com/opengl/extensions.html
+ */
+
+ glTranslatef(3.0, 0, 0);
+ glBlendEquation( GL_FUNC_ADD );
+ glBlendFunc( GL_ONE, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ glBlendEquation( GL_MAX );
+ glBlendFunc( GL_ZERO, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.2, 0.2, 0.2 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ glTranslatef(3.0, 0, 0);
+ glBlendEquation( GL_FUNC_ADD );
+ glBlendFunc( GL_ONE, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ glBlendEquation( GL_MIN );
+ glBlendFunc( GL_ZERO, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.8, 0.8, 0.8 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ glTranslatef(3.0, 0, 0);
+ glBlendEquation( GL_FUNC_ADD );
+ glBlendFunc( GL_ONE, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.8, 0.8, 0.8 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ glBlendEquation( GL_MIN );
+ glBlendFunc( GL_ZERO, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ const char * const ver_string = (const char * const)
+ glGetString( GL_VERSION );
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", ver_string);
+
+ if ( !glutExtensionSupported("GL_ARB_imaging") && !glutExtensionSupported("GL_EXT_blend_minmax")) {
+ printf("Sorry, this program requires either GL_ARB_imaging or GL_EXT_blend_minmax.\n");
+ exit(1);
+ }
+
+ printf("\nAll 4 squares should be the same color.\n");
+ glEnable( GL_BLEND );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow( "GL_EXT_blend_minmax test" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/blendsquare.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/blendsquare.c
new file mode 100644
index 000000000..1694866a5
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/blendsquare.c
@@ -0,0 +1,178 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 (including the next
+ * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+/**
+ * \file blendsquare.c
+ *
+ * Simple test of GL_NV_blend_square functionality. Four squares are drawn
+ * with different blending modes, but all should be rendered with the same
+ * final color.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int Width = 400;
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+ glClearColor(0.2, 0.2, 0.8, 0);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+
+ glTranslatef(-4.5, 0, 0);
+ glBlendFunc( GL_ONE, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.5 * 0.5, 0.5 * 0.5, 0.5 * 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ glTranslatef(3.0, 0, 0);
+ glBlendFunc( GL_ONE, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ glBlendFunc( GL_DST_COLOR, GL_ZERO );
+ glBegin(GL_QUADS);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ glTranslatef(3.0, 0, 0);
+ glBlendFunc( GL_SRC_COLOR, GL_ZERO );
+ glBegin(GL_QUADS);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ glTranslatef(3.0, 0, 0);
+ glBlendFunc( GL_ONE, GL_ZERO );
+ glBegin(GL_QUADS);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ glBlendFunc( GL_ZERO, GL_DST_COLOR );
+ glBegin(GL_QUADS);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ const char * const ver_string = (const char * const)
+ glGetString( GL_VERSION );
+ const double version = strtod( ver_string, NULL );
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", ver_string);
+
+ if ( (version < 1.4) && !glutExtensionSupported("GL_NV_blend_square")) {
+ printf("Sorry, this program requires either OpenGL 1.4 or GL_NV_blend_square\n");
+ exit(1);
+ }
+
+ printf("\nAll 4 squares should be the same color. The two on the left are drawn\n"
+ "without NV_blend_square functionality, and the two on the right are drawn\n"
+ "with NV_blend_square functionality. If the two on the left are dark, but\n"
+ "the two on the right are not, then NV_blend_square is broken.\n");
+ glEnable( GL_BLEND );
+ glBlendEquation( GL_FUNC_ADD );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow( "GL_NV_blend_square test" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/bufferobj.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/bufferobj.c
new file mode 100644
index 000000000..c765d2516
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/bufferobj.c
@@ -0,0 +1,359 @@
+/*
+ * Test GL_ARB_vertex_buffer_object
+ *
+ * Brian Paul
+ * 16 Sep 2003
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+#define NUM_OBJECTS 10
+
+struct object
+{
+ GLuint BufferID;
+ GLuint ElementsBufferID;
+ GLuint NumVerts;
+ GLuint VertexOffset;
+ GLuint ColorOffset;
+ GLuint NumElements;
+};
+
+static struct object Objects[NUM_OBJECTS];
+static GLuint NumObjects;
+
+static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
+static GLboolean Anim = GL_TRUE;
+
+
+static void CheckError(int line)
+{
+ GLenum err = glGetError();
+ if (err) {
+ printf("GL Error 0x%x at line %d\n", (int) err, line);
+ }
+}
+
+
+static void DrawObject( const struct object *obj )
+{
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID);
+ glVertexPointer(3, GL_FLOAT, 0, (void *) obj->VertexOffset);
+ glEnable(GL_VERTEX_ARRAY);
+
+ /* test push/pop attrib */
+ /* XXX this leads to a segfault with NVIDIA's 53.36 driver */
+#if 0
+ if (1)
+ {
+ glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+ /*glVertexPointer(3, GL_FLOAT, 0, (void *) (obj->VertexOffset + 10000));*/
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, 999999);
+ glPopClientAttrib();
+ }
+#endif
+ glColorPointer(3, GL_FLOAT, 0, (void *) obj->ColorOffset);
+ glEnable(GL_COLOR_ARRAY);
+
+ if (obj->NumElements > 0) {
+ /* indexed arrays */
+ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID);
+ glDrawElements(GL_LINE_LOOP, obj->NumElements, GL_UNSIGNED_INT, NULL);
+ }
+ else {
+ /* non-indexed arrays */
+ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
+ glDrawArrays(GL_LINE_LOOP, 0, obj->NumVerts);
+ }
+}
+
+
+static void Idle( void )
+{
+ Zrot = 0.05 * glutGet(GLUT_ELAPSED_TIME);
+ glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+ int i;
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ for (i = 0; i < NumObjects; i++) {
+ float x = 5.0 * ((float) i / (NumObjects-1) - 0.5);
+ glPushMatrix();
+ glTranslatef(x, 0, 0);
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+
+ DrawObject(Objects + i);
+
+ glPopMatrix();
+ }
+
+ CheckError(__LINE__);
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ float ar = (float) width / (float) height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'z':
+ Zrot -= step;
+ break;
+ case 'Z':
+ Zrot += step;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+
+static void MakeObject1(struct object *obj)
+{
+ GLfloat *v, *c;
+ void *p;
+ int i;
+ GLubyte buffer[500];
+
+ for (i = 0; i < 500; i++)
+ buffer[i] = i & 0xff;
+
+ obj->BufferID = 0;
+ glGenBuffersARB(1, &obj->BufferID);
+ assert(obj->BufferID != 0);
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID);
+ glBufferDataARB(GL_ARRAY_BUFFER_ARB, 500, buffer, GL_STATIC_DRAW_ARB);
+
+ for (i = 0; i < 500; i++)
+ buffer[i] = 0;
+
+ glGetBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 500, buffer);
+
+ for (i = 0; i < 500; i++)
+ assert(buffer[i] == (i & 0xff));
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i);
+ assert(!i);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_USAGE_ARB, &i);
+
+ v = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+
+ /* do some sanity tests */
+ glGetBufferPointervARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAP_POINTER_ARB, &p);
+ assert(p == v);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &i);
+ assert(i == 500);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_USAGE_ARB, &i);
+ assert(i == GL_STATIC_DRAW_ARB);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_ACCESS_ARB, &i);
+ assert(i == GL_WRITE_ONLY_ARB);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i);
+ assert(i);
+
+ /* Make rectangle */
+ v[0] = -1; v[1] = -1; v[2] = 0;
+ v[3] = 1; v[4] = -1; v[5] = 0;
+ v[6] = 1; v[7] = 1; v[8] = 0;
+ v[9] = -1; v[10] = 1; v[11] = 0;
+ c = v + 12;
+ c[0] = 1; c[1] = 0; c[2] = 0;
+ c[3] = 1; c[4] = 0; c[5] = 0;
+ c[6] = 1; c[7] = 0; c[8] = 1;
+ c[9] = 1; c[10] = 0; c[11] = 1;
+ obj->NumVerts = 4;
+ obj->VertexOffset = 0;
+ obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts;
+ obj->NumElements = 0;
+
+ glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
+
+ glGetBufferPointervARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAP_POINTER_ARB, &p);
+ assert(!p);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i);
+ assert(!i);
+}
+
+
+static void MakeObject2(struct object *obj)
+{
+ GLfloat *v, *c;
+
+ glGenBuffersARB(1, &obj->BufferID);
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID);
+ glBufferDataARB(GL_ARRAY_BUFFER_ARB, 1000, NULL, GL_STATIC_DRAW_ARB);
+ v = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+
+ /* Make triangle */
+ v[0] = -1; v[1] = -1; v[2] = 0;
+ v[3] = 1; v[4] = -1; v[5] = 0;
+ v[6] = 0; v[7] = 1; v[8] = 0;
+ c = v + 9;
+ c[0] = 0; c[1] = 1; c[2] = 0;
+ c[3] = 0; c[4] = 1; c[5] = 0;
+ c[6] = 1; c[7] = 1; c[8] = 0;
+ obj->NumVerts = 3;
+ obj->VertexOffset = 0;
+ obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts;
+ obj->NumElements = 0;
+
+ glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
+}
+
+
+static void MakeObject3(struct object *obj)
+{
+ GLfloat vertexData[1000];
+ GLfloat *v, *c;
+ GLuint *i;
+ int bytes;
+
+ /* Make rectangle */
+ v = vertexData;
+ v[0] = -1; v[1] = -0.5; v[2] = 0;
+ v[3] = 1; v[4] = -0.5; v[5] = 0;
+ v[6] = 1; v[7] = 0.5; v[8] = 0;
+ v[9] = -1; v[10] = 0.5; v[11] = 0;
+ c = vertexData + 12;
+ c[0] = 0; c[1] = 0; c[2] = 1;
+ c[3] = 0; c[4] = 0; c[5] = 1;
+ c[6] = 0; c[7] = 1; c[8] = 1;
+ c[9] = 0; c[10] = 1; c[11] = 1;
+ obj->NumVerts = 4;
+ obj->VertexOffset = 0;
+ obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts;
+
+ bytes = obj->NumVerts * (3 + 3) * sizeof(GLfloat);
+
+ /* Don't use glMap/UnmapBuffer for this object */
+ glGenBuffersARB(1, &obj->BufferID);
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID);
+ glBufferDataARB(GL_ARRAY_BUFFER_ARB, bytes, vertexData, GL_STATIC_DRAW_ARB);
+
+ /* Setup a buffer of indices to test the ELEMENTS path */
+ glGenBuffersARB(1, &obj->ElementsBufferID);
+ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID);
+ glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 100, NULL, GL_STATIC_DRAW_ARB);
+ i = (GLuint *) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_READ_WRITE_ARB);
+ i[0] = 0;
+ i[1] = 1;
+ i[2] = 2;
+ i[3] = 3;
+ glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
+ obj->NumElements = 4;
+}
+
+
+
+static void Init( void )
+{
+ if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) {
+ printf("GL_ARB_vertex_buffer_object not found!\n");
+ exit(0);
+ }
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ /* Test buffer object deletion */
+ if (1) {
+ static GLubyte data[1000];
+ GLuint id = 999;
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, id);
+ glBufferDataARB(GL_ARRAY_BUFFER_ARB, 1000, data, GL_STATIC_DRAW_ARB);
+ glVertexPointer(3, GL_FLOAT, 0, (void *) 0);
+ glDeleteBuffersARB(1, &id);
+ assert(!glIsBufferARB(id));
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+ glVertexPointer(3, GL_FLOAT, 0, (void *) 0);
+ assert(!glIsBufferARB(id));
+ }
+
+ MakeObject1(Objects + 0);
+ MakeObject2(Objects + 1);
+ MakeObject3(Objects + 2);
+ NumObjects = 3;
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 600, 300 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/bug_3101.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/bug_3101.c
new file mode 100644
index 000000000..761dcbb95
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/bug_3101.c
@@ -0,0 +1,128 @@
+/*
+ * (C) Copyright IBM Corporation 2005
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 (including the next
+ * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+/**
+ * \file bug_3101.c
+ *
+ * Simple regression test for bug #3101. Attempt to draw a single square.
+ * After emiting the first vertex, call \c glEdgeFlag to change the vertex
+ * format. If the bug still exists, this will cause a segfault.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int Width = 400;
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+ glClearColor(0.2, 0.2, 0.8, 0);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+
+ /* This is the "reference" square.
+ */
+
+ glTranslatef(-4.5, 0, 0);
+ glBlendEquation( GL_FUNC_ADD );
+ glBlendFunc( GL_ONE, GL_ZERO );
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glEdgeFlag(GL_TRUE);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ const char * const ver_string = (const char * const)
+ glGetString( GL_VERSION );
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", ver_string);
+
+ printf("\nThis program should draw a single square, but not crash.\n");
+ printf("This is a regression test for bug #3101.\n");
+ printf("https://bugs.freedesktop.org/show_bug.cgi?id=3101\n");
+ glEnable( GL_BLEND );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow( "Bug #3101 Test" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/bug_3195.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/bug_3195.c
new file mode 100644
index 000000000..75de58b07
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/bug_3195.c
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2000 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.
+ */
+
+/**
+ * \file bug_3195.c
+ *
+ * Simple regression test for bug #3195. A bug in the i180 driver caused
+ * a segfault (inside the driver) when the LOD bias is adjusted and no texture
+ * is enabled. This test, which is based on progs/demos/lodbias.c, sets up
+ * all the texturing, disables all textures, adjusts the LOD bias, then
+ * re-enables \c GL_TEXTURE_2D.
+ *
+ * \author Brian Paul
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+
+#include "readtex.h"
+
+#define TEXTURE_FILE "../images/girl.rgb"
+
+static GLfloat Xrot = 0, Yrot = -30, Zrot = 0;
+static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */
+static GLint BiasMin = -400, BiasMax = 400;
+
+
+
+static void
+PrintString(const char *s)
+{
+ while (*s) {
+ glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
+ s++;
+ }
+}
+
+static void Idle( void )
+{
+ static int lastTime = 0;
+ int time = glutGet(GLUT_ELAPSED_TIME);
+ int step;
+
+ if (lastTime == 0)
+ lastTime = time;
+ else if (time - lastTime < 10)
+ return;
+
+ step = (time - lastTime) / 10 * BiasStepSign;
+ lastTime = time;
+
+ Bias += step;
+ if (Bias < BiasMin) {
+ exit(0);
+ }
+ else if (Bias > BiasMax) {
+ Bias = BiasMax;
+ BiasStepSign = -1;
+ }
+
+ glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+ char str[100];
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(-1, 1, -1, 1, -1, 1);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ glDisable(GL_TEXTURE_2D);
+ glColor3f(1,1,1);
+ glRasterPos3f(-0.9, -0.9, 0.0);
+ sprintf(str, "Texture LOD Bias = %4.1f", Bias * 0.01);
+ PrintString(str);
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -8.0 );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.01 * Bias);
+ glEnable(GL_TEXTURE_2D);
+
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0); glVertex2f(-1, -1);
+ glTexCoord2f(2, 0); glVertex2f( 1, -1);
+ glTexCoord2f(2, 2); glVertex2f( 1, 1);
+ glTexCoord2f(0, 2); glVertex2f(-1, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ GLfloat maxBias;
+ const char * const ver_string = (const char * const)
+ glGetString( GL_VERSION );
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", ver_string);
+
+ printf("\nThis program should function nearly identically to Mesa's lodbias demo.\n"
+ "It should cycle through the complet LOD bias range once and exit. If bug\n"
+ "#3195 still exists, the demo should crash almost immediatly.\n");
+ printf("This is a regression test for bug #3101.\n");
+ printf("https://bugs.freedesktop.org/show_bug.cgi?id=3101\n");
+
+ if (!glutExtensionSupported("GL_EXT_texture_lod_bias")) {
+ printf("Sorry, GL_EXT_texture_lod_bias not supported by this renderer.\n");
+ exit(1);
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ if (glutExtensionSupported("GL_SGIS_generate_mipmap")) {
+ /* test auto mipmap generation */
+ GLint width, height, i;
+ GLenum format;
+ GLubyte *image = LoadRGBImage(TEXTURE_FILE, &width, &height, &format);
+ if (!image) {
+ printf("Error: could not load texture image %s\n", TEXTURE_FILE);
+ exit(1);
+ }
+ /* resize to 256 x 256 */
+ if (width != 256 || height != 256) {
+ GLubyte *newImage = malloc(256 * 256 * 4);
+ gluScaleImage(format, width, height, GL_UNSIGNED_BYTE, image,
+ 256, 256, GL_UNSIGNED_BYTE, newImage);
+ free(image);
+ image = newImage;
+ }
+ printf("Using GL_SGIS_generate_mipmap\n");
+ glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
+ glTexImage2D(GL_TEXTURE_2D, 0, format, 256, 256, 0,
+ format, GL_UNSIGNED_BYTE, image);
+ free(image);
+
+ /* make sure mipmap was really generated correctly */
+ width = height = 256;
+ for (i = 0; i < 9; i++) {
+ GLint w, h;
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_WIDTH, &w);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_HEIGHT, &h);
+ printf("Level %d size: %d x %d\n", i, w, h);
+ assert(w == width);
+ assert(h == height);
+ width /= 2;
+ height /= 2;
+ }
+
+ }
+ else if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
+ printf("Error: could not load texture image %s\n", TEXTURE_FILE);
+ exit(1);
+ }
+
+ /* mipmapping required for this extension */
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &maxBias);
+ printf("LOD bias range: [%g, %g]\n", -maxBias, maxBias);
+ BiasMin = -100 * maxBias;
+ BiasMax = 100 * maxBias;
+
+ /* Since we have (about) 8 mipmap levels, no need to bias beyond
+ * the range [-1, +8].
+ */
+ if (BiasMin < -100)
+ BiasMin = -100;
+ if (BiasMax > 800)
+ BiasMax = 800;
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 350, 350 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow( "Bug #3195 Test" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/crossbar.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/crossbar.c
new file mode 100644
index 000000000..12aabb1c9
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/crossbar.c
@@ -0,0 +1,235 @@
+/*
+ * (C) Copyright IBM Corporation 2005
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 (including the next
+ * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+/**
+ * \file crossbar.c
+ *
+ * Simple test of GL_ARB_texture_env_crossbar functionality. Several squares
+ * are drawn with different texture combine modes, but all should be rendered
+ * with the same final color.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+
+static const GLint tests[][8] = {
+ { 1, GL_REPLACE, GL_PRIMARY_COLOR, GL_PRIMARY_COLOR,
+ 2, GL_REPLACE, GL_TEXTURE, GL_PRIMARY_COLOR },
+ { 3, GL_REPLACE, GL_PRIMARY_COLOR, GL_PRIMARY_COLOR,
+ 2, GL_SUBTRACT, GL_TEXTURE0, GL_TEXTURE1 },
+ { 2, GL_REPLACE, GL_PRIMARY_COLOR, GL_PRIMARY_COLOR,
+ 2, GL_REPLACE, GL_TEXTURE0, GL_TEXTURE0 },
+ { 2, GL_REPLACE, GL_PRIMARY_COLOR, GL_PRIMARY_COLOR,
+ 1, GL_SUBTRACT, GL_TEXTURE0, GL_TEXTURE1 },
+ { 3, GL_ADD, GL_TEXTURE1, GL_TEXTURE1,
+ 2, GL_MODULATE, GL_TEXTURE1, GL_PREVIOUS },
+ { 3, GL_ADD, GL_TEXTURE1, GL_TEXTURE1,
+ 4, GL_MODULATE, GL_TEXTURE0, GL_PREVIOUS },
+};
+
+#define NUM_TESTS (sizeof(tests) / sizeof(tests[0]))
+
+static int Width = 100 * (NUM_TESTS + 1);
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+ unsigned i;
+
+
+ glClearColor(0.2, 0.2, 0.8, 0);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+
+ /* This is the "reference" square.
+ */
+
+ glActiveTexture( GL_TEXTURE0 );
+ glDisable( GL_TEXTURE_2D );
+ glActiveTexture( GL_TEXTURE1 );
+ glDisable( GL_TEXTURE_2D );
+
+ glTranslatef(-(NUM_TESTS * 1.5), 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ for ( i = 0 ; i < NUM_TESTS ; i++ ) {
+ glActiveTexture( GL_TEXTURE0 );
+ glEnable( GL_TEXTURE_2D );
+ glBindTexture( GL_TEXTURE_2D, tests[i][0] );
+ glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
+ glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, tests[i][1] );
+ glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, tests[i][2] );
+ glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB, tests[i][3] );
+
+ glActiveTexture( GL_TEXTURE1 );
+ glEnable( GL_TEXTURE_2D );
+ glBindTexture( GL_TEXTURE_2D, tests[i][4] );
+ glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
+ glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, tests[i][5] );
+ glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, tests[i][6] );
+ glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB, tests[i][7] );
+
+ glCallList(1);
+ }
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ const char * const ver_string = (const char * const)
+ glGetString( GL_VERSION );
+ float ver = strtof( ver_string, NULL );
+ GLint tex_units;
+ GLint temp[ 256 ];
+
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", ver_string);
+
+ if ( (!glutExtensionSupported("GL_ARB_multitexture")
+ && (ver < 1.3))
+ || (!glutExtensionSupported("GL_ARB_texture_env_combine")
+ && !glutExtensionSupported("GL_EXT_texture_env_combine")
+ && (ver < 1.3))
+ || (!glutExtensionSupported("GL_ARB_texture_env_crossbar")
+ && !glutExtensionSupported("GL_NV_texture_env_combine4")
+ && (ver < 1.4)) ) {
+ printf("\nSorry, this program requires GL_ARB_multitexture and either\n"
+ "GL_ARB_texture_env_combine or GL_EXT_texture_env_combine (or OpenGL 1.3).\n"
+ "Either GL_ARB_texture_env_crossbar or GL_NV_texture_env_combine4 (or\n"
+ "OpenGL 1.4) are also required.\n");
+ exit(1);
+ }
+
+ glGetIntegerv( GL_MAX_TEXTURE_UNITS, & tex_units );
+ if ( tex_units < 2 ) {
+ printf("\nSorry, this program requires at least 2 texture units.\n");
+ exit(1);
+ }
+
+ printf("\nAll %u squares should be the same color.\n", NUM_TESTS + 1);
+
+ (void) memset( temp, 0x00, sizeof( temp ) );
+ glBindTexture( GL_TEXTURE_2D, 1 );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, temp );
+
+ (void) memset( temp, 0x7f, sizeof( temp ) );
+ glBindTexture( GL_TEXTURE_2D, 2 );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, temp );
+
+ (void) memset( temp, 0xff, sizeof( temp ) );
+ glBindTexture( GL_TEXTURE_2D, 3 );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, temp );
+
+ (void) memset( temp, 0x3f, sizeof( temp ) );
+ glBindTexture( GL_TEXTURE_2D, 4 );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, temp );
+
+
+ glNewList( 1, GL_COMPILE );
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.0, 0.0 );
+ glMultiTexCoord2f( GL_TEXTURE0, 0.5, 0.5 );
+ glMultiTexCoord2f( GL_TEXTURE1, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+ glEndList();
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow( "GL_ARB_texture_env_crossbar test" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/cva.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/cva.c
new file mode 100644
index 000000000..3f7960f53
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/cva.c
@@ -0,0 +1,164 @@
+/* $Id: cva.c,v 1.7 2003/12/08 09:03:35 joukj Exp $ */
+
+/*
+ * Trivial CVA test, good for testing driver fastpaths (especially
+ * indexed vertex buffers if they are supported).
+ *
+ * Gareth Hughes
+ * November 2000
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef __VMS
+# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#else
+# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#endif
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#define GL_GLEXT_LEGACY
+#include <GL/glut.h>
+
+
+GLfloat verts[][4] = {
+ { -0.5, -0.5, -2.0, 0.0 },
+ { 0.5, -0.5, -2.0, 0.0 },
+ { -0.5, 0.5, -2.0, 0.0 },
+ { 0.5, 0.5, -2.0, 0.0 },
+};
+
+GLubyte color[][4] = {
+ { 0xff, 0x00, 0x00, 0x00 },
+ { 0x00, 0xff, 0x00, 0x00 },
+ { 0x00, 0x00, 0xff, 0x00 },
+ { 0xff, 0xff, 0xff, 0x00 },
+};
+
+GLuint indices[] = { 0, 1, 2, 3 };
+
+GLboolean compiled = GL_TRUE;
+GLboolean doubleBuffer = GL_TRUE;
+
+
+void init( void )
+{
+ glClearColor( 0.0, 0.0, 0.0, 0.0 );
+ glShadeModel( GL_SMOOTH );
+
+ glFrontFace( GL_CCW );
+ glCullFace( GL_BACK );
+ glEnable( GL_CULL_FACE );
+
+ glEnable( GL_DEPTH_TEST );
+
+ glEnableClientState( GL_VERTEX_ARRAY );
+ glEnableClientState( GL_COLOR_ARRAY );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 2.0, 10.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts );
+ glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color );
+
+#ifdef GL_EXT_compiled_vertex_array
+ if ( compiled ) {
+ glLockArraysEXT( 0, 4 );
+ }
+#endif
+}
+
+void display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices );
+
+ glFlush();
+ if ( doubleBuffer ) {
+ glutSwapBuffers();
+ }
+}
+
+void keyboard( unsigned char key, int x, int y )
+{
+ switch ( key ) {
+ case 27:
+ exit( 0 );
+ break;
+ }
+
+ glutPostRedisplay();
+}
+
+GLboolean args( int argc, char **argv )
+{
+ GLint i;
+
+ doubleBuffer = GL_TRUE;
+
+ for ( i = 1 ; i < argc ; i++ ) {
+ if ( strcmp( argv[i], "-sb" ) == 0 ) {
+ doubleBuffer = GL_FALSE;
+ } else if ( strcmp( argv[i], "-db" ) == 0 ) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf( stderr, "%s (Bad option).\n", argv[i] );
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main( int argc, char **argv )
+{
+ GLenum type;
+ char *string;
+
+ glutInit( &argc, argv );
+
+ if ( args( argc, argv ) == GL_FALSE ) {
+ exit( 1 );
+ }
+
+ type = GLUT_RGB | GLUT_DEPTH;
+ type |= ( doubleBuffer ) ? GLUT_DOUBLE : GLUT_SINGLE;
+
+ glutInitDisplayMode( type );
+ glutInitWindowSize( 250, 250 );
+ glutInitWindowPosition( 100, 100 );
+ glutCreateWindow( "CVA Test" );
+
+ /* Make sure the server supports GL 1.2 vertex arrays.
+ */
+ string = (char *) glGetString( GL_VERSION );
+
+ if ( !strstr(string, "1.2") &&
+ !strstr(string, "1.3") &&
+ !strstr(string, "1.4")) {
+ fprintf( stderr, "This program requires OpenGL 1.2 vertex arrays.\n" );
+ exit( -1 );
+ }
+
+ /* See if the server supports compiled vertex arrays.
+ */
+ string = (char *) glGetString( GL_EXTENSIONS );
+
+ if ( !strstr( string, "GL_EXT_compiled_vertex_array" ) ) {
+ fprintf( stderr, "Compiled vertex arrays not supported by this renderer.\n" );
+ compiled = GL_FALSE;
+ }
+
+ init();
+
+ glutDisplayFunc( display );
+ glutKeyboardFunc( keyboard );
+ glutMainLoop();
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/debugger.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/debugger.c
new file mode 100644
index 000000000..4c6955bcf
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/debugger.c
@@ -0,0 +1,733 @@
+/*
+ * Test the GL_MESA_program_debug extension
+ */
+
+
+#include <assert.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+/*
+ * Print the string with line numbers
+ */
+static void list_program(const GLubyte *string, GLsizei len)
+{
+ const char *c = (const char *) string;
+ int i, line = 1, printNumber = 1;
+
+ for (i = 0; i < len; i++) {
+ if (printNumber) {
+ printf("%3d ", line);
+ printNumber = 0;
+ }
+ if (*c == '\n') {
+ line++;
+ printNumber = 1;
+ }
+ putchar(*c);
+ c++;
+ }
+ putchar('\n');
+}
+
+
+/*
+ * Return the line number and column number that corresponds to the
+ * given program position. Also return a null-terminated copy of that
+ * line of the program string.
+ */
+static const GLubyte *
+find_line_column(const GLubyte *string, const GLubyte *pos,
+ GLint *line, GLint *col)
+{
+ const GLubyte *lineStart = string;
+ const GLubyte *p = string;
+ GLubyte *s;
+ int len;
+
+ *line = 1;
+
+ while (p != pos) {
+ if (*p == (GLubyte) '\n') {
+ (*line)++;
+ lineStart = p + 1;
+ }
+ p++;
+ }
+
+ *col = (pos - lineStart) + 1;
+
+ /* return copy of this line */
+ while (*p != 0 && *p != '\n')
+ p++;
+ len = p - lineStart;
+ s = (GLubyte *) malloc(len + 1);
+ memcpy(s, lineStart, len);
+ s[len] = 0;
+
+ return s;
+}
+
+
+#define ARB_VERTEX_PROGRAM 1
+#define ARB_FRAGMENT_PROGRAM 2
+#define NV_VERTEX_PROGRAM 3
+#define NV_FRAGMENT_PROGRAM 4
+
+
+struct breakpoint {
+ enum {PIXEL, LINE} type;
+ int x, y;
+ int line;
+ GLboolean enabled;
+};
+
+#define MAX_BREAKPOINTS 100
+static struct breakpoint Breakpoints[MAX_BREAKPOINTS];
+static int NumBreakpoints = 0;
+
+
+
+/*
+ * Interactive debugger
+ */
+static void Debugger2(GLenum target, GLvoid *data)
+{
+ static GLuint skipCount = 0;
+ const GLubyte *ln;
+ GLint pos, line, column;
+ GLint id;
+ int progType;
+ GLint len;
+ GLubyte *program;
+ GLboolean stop;
+ int i;
+
+ /* Sigh, GL_VERTEX_PROGRAM_ARB == GL_VERTEX_PROGRAM_NV so it's a bit
+ * hard to distinguish between them.
+ */
+ if (target == GL_FRAGMENT_PROGRAM_ARB)
+ progType = ARB_FRAGMENT_PROGRAM;
+ else if (target == GL_FRAGMENT_PROGRAM_NV)
+ progType = NV_FRAGMENT_PROGRAM;
+ else
+ progType = NV_VERTEX_PROGRAM;
+
+ /* Until we hit zero, continue rendering */
+ if (skipCount > 0) {
+ skipCount--;
+ return;
+ }
+
+ /* Get id of the program and current position */
+ switch (progType) {
+ case ARB_FRAGMENT_PROGRAM:
+ glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &id);
+ glGetIntegerv(GL_FRAGMENT_PROGRAM_POSITION_MESA, &pos);
+ break;
+ case NV_FRAGMENT_PROGRAM:
+ glGetIntegerv(GL_FRAGMENT_PROGRAM_BINDING_NV, &id);
+ glGetIntegerv(GL_FRAGMENT_PROGRAM_POSITION_MESA, &pos);
+ break;
+ case ARB_VERTEX_PROGRAM:
+ glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &id);
+ glGetIntegerv(GL_VERTEX_PROGRAM_POSITION_MESA, &pos);
+ break;
+ case NV_VERTEX_PROGRAM:
+ glGetIntegerv(GL_VERTEX_PROGRAM_BINDING_NV, &id);
+ glGetIntegerv(GL_VERTEX_PROGRAM_POSITION_MESA, &pos);
+ break;
+ default:
+ abort();
+ }
+
+ /* get program string */
+ if (progType == ARB_VERTEX_PROGRAM ||
+ progType == ARB_FRAGMENT_PROGRAM)
+ glGetProgramivARB(target, GL_PROGRAM_LENGTH_ARB, &len);
+ else
+ glGetProgramivNV(id, GL_PROGRAM_LENGTH_NV, &len);
+ program = malloc(len + 1);
+ if (progType == ARB_VERTEX_PROGRAM ||
+ progType == ARB_FRAGMENT_PROGRAM)
+ glGetProgramStringARB(target, GL_PROGRAM_STRING_ARB, program);
+ else
+ glGetProgramStringNV(id, GL_PROGRAM_STRING_NV, program);
+
+
+ /* Get current line number, column, line string */
+ ln = find_line_column(program, program + pos, &line, &column);
+
+ /* test breakpoints */
+ if (NumBreakpoints > 0)
+ stop = GL_FALSE;
+ else
+ stop = GL_TRUE;
+ for (i = 0; i < NumBreakpoints; i++) {
+ if (Breakpoints[i].enabled) {
+ switch (Breakpoints[i].type) {
+ case PIXEL:
+ if (progType == ARB_FRAGMENT_PROGRAM) {
+
+ }
+ else if (progType == NV_FRAGMENT_PROGRAM) {
+ GLfloat pos[4];
+ int px, py;
+ glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV,
+ 6, (GLubyte *) "f[WPOS]", pos);
+ px = (int) pos[0];
+ py = (int) pos[1];
+ printf("%d, %d\n", px, py);
+ if (px == Breakpoints[i].x &&
+ py == Breakpoints[i].y) {
+ printf("Break at pixel (%d, %d)\n", px, py);
+ stop = GL_TRUE;
+ }
+ }
+ break;
+ case LINE:
+ if (line == Breakpoints[i].line) {
+ /* hit a breakpoint! */
+ printf("Break at line %d\n", line);
+ stop = GL_TRUE;
+ }
+ break;
+ }
+ }
+ }
+ if (!stop) {
+ free(program);
+ return;
+ }
+
+ printf("%d: %s\n", line, ln);
+
+ /* get commands from stdin */
+ while (1) {
+ char command[1000], *cmd;
+
+ /* print prompt and get command */
+ printf("(%s %d) ", (target == GL_VERTEX_PROGRAM_ARB ? "vert" : "frag"),
+ line);
+ fgets(command, 999, stdin);
+
+ /* skip leading whitespace */
+ for (cmd = command; cmd[0] == ' '; cmd++)
+ ;
+
+ if (!cmd[0])
+ /* nothing (repeat the previous cmd?) */
+ continue;
+
+ switch (cmd[0]) {
+ case 's':
+ /* skip N instructions */
+ i = atoi(cmd + 2);
+ skipCount = i;
+ printf("Skipping %d instructions\n", i);
+ return;
+ case 'n':
+ /* next */
+ return;
+ case 'c':
+ return;
+ case 'd':
+ /* dump machine state */
+ if (progType == NV_FRAGMENT_PROGRAM) {
+ static const char *inRegs[] = {
+ "f[WPOS]", "f[COL0]", "f[COL1]", "f[FOGC]",
+ "f[TEX0]", "f[TEX1]", "f[TEX2]", "f[TEX3]",
+ NULL
+ };
+ static const char *outRegs[] = {
+ "o[COLR]", "o[COLH]", "o[DEPR]", NULL
+ };
+ GLfloat v[4];
+ int i;
+ printf("Fragment input attributes:\n");
+ for (i = 0; inRegs[i]; i++) {
+ glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV,
+ strlen(inRegs[i]),
+ (const GLubyte *) inRegs[i], v);
+ printf(" %s: %g, %g, %g, %g\n", inRegs[i],
+ v[0], v[1], v[2], v[3]);
+ }
+ printf("Fragment output attributes:\n");
+ for (i = 0; outRegs[i]; i++) {
+ glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV,
+ strlen(outRegs[i]),
+ (const GLubyte *) outRegs[i], v);
+ printf(" %s: %g, %g, %g, %g\n", outRegs[i],
+ v[0], v[1], v[2], v[3]);
+ }
+ printf("Temporaries:\n");
+ for (i = 0; i < 4; i++) {
+ char temp[100];
+ GLfloat v[4];
+ sprintf(temp, "R%d", i);
+ glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV,
+ strlen(temp),
+ (const GLubyte *) temp, v);
+ printf(" %s: %g, %g, %g, %g\n", temp, v[0],v[1],v[2],v[3]);
+ }
+ }
+ else if (progType == NV_VERTEX_PROGRAM) {
+ GLfloat v[4];
+ int i;
+ static const char *inRegs[] = {
+ "v[OPOS]", "v[WGHT]", "v[NRML]", "v[COL0]",
+ "v[COL1]", "v[FOGC]", "v[6]", "v[7]",
+ "v[TEX0]", "v[TEX1]", "v[TEX2]", "v[TEX3]",
+ "v[TEX4]", "v[TEX5]", "v[TEX6]", "v[TEX7]",
+ NULL
+ };
+ static const char *outRegs[] = {
+ "o[HPOS]", "o[COL0]", "o[COL1]", "o[BFC0]",
+ "o[BFC1]", "o[FOGC]", "o[PSIZ]",
+ "o[TEX0]", "o[TEX1]", "o[TEX2]", "o[TEX3]",
+ "o[TEX4]", "o[TEX5]", "o[TEX6]", "o[TEX7]",
+ NULL
+ };
+ printf("Vertex input attributes:\n");
+ for (i = 0; inRegs[i]; i++) {
+ glGetProgramRegisterfvMESA(GL_VERTEX_PROGRAM_NV,
+ strlen(inRegs[i]),
+ (const GLubyte *) inRegs[i], v);
+ printf(" %s: %g, %g, %g, %g\n", inRegs[i],
+ v[0], v[1], v[2], v[3]);
+ }
+ printf("Vertex output attributes:\n");
+ for (i = 0; outRegs[i]; i++) {
+ glGetProgramRegisterfvMESA(GL_VERTEX_PROGRAM_NV,
+ strlen(outRegs[i]),
+ (const GLubyte *) outRegs[i], v);
+ printf(" %s: %g, %g, %g, %g\n", outRegs[i],
+ v[0], v[1], v[2], v[3]);
+ }
+ printf("Temporaries:\n");
+ for (i = 0; i < 4; i++) {
+ char temp[100];
+ GLfloat v[4];
+ sprintf(temp, "R%d", i);
+ glGetProgramRegisterfvMESA(GL_VERTEX_PROGRAM_NV,
+ strlen(temp),
+ (const GLubyte *) temp, v);
+ printf(" %s: %g, %g, %g, %g\n", temp, v[0],v[1],v[2],v[3]);
+ }
+ }
+ break;
+ case 'l':
+ /* list */
+ list_program(program, len);
+ break;
+ case 'p':
+ /* print */
+ {
+ GLfloat v[4];
+ char *c;
+ cmd++;
+ while (*cmd == ' ')
+ cmd++;
+ c = cmd;
+ while (*c) {
+ if (*c == '\n' || *c == '\r')
+ *c = 0;
+ else
+ c++;
+ }
+ glGetProgramRegisterfvMESA(target, strlen(cmd),
+ (const GLubyte *) cmd, v);
+ if (glGetError() == GL_NO_ERROR)
+ printf("%s = %g, %g, %g, %g\n", cmd, v[0], v[1], v[2], v[3]);
+ else
+ printf("Invalid expression\n");
+ }
+ break;
+ case 'b':
+ if (cmd[1] == ' ' && isdigit(cmd[2])) {
+ char *comma = strchr(cmd, ',');
+ if (comma) {
+ /* break at pixel */
+ int x = atoi(cmd + 2);
+ int y = atoi(comma + 1);
+ if (NumBreakpoints < MAX_BREAKPOINTS) {
+ Breakpoints[NumBreakpoints].type = PIXEL;
+ Breakpoints[NumBreakpoints].x = x;
+ Breakpoints[NumBreakpoints].y = y;
+ Breakpoints[NumBreakpoints].enabled = GL_TRUE;
+ NumBreakpoints++;
+ printf("Breakpoint %d: break at pixel (%d, %d)\n",
+ NumBreakpoints, x, y);
+ }
+ }
+ else {
+ /* break at line */
+ int l = atoi(cmd + 2);
+ if (l && NumBreakpoints < MAX_BREAKPOINTS) {
+ Breakpoints[NumBreakpoints].type = LINE;
+ Breakpoints[NumBreakpoints].line = l;
+ Breakpoints[NumBreakpoints].enabled = GL_TRUE;
+ NumBreakpoints++;
+ printf("Breakpoint %d: break at line %d\n",
+ NumBreakpoints, l);
+ }
+ }
+ }
+ else {
+ /* list breakpoints */
+ printf("Breakpoints:\n");
+ for (i = 0; i < NumBreakpoints; i++) {
+ switch (Breakpoints[i].type) {
+ case LINE:
+ printf(" %d: break at line %d\n",
+ i + 1, Breakpoints[i].line);
+ break;
+ case PIXEL:
+ printf(" %d: break at pixel (%d, %d)\n",
+ i + 1, Breakpoints[i].x, Breakpoints[i].y);
+ break;
+ }
+ }
+ }
+ break;
+ case 'h':
+ /* help */
+ printf("Debugger commands:\n");
+ printf(" b list breakpoints\n");
+ printf(" b N break at line N\n");
+ printf(" b x,y break at pixel x,y\n");
+ printf(" c continue execution\n");
+ printf(" d display register values\n");
+ printf(" h help\n");
+ printf(" l list program\n");
+ printf(" n next instruction\n");
+ printf(" p V print value V\n");
+ printf(" s N skip N instructions\n");
+ break;
+ default:
+ printf("Unknown command: %c\n", cmd[0]);
+ }
+ }
+}
+
+
+/*
+ * Print current line, some registers, and continue.
+ */
+static void Debugger(GLenum target, GLvoid *data)
+{
+ GLint pos;
+ const GLubyte *ln;
+ GLint line, column;
+ GLfloat v[4];
+
+ assert(target == GL_FRAGMENT_PROGRAM_NV);
+
+ glGetIntegerv(GL_FRAGMENT_PROGRAM_POSITION_MESA, &pos);
+
+ ln = find_line_column((const GLubyte *) data, (const GLubyte *) data + pos,
+ &line, &column);
+ printf("%d:%d: %s\n", line, column, (char *) ln);
+
+ glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV,
+ 2, (const GLubyte *) "R0", v);
+ printf(" R0 = %g, %g, %g, %g\n", v[0], v[1], v[2], v[3]);
+ glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV,
+ 7, (const GLubyte *) "f[WPOS]", v);
+ printf(" o[WPOS] = %g, %g, %g, %g\n", v[0], v[1], v[2], v[3]);
+ glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV,
+ 7, (const GLubyte *) "o[COLR]", v);
+ printf(" o[COLR] = %g, %g, %g, %g\n", v[0], v[1], v[2], v[3]);
+
+ free((void *) ln);
+}
+
+
+
+
+/**********************************************************************/
+
+static GLfloat Diffuse[4] = { 0.5, 0.5, 1.0, 1.0 };
+static GLfloat Specular[4] = { 0.8, 0.8, 0.8, 1.0 };
+static GLfloat LightPos[4] = { 0.0, 10.0, 20.0, 1.0 };
+static GLfloat Delta = 1.0;
+
+static GLuint FragProg;
+static GLuint VertProg;
+static GLboolean Anim = GL_TRUE;
+static GLboolean Wire = GL_FALSE;
+static GLboolean PixelLight = GL_TRUE;
+
+static GLfloat Xrot = 0, Yrot = 0;
+
+
+#define NAMED_PARAMETER4FV(prog, name, v) \
+ glProgramNamedParameter4fvNV(prog, strlen(name), (const GLubyte *) name, v)
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ if (PixelLight) {
+ NAMED_PARAMETER4FV(FragProg, "LightPos", LightPos);
+ glEnable(GL_FRAGMENT_PROGRAM_NV);
+ glEnable(GL_VERTEX_PROGRAM_NV);
+ glDisable(GL_LIGHTING);
+ }
+ else {
+ glLightfv(GL_LIGHT0, GL_POSITION, LightPos);
+ glDisable(GL_FRAGMENT_PROGRAM_NV);
+ glDisable(GL_VERTEX_PROGRAM_NV);
+ glEnable(GL_LIGHTING);
+ }
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+
+#if 1
+ glutSolidSphere(2.0, 10, 5);
+#else
+ {
+ GLUquadricObj *q = gluNewQuadric();
+ gluQuadricNormals(q, GL_SMOOTH);
+ gluQuadricTexture(q, GL_TRUE);
+ glRotatef(90, 1, 0, 0);
+ glTranslatef(0, 0, -1);
+ gluCylinder(q, 1.0, 1.0, 2.0, 24, 1);
+ gluDeleteQuadric(q);
+ }
+#endif
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Idle(void)
+{
+ LightPos[0] += Delta;
+ if (LightPos[0] > 25.0)
+ Delta = -1.0;
+ else if (LightPos[0] <- 25.0)
+ Delta = 1.0;
+ glutPostRedisplay();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ /*glOrtho( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case ' ':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'x':
+ LightPos[0] -= 1.0;
+ break;
+ case 'X':
+ LightPos[0] += 1.0;
+ break;
+ case 'w':
+ Wire = !Wire;
+ if (Wire)
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ else
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ break;
+ case 'p':
+ PixelLight = !PixelLight;
+ if (PixelLight) {
+ printf("Per-pixel lighting\n");
+ }
+ else {
+ printf("Conventional lighting\n");
+ }
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+static void SpecialKey( int key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( int argc, char *argv[] )
+{
+ static const char *fragProgramText =
+ "!!FP1.0\n"
+ "DECLARE Diffuse; \n"
+ "DECLARE Specular; \n"
+ "DECLARE LightPos; \n"
+
+ "# Compute normalized LightPos, put it in R0\n"
+ "DP3 R0.x, LightPos, LightPos;\n"
+ "RSQ R0.y, R0.x;\n"
+ "MUL R0, LightPos, R0.y;\n"
+
+ "# Compute normalized normal, put it in R1\n"
+ "DP3 R1, f[TEX0], f[TEX0]; \n"
+ "RSQ R1.y, R1.x;\n"
+ "MUL R1, f[TEX0], R1.y;\n"
+
+ "# Compute dot product of light direction and normal vector\n"
+ "DP3 R2, R0, R1;\n"
+
+ "MUL R3, Diffuse, R2; # diffuse attenuation\n"
+
+ "POW R4, R2.x, {20.0}.x; # specular exponent\n"
+
+ "MUL R5, Specular, R4; # specular attenuation\n"
+
+ "ADD o[COLR], R3, R5; # add diffuse and specular colors\n"
+ "END \n"
+ ;
+
+ static const char *vertProgramText =
+ "!!VP1.0\n"
+ "# typical modelview/projection transform\n"
+ "DP4 o[HPOS].x, c[0], v[OPOS] ;\n"
+ "DP4 o[HPOS].y, c[1], v[OPOS] ;\n"
+ "DP4 o[HPOS].z, c[2], v[OPOS] ;\n"
+ "DP4 o[HPOS].w, c[3], v[OPOS] ;\n"
+ "# transform normal by inv transpose of modelview, put in tex0\n"
+ "DP4 o[TEX0].x, c[4], v[NRML] ;\n"
+ "DP4 o[TEX0].y, c[5], v[NRML] ;\n"
+ "DP4 o[TEX0].z, c[6], v[NRML] ;\n"
+ "DP4 o[TEX0].w, c[7], v[NRML] ;\n"
+ "END\n";
+ ;
+
+ if (!glutExtensionSupported("GL_NV_vertex_program")) {
+ printf("Sorry, this demo requires GL_NV_vertex_program\n");
+ exit(1);
+ }
+ if (!glutExtensionSupported("GL_NV_fragment_program")) {
+ printf("Sorry, this demo requires GL_NV_fragment_program\n");
+ exit(1);
+ }
+
+ glGenProgramsNV(1, &FragProg);
+ assert(FragProg > 0);
+ glGenProgramsNV(1, &VertProg);
+ assert(VertProg > 0);
+
+ /*
+ * Fragment program
+ */
+ glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, FragProg,
+ strlen(fragProgramText),
+ (const GLubyte *) fragProgramText);
+ assert(glIsProgramNV(FragProg));
+ glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, FragProg);
+
+ NAMED_PARAMETER4FV(FragProg, "Diffuse", Diffuse);
+ NAMED_PARAMETER4FV(FragProg, "Specular", Specular);
+
+ /*
+ * Vertex program
+ */
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, VertProg,
+ strlen(vertProgramText),
+ (const GLubyte *) vertProgramText);
+ assert(glIsProgramNV(VertProg));
+ glBindProgramNV(GL_VERTEX_PROGRAM_NV, VertProg);
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV);
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV);
+
+ /*
+ * Misc init
+ */
+ glClearColor(0.3, 0.3, 0.3, 0.0);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_LIGHTING);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular);
+ glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 20.0);
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("Press p to toggle between per-pixel and per-vertex lighting\n");
+
+#ifdef GL_MESA_program_debug
+ if (argc > 1 && strcmp(argv[1], "fragment") == 0) {
+ printf(">> Debugging fragment program\n");
+ glProgramCallbackMESA(GL_FRAGMENT_PROGRAM_ARB, Debugger2,
+ (GLvoid *) fragProgramText);
+ glEnable(GL_FRAGMENT_PROGRAM_CALLBACK_MESA);
+ }
+ else {
+ printf(">> Debugging vertex program\n");
+ glProgramCallbackMESA(GL_VERTEX_PROGRAM_ARB, Debugger2,
+ (GLvoid *) fragProgramText);
+ glEnable(GL_VERTEX_PROGRAM_CALLBACK_MESA);
+ }
+#endif
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 200, 200 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init(argc, argv);
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/descrip.mms b/nx-X11/extras/Mesa_6.4.2/progs/tests/descrip.mms
new file mode 100644
index 000000000..b0ff2610d
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/descrip.mms
@@ -0,0 +1,84 @@
+# Makefile for GLUT-based demo programs for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+
+
+.first
+ define gl [--.include.gl]
+
+.include [--]mms-config.
+
+##### MACROS #####
+
+INCDIR = ([--.include],[-.util])
+CFLAGS = /include=$(INCDIR)/prefix=all/name=(as_is,short)
+
+.ifdef SHARE
+GL_LIBS = $(XLIBS)
+.else
+GL_LIBS = [--.lib]libGLUT/l,libMesaGLU/l,libMesaGL/l,$(XLIBS)
+.endif
+
+LIB_DEP = [--.lib]$(GL_LIB) [--.lib]$(GLU_LIB) [--.lib]$(GLUT_LIB)
+
+PROGS = cva.exe,\
+ dinoshade.exe,\
+ fogcoord.exe,\
+ manytex.exe,\
+ multipal.exe,\
+ projtex.exe,\
+ seccolor.exe,\
+ sharedtex.exe,\
+ texline.exe,\
+ texwrap.exe,\
+ vptest1.exe,\
+ vptest2.exe,\
+ vptest3.exe,\
+ vptorus.exe,\
+ vpwarpmesh.exe
+
+##### RULES #####
+.obj.exe :
+ cxxlink $(MMS$TARGET_NAME),$(GL_LIBS)
+
+##### TARGETS #####
+default :
+ $(MMS)$(MMSQUALIFIERS) $(PROGS)
+
+clean :
+ delete *.obj;*
+
+realclean :
+ delete $(PROGS)
+ delete *.obj;*
+
+cva.exe : cva.obj $(LIB_DEP)
+dinoshade.exe : dinoshade.obj $(LIB_DEP)
+fogcoord.exe : fogcoord.obj $(LIB_DEP)
+manytex.exe : manytex.obj $(LIB_DEP)
+multipal.exe : multipal.obj $(LIB_DEP)
+projtex.exe : projtex.obj $(LIB_DEP)
+seccolor.exe : seccolor.obj $(LIB_DEP)
+sharedtex.exe : sharedtex.obj $(LIB_DEP)
+texline.exe : texline.obj $(LIB_DEP)
+texwrap.exe : texwrap.obj $(LIB_DEP)
+vptest1.exe : vptest1.obj $(LIB_DEP)
+vptest2.exe : vptest2.obj $(LIB_DEP)
+vptest3.exe : vptest3.obj $(LIB_DEP)
+vptorus.exe : vptorus.obj $(LIB_DEP)
+vpwarpmesh.exe : vpwarpmesh.obj $(LIB_DEP)
+
+cva.obj : cva.c
+dinoshade.obj : dinoshade.c
+fogcoord.obj : fogcoord.c
+manytex.obj : manytex.c
+multipal.obj : multipal.c
+projtex.obj : projtex.c
+seccolor.obj : seccolor.c
+sharedtex.obj : sharedtex.c
+texline.obj : texline.c
+texwrap.obj : texwrap.c
+vptest1.obj : vptest1.c
+vptest2.obj : vptest2.c
+vptest3.obj : vptest3.c
+vptorus.obj : vptorus.c
+vpwarpmesh.obj : vpwarpmesh.c
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/dinoshade.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/dinoshade.c
new file mode 100644
index 000000000..ed7b879bc
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/dinoshade.c
@@ -0,0 +1,914 @@
+
+/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+/* Example for PC game developers to show how to *combine* texturing,
+ reflections, and projected shadows all in real-time with OpenGL.
+ Robust reflections use stenciling. Robust projected shadows
+ use both stenciling and polygon offset. PC game programmers
+ should realize that neither stenciling nor polygon offset are
+ supported by Direct3D, so these real-time rendering algorithms
+ are only really viable with OpenGL.
+
+ The program has modes for disabling the stenciling and polygon
+ offset uses. It is worth running this example with these features
+ toggled off so you can see the sort of artifacts that result.
+
+ Notice that the floor texturing, reflections, and shadowing
+ all co-exist properly. */
+
+/* When you run this program: Left mouse button controls the
+ view. Middle mouse button controls light position (left &
+ right rotates light around dino; up & down moves light
+ position up and down). Right mouse button pops up menu. */
+
+/* Check out the comments in the "redraw" routine to see how the
+ reflection blending and surface stenciling is done. You can
+ also see in "redraw" how the projected shadows are rendered,
+ including the use of stenciling and polygon offset. */
+
+/* This program is derived from glutdino.c */
+
+/* Compile: cc -o dinoshade dinoshade.c -lglut -lGLU -lGL -lXmu -lXext -lX11 -lm */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h> /* for cos(), sin(), and sqrt() */
+#ifdef __VMS
+# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#else
+# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#endif
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#define GL_GLEXT_LEGACY
+#include <GL/glut.h> /* OpenGL Utility Toolkit header */
+
+/* Some <math.h> files do not define M_PI... */
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+/* Variable controlling various rendering modes. */
+static int stencilReflection = 1, stencilShadow = 1, offsetShadow = 1;
+static int renderShadow = 1, renderDinosaur = 1, renderReflection = 1;
+static int linearFiltering = 0, useMipmaps = 0, useTexture = 1;
+static int reportSpeed = 0;
+static int animation = 1;
+static GLboolean lightSwitch = GL_TRUE;
+static int directionalLight = 1;
+static int forceExtension = 0;
+
+/* Time varying or user-controled variables. */
+static float jump = 0.0;
+static float lightAngle = 0.0, lightHeight = 20;
+GLfloat angle = -150; /* in degrees */
+GLfloat angle2 = 30; /* in degrees */
+
+int moving, startx, starty;
+int lightMoving = 0, lightStartX, lightStartY;
+
+enum {
+ MISSING, EXTENSION, ONE_DOT_ONE
+};
+int polygonOffsetVersion;
+
+static GLdouble bodyWidth = 3.0;
+/* *INDENT-OFF* */
+static GLfloat body[][2] = { {0, 3}, {1, 1}, {5, 1}, {8, 4}, {10, 4}, {11, 5},
+ {11, 11.5}, {13, 12}, {13, 13}, {10, 13.5}, {13, 14}, {13, 15}, {11, 16},
+ {8, 16}, {7, 15}, {7, 13}, {8, 12}, {7, 11}, {6, 6}, {4, 3}, {3, 2},
+ {1, 2} };
+static GLfloat arm[][2] = { {8, 10}, {9, 9}, {10, 9}, {13, 8}, {14, 9}, {16, 9},
+ {15, 9.5}, {16, 10}, {15, 10}, {15.5, 11}, {14.5, 10}, {14, 11}, {14, 10},
+ {13, 9}, {11, 11}, {9, 11} };
+static GLfloat leg[][2] = { {8, 6}, {8, 4}, {9, 3}, {9, 2}, {8, 1}, {8, 0.5}, {9, 0},
+ {12, 0}, {10, 1}, {10, 2}, {12, 4}, {11, 6}, {10, 7}, {9, 7} };
+static GLfloat eye[][2] = { {8.75, 15}, {9, 14.7}, {9.6, 14.7}, {10.1, 15},
+ {9.6, 15.25}, {9, 15.25} };
+static GLfloat lightPosition[4];
+static GLfloat lightColor[] = {0.8, 1.0, 0.8, 1.0}; /* green-tinted */
+static GLfloat skinColor[] = {0.1, 1.0, 0.1, 1.0}, eyeColor[] = {1.0, 0.2, 0.2, 1.0};
+/* *INDENT-ON* */
+
+/* Nice floor texture tiling pattern. */
+static char *circles[] = {
+ "....xxxx........",
+ "..xxxxxxxx......",
+ ".xxxxxxxxxx.....",
+ ".xxx....xxx.....",
+ "xxx......xxx....",
+ "xxx......xxx....",
+ "xxx......xxx....",
+ "xxx......xxx....",
+ ".xxx....xxx.....",
+ ".xxxxxxxxxx.....",
+ "..xxxxxxxx......",
+ "....xxxx........",
+ "................",
+ "................",
+ "................",
+ "................",
+};
+
+static void
+makeFloorTexture(void)
+{
+ GLubyte floorTexture[16][16][3];
+ GLubyte *loc;
+ int s, t;
+
+ /* Setup RGB image for the texture. */
+ loc = (GLubyte*) floorTexture;
+ for (t = 0; t < 16; t++) {
+ for (s = 0; s < 16; s++) {
+ if (circles[t][s] == 'x') {
+ /* Nice green. */
+ loc[0] = 0x1f;
+ loc[1] = 0x8f;
+ loc[2] = 0x1f;
+ } else {
+ /* Light gray. */
+ loc[0] = 0xaa;
+ loc[1] = 0xaa;
+ loc[2] = 0xaa;
+ }
+ loc += 3;
+ }
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ if (useMipmaps) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_LINEAR);
+ gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 16, 16,
+ GL_RGB, GL_UNSIGNED_BYTE, floorTexture);
+ } else {
+ if (linearFiltering) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ } else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ }
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, 16, 16, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, floorTexture);
+ }
+}
+
+enum {
+ X, Y, Z, W
+};
+enum {
+ A, B, C, D
+};
+
+/* Create a matrix that will project the desired shadow. */
+void
+shadowMatrix(GLfloat shadowMat[4][4],
+ GLfloat groundplane[4],
+ GLfloat lightpos[4])
+{
+ GLfloat dot;
+
+ /* Find dot product between light position vector and ground plane normal. */
+ dot = groundplane[X] * lightpos[X] +
+ groundplane[Y] * lightpos[Y] +
+ groundplane[Z] * lightpos[Z] +
+ groundplane[W] * lightpos[W];
+
+ shadowMat[0][0] = dot - lightpos[X] * groundplane[X];
+ shadowMat[1][0] = 0.f - lightpos[X] * groundplane[Y];
+ shadowMat[2][0] = 0.f - lightpos[X] * groundplane[Z];
+ shadowMat[3][0] = 0.f - lightpos[X] * groundplane[W];
+
+ shadowMat[X][1] = 0.f - lightpos[Y] * groundplane[X];
+ shadowMat[1][1] = dot - lightpos[Y] * groundplane[Y];
+ shadowMat[2][1] = 0.f - lightpos[Y] * groundplane[Z];
+ shadowMat[3][1] = 0.f - lightpos[Y] * groundplane[W];
+
+ shadowMat[X][2] = 0.f - lightpos[Z] * groundplane[X];
+ shadowMat[1][2] = 0.f - lightpos[Z] * groundplane[Y];
+ shadowMat[2][2] = dot - lightpos[Z] * groundplane[Z];
+ shadowMat[3][2] = 0.f - lightpos[Z] * groundplane[W];
+
+ shadowMat[X][3] = 0.f - lightpos[W] * groundplane[X];
+ shadowMat[1][3] = 0.f - lightpos[W] * groundplane[Y];
+ shadowMat[2][3] = 0.f - lightpos[W] * groundplane[Z];
+ shadowMat[3][3] = dot - lightpos[W] * groundplane[W];
+
+}
+
+/* Find the plane equation given 3 points. */
+void
+findPlane(GLfloat plane[4],
+ GLfloat v0[3], GLfloat v1[3], GLfloat v2[3])
+{
+ GLfloat vec0[3], vec1[3];
+
+ /* Need 2 vectors to find cross product. */
+ vec0[X] = v1[X] - v0[X];
+ vec0[Y] = v1[Y] - v0[Y];
+ vec0[Z] = v1[Z] - v0[Z];
+
+ vec1[X] = v2[X] - v0[X];
+ vec1[Y] = v2[Y] - v0[Y];
+ vec1[Z] = v2[Z] - v0[Z];
+
+ /* find cross product to get A, B, and C of plane equation */
+ plane[A] = vec0[Y] * vec1[Z] - vec0[Z] * vec1[Y];
+ plane[B] = -(vec0[X] * vec1[Z] - vec0[Z] * vec1[X]);
+ plane[C] = vec0[X] * vec1[Y] - vec0[Y] * vec1[X];
+
+ plane[D] = -(plane[A] * v0[X] + plane[B] * v0[Y] + plane[C] * v0[Z]);
+}
+
+void
+extrudeSolidFromPolygon(GLfloat data[][2], unsigned int dataSize,
+ GLdouble thickness, GLuint side, GLuint edge, GLuint whole)
+{
+ static GLUtriangulatorObj *tobj = NULL;
+ GLdouble vertex[3], dx, dy, len;
+ int i;
+ int count = (int) (dataSize / (2 * sizeof(GLfloat)));
+
+ if (tobj == NULL) {
+ tobj = gluNewTess(); /* create and initialize a GLU
+ polygon tesselation object */
+ gluTessCallback(tobj, GLU_BEGIN, glBegin);
+ gluTessCallback(tobj, GLU_VERTEX, glVertex2fv); /* semi-tricky */
+ gluTessCallback(tobj, GLU_END, glEnd);
+ }
+ glNewList(side, GL_COMPILE);
+ glShadeModel(GL_SMOOTH); /* smooth minimizes seeing
+ tessellation */
+ gluBeginPolygon(tobj);
+ for (i = 0; i < count; i++) {
+ vertex[0] = data[i][0];
+ vertex[1] = data[i][1];
+ vertex[2] = 0;
+ gluTessVertex(tobj, vertex, data[i]);
+ }
+ gluEndPolygon(tobj);
+ glEndList();
+ glNewList(edge, GL_COMPILE);
+ glShadeModel(GL_FLAT); /* flat shade keeps angular hands
+ from being "smoothed" */
+ glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= count; i++) {
+#if 1 /* weird, but seems to be legal */
+ /* mod function handles closing the edge */
+ glVertex3f(data[i % count][0], data[i % count][1], 0.0);
+ glVertex3f(data[i % count][0], data[i % count][1], thickness);
+ /* Calculate a unit normal by dividing by Euclidean
+ distance. We * could be lazy and use
+ glEnable(GL_NORMALIZE) so we could pass in * arbitrary
+ normals for a very slight performance hit. */
+ dx = data[(i + 1) % count][1] - data[i % count][1];
+ dy = data[i % count][0] - data[(i + 1) % count][0];
+ len = sqrt(dx * dx + dy * dy);
+ glNormal3f(dx / len, dy / len, 0.0);
+#else /* the nice way of doing it */
+ /* Calculate a unit normal by dividing by Euclidean
+ distance. We * could be lazy and use
+ glEnable(GL_NORMALIZE) so we could pass in * arbitrary
+ normals for a very slight performance hit. */
+ dx = data[i % count][1] - data[(i - 1 + count) % count][1];
+ dy = data[(i - 1 + count) % count][0] - data[i % count][0];
+ len = sqrt(dx * dx + dy * dy);
+ glNormal3f(dx / len, dy / len, 0.0);
+ /* mod function handles closing the edge */
+ glVertex3f(data[i % count][0], data[i % count][1], 0.0);
+ glVertex3f(data[i % count][0], data[i % count][1], thickness);
+#endif
+ }
+ glEnd();
+ glEndList();
+ glNewList(whole, GL_COMPILE);
+ glFrontFace(GL_CW);
+ glCallList(edge);
+ glNormal3f(0.0, 0.0, -1.0); /* constant normal for side */
+ glCallList(side);
+ glPushMatrix();
+ glTranslatef(0.0, 0.0, thickness);
+ glFrontFace(GL_CCW);
+ glNormal3f(0.0, 0.0, 1.0); /* opposite normal for other side */
+ glCallList(side);
+ glPopMatrix();
+ glEndList();
+}
+
+/* Enumerants for refering to display lists. */
+typedef enum {
+ RESERVED, BODY_SIDE, BODY_EDGE, BODY_WHOLE, ARM_SIDE, ARM_EDGE, ARM_WHOLE,
+ LEG_SIDE, LEG_EDGE, LEG_WHOLE, EYE_SIDE, EYE_EDGE, EYE_WHOLE
+} displayLists;
+
+static void
+makeDinosaur(void)
+{
+ extrudeSolidFromPolygon(body, sizeof(body), bodyWidth,
+ BODY_SIDE, BODY_EDGE, BODY_WHOLE);
+ extrudeSolidFromPolygon(arm, sizeof(arm), bodyWidth / 4,
+ ARM_SIDE, ARM_EDGE, ARM_WHOLE);
+ extrudeSolidFromPolygon(leg, sizeof(leg), bodyWidth / 2,
+ LEG_SIDE, LEG_EDGE, LEG_WHOLE);
+ extrudeSolidFromPolygon(eye, sizeof(eye), bodyWidth + 0.2,
+ EYE_SIDE, EYE_EDGE, EYE_WHOLE);
+}
+
+static void
+drawDinosaur(void)
+
+{
+ glPushMatrix();
+ /* Translate the dinosaur to be at (0,8,0). */
+ glTranslatef(-8, 0, -bodyWidth / 2);
+ glTranslatef(0.0, jump, 0.0);
+ glMaterialfv(GL_FRONT, GL_DIFFUSE, skinColor);
+ glCallList(BODY_WHOLE);
+ glTranslatef(0.0, 0.0, bodyWidth);
+ glCallList(ARM_WHOLE);
+ glCallList(LEG_WHOLE);
+ glTranslatef(0.0, 0.0, -bodyWidth - bodyWidth / 4);
+ glCallList(ARM_WHOLE);
+ glTranslatef(0.0, 0.0, -bodyWidth / 4);
+ glCallList(LEG_WHOLE);
+ glTranslatef(0.0, 0.0, bodyWidth / 2 - 0.1);
+ glMaterialfv(GL_FRONT, GL_DIFFUSE, eyeColor);
+ glCallList(EYE_WHOLE);
+ glPopMatrix();
+}
+
+static GLfloat floorVertices[4][3] = {
+ { -20.0, 0.0, 20.0 },
+ { 20.0, 0.0, 20.0 },
+ { 20.0, 0.0, -20.0 },
+ { -20.0, 0.0, -20.0 },
+};
+
+/* Draw a floor (possibly textured). */
+static void
+drawFloor(void)
+{
+ glDisable(GL_LIGHTING);
+
+ if (useTexture) {
+ glEnable(GL_TEXTURE_2D);
+ }
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0);
+ glVertex3fv(floorVertices[0]);
+ glTexCoord2f(0.0, 16.0);
+ glVertex3fv(floorVertices[1]);
+ glTexCoord2f(16.0, 16.0);
+ glVertex3fv(floorVertices[2]);
+ glTexCoord2f(16.0, 0.0);
+ glVertex3fv(floorVertices[3]);
+ glEnd();
+
+ if (useTexture) {
+ glDisable(GL_TEXTURE_2D);
+ }
+
+ glEnable(GL_LIGHTING);
+}
+
+static GLfloat floorPlane[4];
+static GLfloat floorShadow[4][4];
+
+static void
+redraw(void)
+{
+ int start, end;
+
+ if (reportSpeed) {
+ start = glutGet(GLUT_ELAPSED_TIME);
+ }
+
+ /* Clear; default stencil clears to zero. */
+ if ((stencilReflection && renderReflection) || (stencilShadow && renderShadow)) {
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ } else {
+ /* Avoid clearing stencil when not using it. */
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ }
+
+ /* Reposition the light source. */
+ lightPosition[0] = 12*cos(lightAngle);
+ lightPosition[1] = lightHeight;
+ lightPosition[2] = 12*sin(lightAngle);
+ if (directionalLight) {
+ lightPosition[3] = 0.0;
+ } else {
+ lightPosition[3] = 1.0;
+ }
+
+ shadowMatrix(floorShadow, floorPlane, lightPosition);
+
+ glPushMatrix();
+ /* Perform scene rotations based on user mouse input. */
+ glRotatef(angle2, 1.0, 0.0, 0.0);
+ glRotatef(angle, 0.0, 1.0, 0.0);
+
+ /* Tell GL new light source position. */
+ glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
+
+ if (renderReflection) {
+ if (stencilReflection) {
+ /* We can eliminate the visual "artifact" of seeing the "flipped"
+ dinosaur underneath the floor by using stencil. The idea is
+ draw the floor without color or depth update but so that
+ a stencil value of one is where the floor will be. Later when
+ rendering the dinosaur reflection, we will only update pixels
+ with a stencil value of 1 to make sure the reflection only
+ lives on the floor, not below the floor. */
+
+ /* Don't update color or depth. */
+ glDisable(GL_DEPTH_TEST);
+ glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+
+ /* Draw 1 into the stencil buffer. */
+ glEnable(GL_STENCIL_TEST);
+ glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ glStencilFunc(GL_ALWAYS, 1, 0xffffffff);
+
+ /* Now render floor; floor pixels just get their stencil set to 1. */
+ drawFloor();
+
+ /* Re-enable update of color and depth. */
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glEnable(GL_DEPTH_TEST);
+
+ /* Now, only render where stencil is set to 1. */
+ glStencilFunc(GL_EQUAL, 1, 0xffffffff); /* draw if ==1 */
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ }
+
+ glPushMatrix();
+
+ /* The critical reflection step: Reflect dinosaur through the floor
+ (the Y=0 plane) to make a relection. */
+ glScalef(1.0, -1.0, 1.0);
+
+ /* Reflect the light position. */
+ glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
+
+ /* To avoid our normals getting reversed and hence botched lighting
+ on the reflection, turn on normalize. */
+ glEnable(GL_NORMALIZE);
+ glCullFace(GL_FRONT);
+
+ /* Draw the reflected dinosaur. */
+ drawDinosaur();
+
+ /* Disable noramlize again and re-enable back face culling. */
+ glDisable(GL_NORMALIZE);
+ glCullFace(GL_BACK);
+
+ glPopMatrix();
+
+ /* Switch back to the unreflected light position. */
+ glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
+
+ if (stencilReflection) {
+ glDisable(GL_STENCIL_TEST);
+ }
+ }
+
+ /* Back face culling will get used to only draw either the top or the
+ bottom floor. This let's us get a floor with two distinct
+ appearances. The top floor surface is reflective and kind of red.
+ The bottom floor surface is not reflective and blue. */
+
+ /* Draw "bottom" of floor in blue. */
+ glFrontFace(GL_CW); /* Switch face orientation. */
+ glColor4f(0.1, 0.1, 0.7, 1.0);
+ drawFloor();
+ glFrontFace(GL_CCW);
+
+ if (renderShadow) {
+ if (stencilShadow) {
+ /* Draw the floor with stencil value 3. This helps us only
+ draw the shadow once per floor pixel (and only on the
+ floor pixels). */
+ glEnable(GL_STENCIL_TEST);
+ glStencilFunc(GL_ALWAYS, 3, 0xffffffff);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+ }
+ }
+
+ /* Draw "top" of floor. Use blending to blend in reflection. */
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4f(0.7, 0.0, 0.0, 0.3);
+ glColor4f(1.0, 1.0, 1.0, 0.3);
+ drawFloor();
+ glDisable(GL_BLEND);
+
+ if (renderDinosaur) {
+ /* Draw "actual" dinosaur, not its reflection. */
+ drawDinosaur();
+ }
+
+ if (renderShadow) {
+
+ /* Render the projected shadow. */
+
+ if (stencilShadow) {
+
+ /* Now, only render where stencil is set above 2 (ie, 3 where
+ the top floor is). Update stencil with 2 where the shadow
+ gets drawn so we don't redraw (and accidently reblend) the
+ shadow). */
+ glStencilFunc(GL_LESS, 2, 0xffffffff); /* draw if ==1 */
+ glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ }
+
+ /* To eliminate depth buffer artifacts, we use polygon offset
+ to raise the depth of the projected shadow slightly so
+ that it does not depth buffer alias with the floor. */
+ if (offsetShadow) {
+ switch (polygonOffsetVersion) {
+ case EXTENSION:
+#ifdef GL_EXT_polygon_offset
+ glEnable(GL_POLYGON_OFFSET_EXT);
+ break;
+#endif
+#ifdef GL_VERSION_1_1
+ case ONE_DOT_ONE:
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ break;
+#endif
+ case MISSING:
+ /* Oh well. */
+ break;
+ }
+ }
+
+ /* Render 50% black shadow color on top of whatever the
+ floor appareance is. */
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_LIGHTING); /* Force the 50% black. */
+ glColor4f(0.0, 0.0, 0.0, 0.5);
+
+ glPushMatrix();
+ /* Project the shadow. */
+ glMultMatrixf((GLfloat *) floorShadow);
+ drawDinosaur();
+ glPopMatrix();
+
+ glDisable(GL_BLEND);
+ glEnable(GL_LIGHTING);
+
+ if (offsetShadow) {
+ switch (polygonOffsetVersion) {
+#ifdef GL_EXT_polygon_offset
+ case EXTENSION:
+ glDisable(GL_POLYGON_OFFSET_EXT);
+ break;
+#endif
+#ifdef GL_VERSION_1_1
+ case ONE_DOT_ONE:
+ glDisable(GL_POLYGON_OFFSET_FILL);
+ break;
+#endif
+ case MISSING:
+ /* Oh well. */
+ break;
+ }
+ }
+ if (stencilShadow) {
+ glDisable(GL_STENCIL_TEST);
+ }
+ }
+
+ glPushMatrix();
+ glDisable(GL_LIGHTING);
+ glColor3f(1.0, 1.0, 0.0);
+ if (directionalLight) {
+ /* Draw an arrowhead. */
+ glDisable(GL_CULL_FACE);
+ glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);
+ glRotatef(lightAngle * -180.0 / M_PI, 0, 1, 0);
+ glRotatef(atan(lightHeight/12) * 180.0 / M_PI, 0, 0, 1);
+ glBegin(GL_TRIANGLE_FAN);
+ glVertex3f(0, 0, 0);
+ glVertex3f(2, 1, 1);
+ glVertex3f(2, -1, 1);
+ glVertex3f(2, -1, -1);
+ glVertex3f(2, 1, -1);
+ glVertex3f(2, 1, 1);
+ glEnd();
+ /* Draw a white line from light direction. */
+ glColor3f(1.0, 1.0, 1.0);
+ glBegin(GL_LINES);
+ glVertex3f(0, 0, 0);
+ glVertex3f(5, 0, 0);
+ glEnd();
+ glEnable(GL_CULL_FACE);
+ } else {
+ /* Draw a yellow ball at the light source. */
+ glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);
+ glutSolidSphere(1.0, 5, 5);
+ }
+ glEnable(GL_LIGHTING);
+ glPopMatrix();
+
+ glPopMatrix();
+
+ if (reportSpeed) {
+ glFinish();
+ end = glutGet(GLUT_ELAPSED_TIME);
+ printf("Speed %.3g frames/sec (%d ms)\n", 1000.0/(end-start), end-start);
+ }
+
+ glutSwapBuffers();
+}
+
+/* ARGSUSED2 */
+static void
+mouse(int button, int state, int x, int y)
+{
+ if (button == GLUT_LEFT_BUTTON) {
+ if (state == GLUT_DOWN) {
+ moving = 1;
+ startx = x;
+ starty = y;
+ }
+ if (state == GLUT_UP) {
+ moving = 0;
+ }
+ }
+ if (button == GLUT_MIDDLE_BUTTON) {
+ if (state == GLUT_DOWN) {
+ lightMoving = 1;
+ lightStartX = x;
+ lightStartY = y;
+ }
+ if (state == GLUT_UP) {
+ lightMoving = 0;
+ }
+ }
+}
+
+/* ARGSUSED1 */
+static void
+motion(int x, int y)
+{
+ if (moving) {
+ angle = angle + (x - startx);
+ angle2 = angle2 + (y - starty);
+ startx = x;
+ starty = y;
+ glutPostRedisplay();
+ }
+ if (lightMoving) {
+ lightAngle += (x - lightStartX)/40.0;
+ lightHeight += (lightStartY - y)/20.0;
+ lightStartX = x;
+ lightStartY = y;
+ glutPostRedisplay();
+ }
+}
+
+/* Advance time varying state when idle callback registered. */
+static void
+idle(void)
+{
+ static float time = 0.0;
+
+ time = glutGet(GLUT_ELAPSED_TIME) / 500.0;
+
+ jump = 4.0 * fabs(sin(time)*0.5);
+ if (!lightMoving) {
+ lightAngle += 0.03;
+ }
+ glutPostRedisplay();
+}
+
+enum {
+ M_NONE, M_MOTION, M_LIGHT, M_TEXTURE, M_SHADOWS, M_REFLECTION, M_DINOSAUR,
+ M_STENCIL_REFLECTION, M_STENCIL_SHADOW, M_OFFSET_SHADOW,
+ M_POSITIONAL, M_DIRECTIONAL, M_PERFORMANCE
+};
+
+static void
+controlLights(int value)
+{
+ switch (value) {
+ case M_NONE:
+ return;
+ case M_MOTION:
+ animation = 1 - animation;
+ if (animation) {
+ glutIdleFunc(idle);
+ } else {
+ glutIdleFunc(NULL);
+ }
+ break;
+ case M_LIGHT:
+ lightSwitch = !lightSwitch;
+ if (lightSwitch) {
+ glEnable(GL_LIGHT0);
+ } else {
+ glDisable(GL_LIGHT0);
+ }
+ break;
+ case M_TEXTURE:
+ useTexture = !useTexture;
+ break;
+ case M_SHADOWS:
+ renderShadow = 1 - renderShadow;
+ break;
+ case M_REFLECTION:
+ renderReflection = 1 - renderReflection;
+ break;
+ case M_DINOSAUR:
+ renderDinosaur = 1 - renderDinosaur;
+ break;
+ case M_STENCIL_REFLECTION:
+ stencilReflection = 1 - stencilReflection;
+ break;
+ case M_STENCIL_SHADOW:
+ stencilShadow = 1 - stencilShadow;
+ break;
+ case M_OFFSET_SHADOW:
+ offsetShadow = 1 - offsetShadow;
+ break;
+ case M_POSITIONAL:
+ directionalLight = 0;
+ break;
+ case M_DIRECTIONAL:
+ directionalLight = 1;
+ break;
+ case M_PERFORMANCE:
+ reportSpeed = 1 - reportSpeed;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+/* When not visible, stop animating. Restart when visible again. */
+static void
+visible(int vis)
+{
+ if (vis == GLUT_VISIBLE) {
+ if (animation)
+ glutIdleFunc(idle);
+ } else {
+ if (!animation)
+ glutIdleFunc(NULL);
+ }
+}
+
+/* Press any key to redraw; good when motion stopped and
+ performance reporting on. */
+/* ARGSUSED */
+static void
+key(unsigned char c, int x, int y)
+{
+ if (c == 27) {
+ exit(0); /* IRIS GLism, Escape quits. */
+ }
+ glutPostRedisplay();
+}
+
+/* Press any key to redraw; good when motion stopped and
+ performance reporting on. */
+/* ARGSUSED */
+static void
+special(int k, int x, int y)
+{
+ glutPostRedisplay();
+}
+
+static int
+supportsOneDotOne(void)
+{
+ const char *version;
+ int major, minor;
+
+ version = (char *) glGetString(GL_VERSION);
+ if (sscanf(version, "%d.%d", &major, &minor) == 2)
+ return major >= 1 && minor >= 1;
+ return 0; /* OpenGL version string malformed! */
+}
+
+int
+main(int argc, char **argv)
+{
+ int i;
+
+ glutInit(&argc, argv);
+
+ for (i=1; i<argc; i++) {
+ if (!strcmp("-linear", argv[i])) {
+ linearFiltering = 1;
+ } else if (!strcmp("-mipmap", argv[i])) {
+ useMipmaps = 1;
+ } else if (!strcmp("-ext", argv[i])) {
+ forceExtension = 1;
+ }
+ }
+
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);
+
+#if 0
+ /* In GLUT 4.0, you'll be able to do this an be sure to
+ get 2 bits of stencil if the machine has it for you. */
+ glutInitDisplayString("samples stencil>=2 rgb double depth");
+#endif
+
+ glutCreateWindow("Shadowy Leapin' Lizards");
+
+ if (glutGet(GLUT_WINDOW_STENCIL_SIZE) <= 1) {
+ printf("dinoshade: Sorry, I need at least 2 bits of stencil.\n");
+ exit(1);
+ }
+
+ /* Register GLUT callbacks. */
+ glutDisplayFunc(redraw);
+ glutMouseFunc(mouse);
+ glutMotionFunc(motion);
+ glutVisibilityFunc(visible);
+ glutKeyboardFunc(key);
+ glutSpecialFunc(special);
+
+ glutCreateMenu(controlLights);
+
+ glutAddMenuEntry("Toggle motion", M_MOTION);
+ glutAddMenuEntry("-----------------------", M_NONE);
+ glutAddMenuEntry("Toggle light", M_LIGHT);
+ glutAddMenuEntry("Toggle texture", M_TEXTURE);
+ glutAddMenuEntry("Toggle shadows", M_SHADOWS);
+ glutAddMenuEntry("Toggle reflection", M_REFLECTION);
+ glutAddMenuEntry("Toggle dinosaur", M_DINOSAUR);
+ glutAddMenuEntry("-----------------------", M_NONE);
+ glutAddMenuEntry("Toggle reflection stenciling", M_STENCIL_REFLECTION);
+ glutAddMenuEntry("Toggle shadow stenciling", M_STENCIL_SHADOW);
+ glutAddMenuEntry("Toggle shadow offset", M_OFFSET_SHADOW);
+ glutAddMenuEntry("----------------------", M_NONE);
+ glutAddMenuEntry("Positional light", M_POSITIONAL);
+ glutAddMenuEntry("Directional light", M_DIRECTIONAL);
+ glutAddMenuEntry("-----------------------", M_NONE);
+ glutAddMenuEntry("Toggle performance", M_PERFORMANCE);
+ glutAttachMenu(GLUT_RIGHT_BUTTON);
+ makeDinosaur();
+
+#ifdef GL_VERSION_1_1
+ if (supportsOneDotOne() && !forceExtension) {
+ polygonOffsetVersion = ONE_DOT_ONE;
+ glPolygonOffset(-2.0, -9.0);
+ } else
+#endif
+ {
+#ifdef GL_EXT_polygon_offset
+ /* check for the polygon offset extension */
+ if (glutExtensionSupported("GL_EXT_polygon_offset")) {
+ polygonOffsetVersion = EXTENSION;
+ glPolygonOffsetEXT(-2.0, -0.002);
+ } else
+#endif
+ {
+ polygonOffsetVersion = MISSING;
+ printf("\ndinoshine: Missing polygon offset.\n");
+ printf(" Expect shadow depth aliasing artifacts.\n\n");
+ }
+ }
+
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_TEXTURE_2D);
+ glLineWidth(3.0);
+
+ glMatrixMode(GL_PROJECTION);
+ gluPerspective( /* field of view in degree */ 40.0,
+ /* aspect ratio */ 1.0,
+ /* Z near */ 20.0, /* Z far */ 100.0);
+ glMatrixMode(GL_MODELVIEW);
+ gluLookAt(0.0, 8.0, 60.0, /* eye is at (0,8,60) */
+ 0.0, 8.0, 0.0, /* center is at (0,8,0) */
+ 0.0, 1.0, 0.); /* up is in postivie Y direction */
+
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
+ glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1);
+ glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_LIGHTING);
+
+ makeFloorTexture();
+
+ /* Setup floor plane for projected shadow calculations. */
+ findPlane(floorPlane, floorVertices[1], floorVertices[2], floorVertices[3]);
+
+ glutMainLoop();
+ return 0; /* ANSI C requires main to return int. */
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/ext422square.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/ext422square.c
new file mode 100644
index 000000000..6533514d6
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/ext422square.c
@@ -0,0 +1,258 @@
+/*
+ * Exercise the EXT_422_pixels extension, a less convenient
+ * alternative to MESA_ycbcr_texture. Requires ARB_fragment_program
+ * to perform the final YUV->RGB conversion.
+ *
+ * Brian Paul 13 September 2002
+ * Keith Whitwell 30 November 2004
+ */
+
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include <assert.h>
+
+#include "../util/readtex.c" /* I know, this is a hack. */
+
+#define TEXTURE_FILE "../images/tile.rgb"
+
+static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
+static GLint ImgWidth, ImgHeight;
+static GLushort *ImageYUV = NULL;
+static const GLuint yuvObj = 100;
+static const GLuint rgbObj = 101;
+
+static void Init( int argc, char *argv[] );
+
+static void DrawObject(void)
+{
+ glBegin(GL_QUADS);
+
+ glTexCoord2f(0, 0);
+ glVertex2f(-1.0, -1.0);
+
+ glTexCoord2f(1, 0);
+ glVertex2f(1.0, -1.0);
+
+ glTexCoord2f(1, 1);
+ glVertex2f(1.0, 1.0);
+
+ glTexCoord2f(0, 1);
+ glVertex2f(-1.0, 1.0);
+
+ glEnd();
+}
+
+static void Display( void )
+{
+ static int firsttime = 1;
+
+ if (firsttime) {
+ firsttime = 0;
+ Init( 0, 0 ); /* don't ask */
+ }
+
+ glClear( GL_COLOR_BUFFER_BIT );
+ glBindTexture(GL_TEXTURE_2D, yuvObj);
+
+ glPushMatrix();
+ glEnable(GL_FRAGMENT_PROGRAM_ARB);
+ glTranslatef( -1.1, 0.0, -15.0 );
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+ glBindTexture(GL_TEXTURE_2D, yuvObj);
+ DrawObject();
+ glPopMatrix();
+
+ glPushMatrix();
+ glDisable(GL_FRAGMENT_PROGRAM_ARB);
+ glTranslatef( 1.1, 0.0, -15.0 );
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+ glBindTexture(GL_TEXTURE_2D, rgbObj);
+ DrawObject();
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.1, 1.1, -1.1, 1.1, 10.0, 100.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ float step = 3.0;
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot += step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot -= step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+
+
+/* #define LINEAR_FILTER */
+
+static void Init( int argc, char *argv[] )
+{
+ const char *file;
+ const GLfloat yuvtorgb[16] = {
+ 1.164, 1.164, 1.164, 0,
+ 0, -.391, 2.018, 0,
+ 1.596, -.813, 0.0, 0,
+ (-.0625*1.164 + -.5*1.596), (-.0625*1.164 + -.5*-.813 + -.5*-.391), (-.0625*1.164 + -.5*2.018), 1
+ };
+
+ if (!glutExtensionSupported("GL_ARB_fragment_program")) {
+ printf("Error: GL_ARB_fragment_program not supported!\n");
+ exit(1);
+ }
+
+ if (!glutExtensionSupported("GL_EXT_422_pixels")) {
+ printf("Error: GL_EXT_422_pixels not supported!\n");
+ exit(1);
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ file = TEXTURE_FILE;
+
+ /* Load the texture as YCbCr.
+ */
+ glBindTexture(GL_TEXTURE_2D, yuvObj);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ ImageYUV = LoadYUVImage(file, &ImgWidth, &ImgHeight );
+ if (!ImageYUV) {
+ printf("Couldn't read %s\n", TEXTURE_FILE);
+ exit(0);
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ GL_RGB,
+ ImgWidth, ImgHeight, 0,
+ GL_422_EXT,
+ GL_UNSIGNED_BYTE, ImageYUV);
+
+ glEnable(GL_TEXTURE_2D);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ {
+ static const char *modulateYUV =
+ "!!ARBfp1.0\n"
+ "TEMP R0;\n"
+ "TEX R0, fragment.texcoord[0], texture[0], 2D; \n"
+
+ "ADD R0, R0, {-0.0625, -0.5, -0.5, 0.0}; \n"
+ "DP3 result.color.x, R0, {1.164, 1.596, 0.0}; \n"
+ "DP3 result.color.y, R0, {1.164, -0.813, -0.391}; \n"
+ "DP3 result.color.z, R0, {1.164, 0.0, 2.018}; \n"
+ "MOV result.color.w, R0.w; \n"
+
+ "END"
+ ;
+
+ GLuint modulateProg;
+
+
+ /* Setup the fragment program */
+ glGenProgramsARB(1, &modulateProg);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(modulateYUV), (const GLubyte *)modulateYUV);
+
+ printf("glGetError = 0x%x\n", (int) glGetError());
+ printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
+ (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ assert(glIsProgramARB(modulateProg));
+
+ }
+
+ /* Now the same, but use a color matrix to do the conversion at
+ * upload time:
+ */
+ glBindTexture(GL_TEXTURE_2D, rgbObj);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ glMatrixMode( GL_COLOR_MATRIX );
+ glLoadMatrixf( yuvtorgb );
+
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ GL_RGB,
+ ImgWidth, ImgHeight, 0,
+ GL_422_EXT,
+ GL_UNSIGNED_BYTE, ImageYUV);
+
+ glLoadIdentity();
+ glMatrixMode( GL_MODELVIEW );
+
+ glEnable(GL_TEXTURE_2D);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+
+ glShadeModel(GL_FLAT);
+ glClearColor(0.3, 0.3, 0.4, 1.0);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowSize( 300, 300 );
+ glutInitWindowPosition( 0, 0 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0] );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/fbotest1.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/fbotest1.c
new file mode 100644
index 000000000..3faa55eb9
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/fbotest1.c
@@ -0,0 +1,190 @@
+/*
+ * Test GL_EXT_framebuffer_object
+ *
+ * Brian Paul
+ * 7 Feb 2005
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+static int Width = 400, Height = 400;
+static GLuint MyFB;
+
+
+static void
+CheckError(int line)
+{
+ GLenum err = glGetError();
+ if (err) {
+ printf("GL Error 0x%x at line %d\n", (int) err, line);
+ }
+}
+
+
+static void
+Display( void )
+{
+ GLubyte *buffer = malloc(Width * Height * 4);
+ GLenum status;
+
+ /* draw to user framebuffer */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+ glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
+ glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
+
+ status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ printf("Framebuffer incomplete!!!\n");
+ }
+
+ glClearColor(0.5, 0.5, 1.0, 0.0);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glBegin(GL_POLYGON);
+ glColor3f(1, 0, 0);
+ glVertex2f(-1, -1);
+ glColor3f(0, 1, 0);
+ glVertex2f(1, -1);
+ glColor3f(0, 0, 1);
+ glVertex2f(0, 1);
+ glEnd();
+
+ /* read from user framebuffer */
+ glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+ /* draw to window */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glWindowPos2iARB(0, 0);
+ glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+ free(buffer);
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape( int width, int height )
+{
+#if 0
+ float ar = (float) width / (float) height;
+#endif
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+#if 0
+ glFrustum( -ar, ar, -1.0, 1.0, 5.0, 25.0 );
+#else
+ glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+#endif
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+ Width = width;
+ Height = height;
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+}
+
+
+static void
+Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init( void )
+{
+ GLuint rb;
+ GLint i;
+
+ if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
+ printf("GL_EXT_framebuffer_object not found!\n");
+ /*exit(0);*/
+ }
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ glGenFramebuffersEXT(1, &MyFB);
+ assert(MyFB);
+ assert(!glIsFramebufferEXT(MyFB));
+ glDeleteFramebuffersEXT(1, &MyFB);
+ assert(!glIsFramebufferEXT(MyFB));
+ /* Note, continue to use MyFB below */
+
+ glGenRenderbuffersEXT(1, &rb);
+ assert(rb);
+ assert(!glIsRenderbufferEXT(rb));
+ glDeleteRenderbuffersEXT(1, &rb);
+ assert(!glIsRenderbufferEXT(rb));
+ rb = 42; /* an arbitrary ID */
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+ assert(glIsFramebufferEXT(MyFB));
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
+ assert(glIsRenderbufferEXT(rb));
+
+ glGetIntegerv(GL_RENDERBUFFER_BINDING_EXT, &i);
+ assert(i == rb);
+
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &i);
+ assert(i == MyFB);
+
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
+ GL_RENDERBUFFER_EXT, rb);
+
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+
+ {
+ GLint r, g, b, a;
+ glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ GL_RENDERBUFFER_RED_SIZE_EXT, &r);
+ glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ GL_RENDERBUFFER_GREEN_SIZE_EXT, &g);
+ glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ GL_RENDERBUFFER_BLUE_SIZE_EXT, &b);
+ glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ GL_RENDERBUFFER_ALPHA_SIZE_EXT, &a);
+ printf("renderbuffer RGBA sizes = %d %d %d %d\n", r, g, b, a);
+
+ glGetIntegerv(GL_RED_BITS, &r);
+ glGetIntegerv(GL_GREEN_BITS, &g);
+ glGetIntegerv(GL_BLUE_BITS, &b);
+ glGetIntegerv(GL_ALPHA_BITS, &a);
+ printf("Visual RGBA sizes = %d %d %d %d\n", r, g, b, a);
+ }
+
+ CheckError(__LINE__);
+
+ /* restore to default */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+}
+
+
+int
+main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize(Width, Height);
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/fbotexture.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/fbotexture.c
new file mode 100644
index 000000000..f348d202f
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/fbotexture.c
@@ -0,0 +1,288 @@
+/*
+ * Test GL_EXT_framebuffer_object render-to-texture
+ *
+ * Draw a teapot into a texture image with stenciling.
+ * Then draw a textured quad using that texture.
+ *
+ * Brian Paul
+ * 18 Apr 2005
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+static int Width = 400, Height = 400;
+static int TexWidth = 512, TexHeight = 512;
+static GLuint MyFB;
+static GLuint TexObj;
+static GLuint DepthRB, StencilRB;
+static GLboolean Anim = GL_FALSE;
+static GLfloat Rot = 0.0;
+
+
+static void
+CheckError(int line)
+{
+ GLenum err = glGetError();
+ if (err) {
+ printf("GL Error 0x%x at line %d\n", (int) err, line);
+ }
+}
+
+
+static void
+Idle(void)
+{
+ Rot = glutGet(GLUT_ELAPSED_TIME) * 0.05;
+ glutPostRedisplay();
+}
+
+
+static void
+RenderTexture(void)
+{
+ GLint level = 0;
+ GLenum status;
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -15.0);
+
+ /* draw to texture image */
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, TexObj, level);
+
+ status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ printf("Framebuffer incomplete!!!\n");
+ }
+
+ glViewport(0, 0, TexWidth, TexHeight);
+
+ glClearColor(0.5, 0.5, 1.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_STENCIL_TEST);
+ glStencilFunc(GL_NEVER, 1, ~0);
+ glStencilOp(GL_REPLACE, GL_KEEP, GL_REPLACE);
+
+ /* draw diamond-shaped stencil pattern */
+ glColor3f(0, 1, 0);
+ glBegin(GL_POLYGON);
+ glVertex2f(-0.2, 0.0);
+ glVertex2f( 0.0, -0.2);
+ glVertex2f( 0.2, 0.0);
+ glVertex2f( 0.0, 0.2);
+ glEnd();
+
+ /* draw teapot where stencil != 1 */
+ glStencilFunc(GL_NOTEQUAL, 1, ~0);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+
+#if 0
+ glBegin(GL_POLYGON);
+ glColor3f(1, 0, 0);
+ glVertex2f(-1, -1);
+ glColor3f(0, 1, 0);
+ glVertex2f(1, -1);
+ glColor3f(0, 0, 1);
+ glVertex2f(0, 1);
+ glEnd();
+#else
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glPushMatrix();
+ glRotatef(0.5 * Rot, 1.0, 0.0, 0.0);
+ glutSolidTeapot(0.5);
+ glPopMatrix();
+ glDisable(GL_LIGHTING);
+#endif
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_STENCIL_TEST);
+
+ /* Bind normal framebuffer */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+
+ CheckError(__LINE__);
+}
+
+
+
+static void
+Display(void)
+{
+ float ar = (float) Width / (float) Height;
+
+ RenderTexture();
+
+ /* draw textured quad in the window */
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -7.0);
+
+ glViewport(0, 0, Width, Height);
+
+ glClearColor(0.25, 0.25, 0.25, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glPushMatrix();
+ glRotatef(Rot, 0, 1, 0);
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, TexObj);
+ glBegin(GL_POLYGON);
+ glColor3f(0.25, 0.25, 0.25);
+ glTexCoord2f(0, 0);
+ glVertex2f(-1, -1);
+ glTexCoord2f(1, 0);
+ glVertex2f(1, -1);
+ glColor3f(1.0, 1.0, 1.0);
+ glTexCoord2f(1, 1);
+ glVertex2f(1, 1);
+ glTexCoord2f(0, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+ glPopMatrix();
+ glDisable(GL_TEXTURE_2D);
+
+ glutSwapBuffers();
+ CheckError(__LINE__);
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ Width = width;
+ Height = height;
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+ GLint i;
+
+ if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
+ printf("GL_EXT_framebuffer_object not found!\n");
+ exit(0);
+ }
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ /* gen framebuffer id, delete it, do some assertions, just for testing */
+ glGenFramebuffersEXT(1, &MyFB);
+ assert(MyFB);
+ assert(!glIsFramebufferEXT(MyFB));
+ glDeleteFramebuffersEXT(1, &MyFB);
+ assert(!glIsFramebufferEXT(MyFB));
+ /* Note, continue to use MyFB below */
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+ assert(glIsFramebufferEXT(MyFB));
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &i);
+ assert(i == MyFB);
+
+ /* make depth renderbuffer */
+ glGenRenderbuffersEXT(1, &DepthRB);
+ assert(DepthRB);
+ assert(!glIsRenderbufferEXT(DepthRB));
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
+ assert(glIsRenderbufferEXT(DepthRB));
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
+ TexWidth, TexHeight);
+ glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
+ printf("Depth renderbuffer size = %d bits\n", i);
+ assert(i > 0);
+
+ /* make stencil renderbuffer */
+ glGenRenderbuffersEXT(1, &StencilRB);
+ assert(StencilRB);
+ assert(!glIsRenderbufferEXT(StencilRB));
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilRB);
+ assert(glIsRenderbufferEXT(StencilRB));
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX,
+ TexWidth, TexHeight);
+ glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ GL_RENDERBUFFER_STENCIL_SIZE_EXT, &i);
+ printf("Stencil renderbuffer size = %d bits\n", i);
+ assert(i > 0);
+
+ /* attach DepthRB to MyFB */
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, DepthRB);
+
+ /* attach StencilRB to MyFB */
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, StencilRB);
+
+
+ /* bind regular framebuffer */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+
+ /* Make texture object/image */
+ glGenTextures(1, &TexObj);
+ glBindTexture(GL_TEXTURE_2D, TexObj);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TexWidth, TexHeight, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ CheckError(__LINE__);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(Width, Height);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Display);
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/floattex.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/floattex.c
new file mode 100644
index 000000000..2345a49b2
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/floattex.c
@@ -0,0 +1,169 @@
+/*
+ * Test floating point textures.
+ * No actual rendering, yet.
+ */
+
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+/* XXX - temporary */
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float 1
+#define GL_TEXTURE_RED_TYPE_ARB 0x9000
+#define GL_TEXTURE_GREEN_TYPE_ARB 0x9001
+#define GL_TEXTURE_BLUE_TYPE_ARB 0x9002
+#define GL_TEXTURE_ALPHA_TYPE_ARB 0x9003
+#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x9004
+#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x9005
+#define GL_TEXTURE_DEPTH_TYPE_ARB 0x9006
+#define GL_UNSIGNED_NORMALIZED_ARB 0x9007
+#define GL_RGBA32F_ARB 0x8814
+#define GL_RGB32F_ARB 0x8815
+#define GL_ALPHA32F_ARB 0x8816
+#define GL_INTENSITY32F_ARB 0x8817
+#define GL_LUMINANCE32F_ARB 0x8818
+#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
+#define GL_RGBA16F_ARB 0x881A
+#define GL_RGB16F_ARB 0x881B
+#define GL_ALPHA16F_ARB 0x881C
+#define GL_INTENSITY16F_ARB 0x881D
+#define GL_LUMINANCE16F_ARB 0x881E
+#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
+#endif
+
+
+static GLboolean
+CheckError( int line )
+{
+ GLenum error = glGetError();
+ if (error) {
+ char *err = (char *) gluErrorString( error );
+ fprintf( stderr, "GL Error: %s at line %d\n", err, line );
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+
+static void
+Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glPushMatrix();
+
+ glutSolidCube(2.0);
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -15.0);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+
+static void
+Init(void)
+{
+ GLfloat tex[16][16][4];
+ GLfloat tex2[16][16][4];
+ GLint i, j, t;
+
+ if (!glutExtensionSupported("GL_MESAX_texture_float")) {
+ printf("Sorry, this test requires GL_MESAX_texture_float\n");
+ exit(1);
+ }
+
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ GLfloat s = i / 15.0;
+ tex[i][j][0] = s;
+ tex[i][j][1] = 2.0 * s;
+ tex[i][j][2] = -3.0 * s;
+ tex[i][j][3] = 4.0 * s;
+ }
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, 16, 16, 0, GL_RGBA,
+ GL_FLOAT, tex);
+ CheckError(__LINE__);
+
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_TYPE_ARB, &t);
+ assert(t == GL_FLOAT);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_TYPE_ARB, &t);
+ assert(t == GL_FLOAT);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_TYPE_ARB, &t);
+ assert(t == GL_FLOAT);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_TYPE_ARB, &t);
+ assert(t == GL_FLOAT);
+
+ CheckError(__LINE__);
+
+ /* read back the texture and make sure values are correct */
+ glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, tex2);
+ CheckError(__LINE__);
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ if (tex[i][j][0] != tex2[i][j][0] ||
+ tex[i][j][1] != tex2[i][j][1] ||
+ tex[i][j][2] != tex2[i][j][2] ||
+ tex[i][j][3] != tex2[i][j][3]) {
+ printf("tex[%d][%d] %g %g %g %g != tex2[%d][%d] %g %g %g %g\n",
+ i, j,
+ tex[i][j][0], tex[i][j][1], tex[i][j][2], tex[i][j][3],
+ i, j,
+ tex2[i][j][0], tex2[i][j][1], tex2[i][j][2], tex2[i][j][3]);
+ }
+ }
+ }
+
+
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(400, 400);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/fogcoord.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/fogcoord.c
new file mode 100644
index 000000000..89355742a
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/fogcoord.c
@@ -0,0 +1,102 @@
+/*
+ * Exercise GL_EXT_fog_coord
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+static int Width = 600;
+static int Height = 200;
+static GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+ GLfloat t;
+
+ glClearColor(0.2, 0.2, 0.8, 0);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ for (t = 0.0; t <= 1.0; t += 0.25) {
+ GLfloat f = Near + t * (Far - Near);
+ printf("glFogCoord(%4.1f)\n", f);
+ glFogCoordfEXT(f);
+
+ glPushMatrix();
+ glTranslatef(t * 10.0 - 5.0, 0, 0);
+ glBegin(GL_POLYGON);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+ glPopMatrix();
+ }
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ /* setup lighting, etc */
+ if (!glutExtensionSupported("GL_EXT_fog_coord")) {
+ printf("Sorry, this program requires GL_EXT_fog_coord\n");
+ exit(1);
+ }
+ glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
+ glFogi(GL_FOG_MODE, GL_LINEAR);
+ glFogf(GL_FOG_START, Near);
+ glFogf(GL_FOG_END, Far);
+ glEnable(GL_FOG);
+ printf("Squares should be colored from white -> gray -> black.\n");
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/fptest1.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/fptest1.c
new file mode 100644
index 000000000..d0bcdaa22
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/fptest1.c
@@ -0,0 +1,220 @@
+/* Test GL_NV_fragment_program */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+
+ glColor4f(0, 0.5, 0, 1);
+ glColor4f(0, 1, 0, 1);
+ glBegin(GL_POLYGON);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 0, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ static const char *prog0 =
+ "!!FP1.0\n"
+ "MUL o[COLR], R0, f[WPOS]; \n"
+ "ADD o[COLH], H3, f[TEX0]; \n"
+ "ADD_SAT o[COLH], H3, f[TEX0]; \n"
+ "ADDX o[COLH], H3, f[TEX0]; \n"
+ "ADDHC o[COLH], H3, f[TEX0]; \n"
+ "ADDXC o[COLH], H3, f[TEX0]; \n"
+ "ADDXC_SAT o[COLH], H30, f[TEX0]; \n"
+ "MUL o[COLR].xy, R0.wzyx, f[WPOS]; \n"
+ "MUL o[COLR], H0, f[WPOS]; \n"
+ "MUL o[COLR], -H0, f[WPOS]; \n"
+ "MOV RC, H1; \n"
+ "MOV HC, H2; \n"
+ "END \n"
+ ;
+
+ /* masked updates, defines, declarations */
+ static const char *prog1 =
+ "!!FP1.0\n"
+ "DEFINE foo = {1, 2, 3, 4}; \n"
+ "DEFINE foo2 = 5; \n"
+ "DECLARE foo3 = {5, 6, 7, 8}; \n"
+ "DECLARE bar = 3; \n"
+ "DECLARE bar2; \n"
+ "DECLARE bar3 = bar; \n"
+ "#DECLARE bar4 = { a, b, c, d }; \n"
+ "MOV o[COLR].xy, R0; \n"
+ "MOV o[COLR] (NE), R0; \n"
+ "MOV o[COLR] (NE.wzyx), R0; \n"
+ "MOV o[COLR].xy (NE.wzyx), R0; \n"
+ "MOV RC.x (EQ), R1.x; \n"
+ "KIL NE; \n"
+ "KIL EQ.xyxy; \n"
+ "END \n"
+ ;
+
+ /* texture instructions */
+ static const char *prog2 =
+ "!!FP1.0\n"
+ "TEX R0, f[TEX0], TEX0, 2D; \n"
+ "TEX R1, f[TEX1], TEX1, CUBE; \n"
+ "TEX R2, f[TEX2], TEX2, 3D; \n"
+ "TXP R3, f[TEX3], TEX3, RECT; \n"
+ "TXD R3, R2, R1, f[TEX3], TEX3, RECT; \n"
+ "MUL o[COLR], R0, f[COL0]; \n"
+ "END \n"
+ ;
+
+ /* test negation, absolute value */
+ static const char *prog3 =
+ "!!FP1.0\n"
+ "MOV R0, -R1; \n"
+ "MOV R0, +R1; \n"
+ "MOV R0, |-R1|; \n"
+ "MOV R0, |+R1|; \n"
+ "MOV R0, -|R1|; \n"
+ "MOV R0, +|R1|; \n"
+ "MOV R0, -|-R1|; \n"
+ "MOV R0, -|+R1|; \n"
+ "MOV o[COLR], R0; \n"
+ "END \n"
+ ;
+
+ /* literal constant sources */
+ static const char *prog4 =
+ "!!FP1.0\n"
+ "DEFINE Pi = 3.14159; \n"
+ "MOV R0, {1, -2, +3, 4}; \n"
+ "MOV R0, 5; \n"
+ "MOV R0, -5; \n"
+ "MOV R0, +5; \n"
+ "MOV R0, Pi; \n"
+ "MOV o[COLR], R0; \n"
+ "END \n"
+ ;
+
+ /* change the fragment color in a simple way */
+ static const char *prog10 =
+ "!!FP1.0\n"
+ "DEFINE blue = {0, 0, 1, 0};\n"
+ "DECLARE color; \n"
+ "MOV R0, f[COL0]; \n"
+ "#ADD o[COLR], R0, f[COL0]; \n"
+ "#ADD o[COLR], blue, f[COL0]; \n"
+ "#ADD o[COLR], {1, 0, 0, 0}, f[COL0]; \n"
+ "ADD o[COLR], color, f[COL0]; \n"
+ "END \n"
+ ;
+
+ GLuint progs[20];
+
+ glGenProgramsNV(20, progs);
+ assert(progs[0]);
+ assert(progs[1]);
+ assert(progs[0] != progs[1]);
+
+#if 0
+ glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[0],
+ strlen(prog0),
+ (const GLubyte *) prog0);
+ assert(glIsProgramNV(progs[0]));
+#endif
+
+ glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[1],
+ strlen(prog1),
+ (const GLubyte *) prog1);
+ assert(glIsProgramNV(progs[1]));
+
+ glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[2],
+ strlen(prog2),
+ (const GLubyte *) prog2);
+ assert(glIsProgramNV(progs[2]));
+ glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[2]);
+
+ glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[3],
+ strlen(prog3),
+ (const GLubyte *) prog3);
+ assert(glIsProgramNV(progs[3]));
+ glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[3]);
+
+ glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[4],
+ strlen(prog4),
+ (const GLubyte *) prog4);
+ assert(glIsProgramNV(progs[4]));
+ glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[4]);
+
+
+ /* a real program */
+ glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[10],
+ strlen(prog10),
+ (const GLubyte *) prog10);
+ assert(glIsProgramNV(progs[10]));
+ glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[10]);
+
+ glProgramNamedParameter4fNV(progs[10],
+ strlen("color"), (const GLubyte *) "color",
+ 1, 0, 0, 1);
+
+ glEnable(GL_FRAGMENT_PROGRAM_NV);
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_ALWAYS, 0.0);
+
+ printf("glGetError = %d\n", (int) glGetError());
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/fptexture.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/fptexture.c
new file mode 100644
index 000000000..f57ad6282
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/fptexture.c
@@ -0,0 +1,151 @@
+/* GL_NV_fragment_program texture test */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#include "../util/readtex.c"
+
+
+#define TEXTURE_FILE "../images/girl.rgb"
+
+static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+
+ glBegin(GL_POLYGON);
+ glColor4f(1.0, 1.0, 1.0, 1); glTexCoord2f(0, 0); glVertex2f(-1, -1);
+ glColor4f(0.2, 0.2, 1.0, 1); glTexCoord2f(1, 0); glVertex2f( 1, -1);
+ glColor4f(0.2, 1.0, 0.2, 1); glTexCoord2f(1, 1); glVertex2f( 1, 1);
+ glColor4f(1.0, 0.2, 0.2, 1); glTexCoord2f(0, 1); glVertex2f(-1, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -8.0 );
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ float step = 3.0;
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot += step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot -= step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ static const char *modulate2D =
+ "!!FP1.0\n"
+ "TEX R0, f[TEX0], TEX0, 2D; \n"
+ "MUL o[COLR], R0, f[COL0]; \n"
+ "END"
+ ;
+ GLuint modulateProg;
+ GLuint Texture;
+
+ if (!glutExtensionSupported("GL_NV_fragment_program")) {
+ printf("Error: GL_NV_fragment_program not supported!\n");
+ exit(1);
+ }
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ /* Setup the fragment program */
+ glGenProgramsNV(1, &modulateProg);
+ glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, modulateProg,
+ strlen(modulate2D),
+ (const GLubyte *) modulate2D);
+ printf("glGetError = 0x%x\n", (int) glGetError());
+ printf("glError(GL_PROGRAM_ERROR_STRING_NV) = %s\n",
+ (char *) glGetString(GL_PROGRAM_ERROR_STRING_NV));
+ assert(glIsProgramNV(modulateProg));
+
+ glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, modulateProg);
+ glEnable(GL_FRAGMENT_PROGRAM_NV);
+
+ /* Load texture */
+ glGenTextures(1, &Texture);
+ glBindTexture(GL_TEXTURE_2D, Texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
+ printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE);
+ exit(1);
+ }
+ /* XXX this enable shouldn't really be needed!!! */
+ glEnable(GL_TEXTURE_2D);
+
+ glClearColor(.3, .3, .3, 0);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/getprocaddress.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/getprocaddress.c
new file mode 100644
index 000000000..2480ed44c
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/getprocaddress.c
@@ -0,0 +1,438 @@
+/*
+ * Copyright (C) 1999-2002 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.
+ */
+
+/*
+ * Test that glXGetProcAddress works.
+ */
+
+#define GLX_GLXEXT_PROTOTYPES
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/gl.h>
+#include <GL/glx.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+
+typedef void (*generic_func)();
+
+#define EQUAL(X, Y) (fabs((X) - (Y)) < 0.001)
+
+static GLboolean
+test_ActiveTextureARB(generic_func func)
+{
+ PFNGLACTIVETEXTUREARBPROC activeTexture = (PFNGLACTIVETEXTUREARBPROC) func;
+ GLint t;
+ GLboolean pass;
+ (*activeTexture)(GL_TEXTURE1_ARB);
+ glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &t);
+ pass = (t == GL_TEXTURE1_ARB);
+ (*activeTexture)(GL_TEXTURE0_ARB); /* restore default */
+ return pass;
+}
+
+
+static GLboolean
+test_SecondaryColor3fEXT(generic_func func)
+{
+ PFNGLSECONDARYCOLOR3FEXTPROC secColor3f = (PFNGLSECONDARYCOLOR3FEXTPROC) func;
+ GLfloat color[4];
+ GLboolean pass;
+ (*secColor3f)(1.0, 1.0, 0.0);
+ glGetFloatv(GL_CURRENT_SECONDARY_COLOR_EXT, color);
+ pass = (color[0] == 1.0 && color[1] == 1.0 && color[2] == 0.0);
+ (*secColor3f)(0.0, 0.0, 0.0); /* restore default */
+ return pass;
+}
+
+
+static GLboolean
+test_ActiveStencilFaceEXT(generic_func func)
+{
+ PFNGLACTIVESTENCILFACEEXTPROC activeFace = (PFNGLACTIVESTENCILFACEEXTPROC) func;
+ GLint face;
+ GLboolean pass;
+ (*activeFace)(GL_BACK);
+ glGetIntegerv(GL_ACTIVE_STENCIL_FACE_EXT, &face);
+ pass = (face == GL_BACK);
+ (*activeFace)(GL_FRONT); /* restore default */
+ return pass;
+}
+
+
+static GLboolean
+test_VertexAttrib1fvARB(generic_func func)
+{
+ PFNGLVERTEXATTRIB1FVARBPROC vertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC) func;
+ PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
+
+ const GLfloat v[1] = {25.0};
+ const GLfloat def[1] = {0};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib1fvARB)(6, v);
+ (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
+ pass = (res[0] == 25.0 && res[1] == 0.0 && res[2] == 0.0 && res[3] == 1.0);
+ (*vertexAttrib1fvARB)(6, def);
+ return pass;
+}
+
+static GLboolean
+test_VertexAttrib4NubvARB(generic_func func)
+{
+ PFNGLVERTEXATTRIB4NUBVARBPROC vertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC) func;
+ PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
+
+ const GLubyte v[4] = {255, 0, 255, 0};
+ const GLubyte def[4] = {0, 0, 0, 255};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib4NubvARB)(6, v);
+ (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
+ pass = (res[0] == 1.0 && res[1] == 0.0 && res[2] == 1.0 && res[3] == 0.0);
+ (*vertexAttrib4NubvARB)(6, def);
+ return pass;
+}
+
+
+static GLboolean
+test_VertexAttrib4NuivARB(generic_func func)
+{
+ PFNGLVERTEXATTRIB4NUIVARBPROC vertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC) func;
+ PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
+
+ const GLuint v[4] = {0xffffffff, 0, 0xffffffff, 0};
+ const GLuint def[4] = {0, 0, 0, 0xffffffff};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib4NuivARB)(6, v);
+ (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
+ pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
+ (*vertexAttrib4NuivARB)(6, def);
+ return pass;
+}
+
+
+static GLboolean
+test_VertexAttrib4ivARB(generic_func func)
+{
+ PFNGLVERTEXATTRIB4IVARBPROC vertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC) func;
+ PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
+
+ const GLint v[4] = {1, 2, -3, 4};
+ const GLint def[4] = {0, 0, 0, 1};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib4ivARB)(6, v);
+ (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
+ pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 2.0) && EQUAL(res[2], -3.0) && EQUAL(res[3], 4.0));
+ (*vertexAttrib4ivARB)(6, def);
+ return pass;
+}
+
+
+static GLboolean
+test_VertexAttrib4NsvARB(generic_func func)
+{
+ PFNGLVERTEXATTRIB4NSVARBPROC vertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC) func;
+ PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
+
+ const GLshort v[4] = {0, 32767, 32767, 0};
+ const GLshort def[4] = {0, 0, 0, 32767};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib4NsvARB)(6, v);
+ (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
+ pass = (EQUAL(res[0], 0.0) && EQUAL(res[1], 1.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
+ (*vertexAttrib4NsvARB)(6, def);
+ return pass;
+}
+
+
+static GLboolean
+test_VertexAttrib4NusvARB(generic_func func)
+{
+ PFNGLVERTEXATTRIB4NUSVARBPROC vertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC) func;
+ PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
+
+ const GLushort v[4] = {0xffff, 0, 0xffff, 0};
+ const GLushort def[4] = {0, 0, 0, 0xffff};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib4NusvARB)(6, v);
+ (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
+ pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
+ (*vertexAttrib4NusvARB)(6, def);
+ return pass;
+}
+
+
+static GLboolean
+test_VertexAttrib4ubNV(generic_func func)
+{
+ PFNGLVERTEXATTRIB4UBNVPROC vertexAttrib4ubNV = (PFNGLVERTEXATTRIB4UBNVPROC) func;
+ PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
+
+ const GLubyte v[4] = {255, 0, 255, 0};
+ const GLubyte def[4] = {0, 0, 0, 255};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib4ubNV)(6, v[0], v[1], v[2], v[3]);
+ (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
+ pass = (res[0] == 1.0 && res[1] == 0.0 && res[2] == 1.0 && res[3] == 0.0);
+ (*vertexAttrib4ubNV)(6, def[0], def[1], def[2], def[3]);
+ return pass;
+}
+
+
+static GLboolean
+test_VertexAttrib2sNV(generic_func func)
+{
+ PFNGLVERTEXATTRIB2SNVPROC vertexAttrib2sNV = (PFNGLVERTEXATTRIB2SNVPROC) func;
+ PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
+
+ const GLshort v[2] = {2, -4,};
+ const GLshort def[2] = {0, 0};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib2sNV)(6, v[0], v[1]);
+ (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
+ pass = (EQUAL(res[0], 2) && EQUAL(res[1], -4) && EQUAL(res[2], 0) && res[3] == 1.0);
+ (*vertexAttrib2sNV)(6, def[0], def[1]);
+ return pass;
+}
+
+
+static GLboolean
+test_VertexAttrib3fNV(generic_func func)
+{
+ PFNGLVERTEXATTRIB3FNVPROC vertexAttrib3fNV = (PFNGLVERTEXATTRIB3FNVPROC) func;
+ PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
+
+ const GLfloat v[3] = {0.2, 0.4, 0.8};
+ const GLfloat def[3] = {0, 0, 0};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib3fNV)(6, v[0], v[1], v[2]);
+ (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
+ pass = (EQUAL(res[0], 0.2) && EQUAL(res[1], 0.4) && EQUAL(res[2], 0.8) && res[3] == 1.0);
+ (*vertexAttrib3fNV)(6, def[0], def[1], def[2]);
+ return pass;
+}
+
+
+static GLboolean
+test_VertexAttrib4dvNV(generic_func func)
+{
+ PFNGLVERTEXATTRIB4DVNVPROC vertexAttrib4dvNV = (PFNGLVERTEXATTRIB4DVNVPROC) func;
+ PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
+
+ const GLdouble v[4] = {0.2, 0.4, 0.8, 1.2};
+ const GLdouble def[4] = {0, 0, 0, 1};
+ GLfloat res[4];
+ GLboolean pass;
+ (*vertexAttrib4dvNV)(6, v);
+ (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
+ pass = (EQUAL(res[0], 0.2) && EQUAL(res[1], 0.4) && EQUAL(res[2], 0.8) && EQUAL(res[3], 1.2));
+ (*vertexAttrib4dvNV)(6, def);
+ return pass;
+}
+
+
+/*
+ * The following header file is auto-generated with Python. The Python
+ * script looks in this file for functions named "test_*" as seen above.
+ */
+#include "getproclist.h"
+
+
+
+static int
+extension_supported(const char *haystack, const char *needle)
+{
+ if (strstr(haystack, needle))
+ return 1;
+ else
+ return 0;
+}
+
+
+static void
+check_functions( const char *extensions )
+{
+ struct name_test_pair *entry;
+ int failures = 0, passes = 0;
+ int totalFail = 0, totalPass = 0;
+ int doTests;
+
+ for (entry = functions; entry->name; entry++) {
+ if (entry->name[0] == '-') {
+ /* XXX update for OpenGL 2.0 */
+ if (entry->name[1] == '1') {
+ /* check GL version X.Y */
+ const char *version = (const char *) glGetString(GL_VERSION);
+ if (version[0] == entry->name[1] &&
+ version[1] == entry->name[2] &&
+ version[2] >= entry->name[3])
+ doTests = 1;
+ else
+ doTests = 0;
+ }
+ else {
+ /* check if the named extension is available */
+ doTests = extension_supported(extensions, entry->name+1);
+ }
+ if (doTests)
+ printf("Testing %s functions\n", entry->name + 1);
+ totalFail += failures;
+ totalPass += passes;
+ failures = 0;
+ passes = 0;
+ }
+ else if (doTests) {
+ generic_func funcPtr = (generic_func) glXGetProcAddressARB((const GLubyte *) entry->name);
+ if (funcPtr) {
+ if (entry->test) {
+ GLboolean b;
+ printf(" Validating %s:", entry->name);
+ b = (*entry->test)(funcPtr);
+ if (b) {
+ printf(" Pass\n");
+ passes++;
+ }
+ else {
+ printf(" FAIL!!!\n");
+ failures++;
+ }
+ }
+ else {
+ passes++;
+ }
+ }
+ else {
+ printf(" glXGetProcAddress(%s) failed!\n", entry->name);
+ failures++;
+ }
+ }
+
+ if (doTests && (!(entry+1)->name || (entry+1)->name[0] == '-')) {
+ if (failures > 0) {
+ printf(" %d failed.\n", failures);
+ }
+ if (passes > 0) {
+ printf(" %d passed.\n", passes);
+ }
+ }
+ }
+ totalFail += failures;
+ totalPass += passes;
+
+ printf("-----------------------------\n");
+ printf("Total: %d pass %d fail\n", totalPass, totalFail);
+}
+
+
+
+static void
+print_screen_info(Display *dpy, int scrnum, Bool allowDirect)
+{
+ Window win;
+ int attribSingle[] = {
+ GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ None };
+ int attribDouble[] = {
+ GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ None };
+
+ XSetWindowAttributes attr;
+ unsigned long mask;
+ Window root;
+ GLXContext ctx;
+ XVisualInfo *visinfo;
+ int width = 100, height = 100;
+
+ root = RootWindow(dpy, scrnum);
+
+ visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
+ if (!visinfo) {
+ visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
+ if (!visinfo) {
+ fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
+ return;
+ }
+ }
+
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
+ attr.event_mask = StructureNotifyMask | ExposureMask;
+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+ win = XCreateWindow(dpy, root, 0, 0, width, height,
+ 0, visinfo->depth, InputOutput,
+ visinfo->visual, mask, &attr);
+
+ ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
+ if (!ctx) {
+ fprintf(stderr, "Error: glXCreateContext failed\n");
+ XDestroyWindow(dpy, win);
+ return;
+ }
+
+ if (glXMakeCurrent(dpy, win, ctx)) {
+ check_functions( (const char *) glGetString(GL_EXTENSIONS) );
+ }
+ else {
+ fprintf(stderr, "Error: glXMakeCurrent failed\n");
+ }
+
+ glXDestroyContext(dpy, ctx);
+ XDestroyWindow(dpy, win);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ char *displayName = NULL;
+ Display *dpy;
+
+ dpy = XOpenDisplay(displayName);
+ if (!dpy) {
+ fprintf(stderr, "Error: unable to open display %s\n", displayName);
+ return -1;
+ }
+
+ print_screen_info(dpy, 0, GL_TRUE);
+
+ XCloseDisplay(dpy);
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/getprocaddress.py b/nx-X11/extras/Mesa_6.4.2/progs/tests/getprocaddress.py
new file mode 100644
index 000000000..d16b2d93d
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/getprocaddress.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+
+# $Id: getprocaddress.py,v 1.7 2005/06/21 23:42:43 idr Exp $
+
+# Helper for the getprocaddress.c test.
+
+import sys, getopt, re
+sys.path.append("../../src/mesa/glapi/" )
+import gl_XML
+import license
+
+
+def FindTestFunctions():
+ """Scan getprocaddress.c for lines that start with "test_" to find
+ extension function tests. Return a list of names found."""
+ functions = []
+ f = open("getprocaddress.c")
+ if not f:
+ return functions
+ for line in f.readlines():
+ v = re.search("^test_([a-zA-Z0-9]+)", line)
+ if v:
+ func = v.group(1)
+ functions.append(func)
+ f.close
+ return functions
+
+
+class PrintExports(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "getprocaddress.py (from Mesa)"
+ self.license = license.bsd_license_template % ( \
+"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
+
+ self.tests = FindTestFunctions()
+ self.prevCategory = ""
+ return
+
+
+ def printRealHeader(self):
+ print """
+struct name_test_pair {
+ const char *name;
+ GLboolean (*test)(generic_func);
+};
+
+static struct name_test_pair functions[] = {"""
+
+ def printBody(self, api):
+ prev_category = None
+
+
+ for f in api.functionIterateByOffset():
+ [category, num] = api.get_category_for_name( f.name )
+ if category != prev_category:
+ print ' { "-%s", NULL},' % category
+ prev_category = category
+
+ test = "NULL"
+ for name in f.entry_points:
+ if name in self.tests:
+ test = "test_%s" % name
+ break
+
+ print ' { "gl%s", %s },' % (f.name, test)
+
+ print ''
+ print ' { NULL, NULL }'
+ print '};'
+ print ''
+ return
+
+
+if __name__ == '__main__':
+ file_name = "../../src/mesa/glapi/gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:")
+ except Exception,e:
+ show_usage()
+
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+
+ printer = PrintExports()
+
+ api = gl_XML.parse_GL_API( file_name, gl_XML.gl_item_factory() )
+
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/invert.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/invert.c
new file mode 100644
index 000000000..750592ed7
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/invert.c
@@ -0,0 +1,195 @@
+/*
+ * (C) Copyright IBM Corporation 2005
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 (including the next
+ * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+/**
+ * \file invert.c
+ *
+ * Simple test of GL_MESA_pack_invert functionality. Three squares are
+ * drawn. The first two should look the same, and the third one should
+ * look inverted.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+
+#include "readtex.h"
+
+#define IMAGE_FILE "../images/tree3.rgb"
+
+static int Width = 420;
+static int Height = 150;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+static GLubyte * image = NULL;
+static GLubyte * temp_image = NULL;
+static GLuint img_width = 0;
+static GLuint img_height = 0;
+static GLuint img_format = 0;
+
+PFNGLWINDOWPOS2IPROC win_pos_2i = NULL;
+
+
+static void Display( void )
+{
+ GLint err;
+
+
+ glClearColor(0.2, 0.2, 0.8, 0);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+
+ /* This is the "reference" square.
+ */
+
+ (*win_pos_2i)( 5, 5 );
+ glDrawPixels( img_width, img_height, img_format, GL_UNSIGNED_BYTE, image );
+
+ glPixelStorei( GL_PACK_INVERT_MESA, GL_FALSE );
+ err = glGetError();
+ if ( err != GL_NO_ERROR ) {
+ printf( "Setting PACK_INVERT_MESA to false generated an error (0x%04x).\n",
+ err );
+ }
+
+ glReadPixels( 5, 5, img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image );
+ (*win_pos_2i)( 5 + 1 * (10 + img_width), 5 );
+ glDrawPixels( img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image );
+
+ glPixelStorei( GL_PACK_INVERT_MESA, GL_TRUE );
+ err = glGetError();
+ if ( err != GL_NO_ERROR ) {
+ printf( "Setting PACK_INVERT_MESA to true generated an error (0x%04x).\n",
+ err );
+ }
+
+ glReadPixels( 5, 5, img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image );
+ (*win_pos_2i)( 5 + 2 * (10 + img_width), 5 );
+ glDrawPixels( img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image );
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ const char * const ver_string = (const char * const)
+ glGetString( GL_VERSION );
+ const float ver = strtof( ver_string, NULL );
+
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", ver_string);
+
+ if ( !glutExtensionSupported("GL_MESA_pack_invert") ) {
+ printf("\nSorry, this program requires GL_MESA_pack_invert.\n");
+ exit(1);
+ }
+
+ if ( ver >= 1.4 ) {
+ win_pos_2i = (PFNGLWINDOWPOS2IPROC) glutGetProcAddress( "glWindowPos2i" );
+ }
+ else if ( glutExtensionSupported("GL_ARB_window_pos") ) {
+ win_pos_2i = (PFNGLWINDOWPOS2IPROC) glutGetProcAddress( "glWindowPos2iARB" );
+ }
+ else if ( glutExtensionSupported("GL_MESA_window_pos") ) {
+ win_pos_2i = (PFNGLWINDOWPOS2IPROC) glutGetProcAddress( "glWindowPos2iMESA" );
+ }
+
+
+ /* Do this check as a separate if-statement instead of as an else in case
+ * one of the required extensions is supported but glutGetProcAddress
+ * returns NULL.
+ */
+
+ if ( win_pos_2i == NULL ) {
+ printf("\nSorry, this program requires either GL 1.4 (or higher),\n"
+ "GL_ARB_window_pos, or GL_MESA_window_pos.\n");
+ exit(1);
+ }
+
+ printf("\nThe left 2 squares should be the same color, and the right\n"
+ "square should look upside-down.\n");
+
+
+ image = LoadRGBImage( IMAGE_FILE, & img_width, & img_height,
+ & img_format );
+ if ( image == NULL ) {
+ printf( "Could not open image file \"%s\".\n", IMAGE_FILE );
+ exit(1);
+ }
+
+ temp_image = malloc( 3 * img_height * img_width );
+ if ( temp_image == NULL ) {
+ printf( "Could not allocate memory for temporary image.\n" );
+ exit(1);
+ }
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow( "GL_MESA_pack_invert test" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/jkrahntest.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/jkrahntest.c
new file mode 100644
index 000000000..520dbb84e
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/jkrahntest.c
@@ -0,0 +1,177 @@
+/* $Id: jkrahntest.c,v 1.1 2002/06/16 03:57:48 brianp Exp $ */
+
+/* This is a good test for glXSwapBuffers on non-current windows,
+ * and the glXCopyContext function. Fixed several Mesa/DRI bugs with
+ * this program on 15 June 2002.
+ *
+ * Joe's comments follow:
+ *
+ * I have tried some different approaches for being able to
+ * draw to multiple windows using one context, or a copied
+ * context. Mesa/indirect rendering works to use one context
+ * for multiple windows, but crashes with glXCopyContext.
+ * DRI is badly broken, at least for ATI.
+ *
+ * I also noticed that glXMakeCurrent allows a window and context
+ * from different visuals to be attached (haven't tested recently).
+ *
+ * Joe Krahn <jkrahn@nc.rr.com>
+ */
+
+#include <GL/glx.h>
+#include <GL/gl.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <math.h>
+#define M_PI 3.14159
+#define DEGTOR (M_PI/180.0)
+
+static int AttributeList[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None };
+
+int main(int argc, char **argv)
+{
+ Window win1, win2;
+ XVisualInfo *vi;
+ XSetWindowAttributes swa;
+ Display *dpy;
+ GLXContext ctx1, ctx2;
+ float angle;
+ int test;
+
+ if (argc < 2) {
+ fprintf(stderr, "This program tests GLX context switching.\n");
+ fprintf(stderr, "Usage: cxbug <n>\n");
+ fprintf(stderr, "Where n is:\n");
+ fprintf(stderr, "\t1) Use two contexts and swap only when the context is current (typical case).\n");
+ fprintf(stderr, "\t2) Use two contexts and swap at the same time.\n");
+ fprintf(stderr, "\t\t Used to crash Mesa & nVidia, and DRI artifacts. Seems OK now.\n");
+ fprintf(stderr, "\t3) Use one context, but only swap when a context is current.\n");
+ fprintf(stderr, "\t\t Serious artifacts for DRI at least with ATI.\n");
+ fprintf(stderr, "\t4) Use one context, swap both windows at the same time, so the left\n");
+ fprintf(stderr, "\t\t window has no context at swap time. Severe artifacts for DRI.\n");
+ fprintf(stderr, "\t5) Use two contexts, copying one to the other when switching windows.\n");
+ fprintf(stderr, "\t\t DRI gives an error, indirect rendering crashes server.\n");
+
+ exit(1);
+ }
+ test = atoi(argv[1]);
+
+ /* get a connection */
+ dpy = XOpenDisplay(NULL);
+
+ /* Get an appropriate visual */
+ vi = glXChooseVisual(dpy, DefaultScreen(dpy), AttributeList);
+ if (vi == 0) {
+ fprintf(stderr, "No matching visuals found.\n");
+ exit(-1);
+ }
+
+ /* Create two GLX contexts, with list sharing */
+ ctx1 = glXCreateContext(dpy, vi, 0, True);
+ ctx2 = glXCreateContext(dpy, vi, ctx1, True);
+
+ /* create a colormap */
+ swa.colormap = XCreateColormap(dpy, RootWindow(dpy, vi->screen),
+ vi->visual, AllocNone);
+ swa.border_pixel = 0;
+
+ /* Create two windows */
+ win1 = XCreateWindow(dpy, RootWindow(dpy, vi->screen),
+ 10, 10, 200, 200,
+ 0, vi->depth, InputOutput, vi->visual,
+ CWBorderPixel | CWColormap, &swa);
+ XStoreName(dpy, win1, "Test [L]");
+ XMapWindow(dpy, win1);
+ XMoveWindow(dpy, win1, 10, 10); /* Initial requested x,y may not be honored */
+ {
+ XSizeHints sizehints;
+ static const char *name = "window";
+ sizehints.x = 10;
+ sizehints.y = 10;
+ sizehints.width = 200;
+ sizehints.height = 200;
+ sizehints.flags = USSize | USPosition;
+ XSetNormalHints(dpy, win1, &sizehints);
+ XSetStandardProperties(dpy, win1, name, name,
+ None, (char **)NULL, 0, &sizehints);
+ }
+
+
+ win2 = XCreateWindow(dpy, RootWindow(dpy, vi->screen),
+ 250, 10, 200, 200,
+ 0, vi->depth, InputOutput, vi->visual,
+ CWBorderPixel | CWColormap, &swa);
+ XStoreName(dpy, win1, "Test [R]");
+ XMapWindow(dpy, win2);
+ XMoveWindow(dpy, win2, 260, 10);
+ {
+ XSizeHints sizehints;
+ static const char *name = "window";
+ sizehints.x = 10;
+ sizehints.y = 10;
+ sizehints.width = 200;
+ sizehints.height = 200;
+ sizehints.flags = USSize | USPosition;
+ XSetNormalHints(dpy, win2, &sizehints);
+ XSetStandardProperties(dpy, win2, name, name,
+ None, (char **)NULL, 0, &sizehints);
+ }
+
+
+ /* Now draw some spinning things */
+ for (angle = 0; angle < 360*4; angle += 10.0) {
+ /* Connect the context to window 1 */
+ glXMakeCurrent(dpy, win1, ctx1);
+
+ /* Clear and draw in window 1 */
+ glDrawBuffer(GL_BACK);
+ glClearColor(1, 1, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glColor3f(1, 0, 0);
+ glBegin(GL_TRIANGLES);
+ glVertex2f(0, 0);
+ glVertex2f(cos(angle * DEGTOR), sin(angle * DEGTOR));
+ glVertex2f(cos((angle + 20.0) * DEGTOR),
+ sin((angle + 20.0) * DEGTOR));
+ glEnd();
+ glFlush();
+
+ if (test == 1 || test == 3 || test == 5)
+ glXSwapBuffers(dpy, win1);
+
+ if (test == 5)
+ glXCopyContext(dpy, ctx1, ctx2, GL_ALL_ATTRIB_BITS);
+ /* Connect the context to window 2 */
+ if (test == 3 || test == 4) {
+ glXMakeCurrent(dpy, win2, ctx1);
+ } else {
+ glXMakeCurrent(dpy, win2, ctx2);
+ }
+
+ /* Clear and draw in window 2 */
+ glDrawBuffer(GL_BACK);
+ glClearColor(0, 0, 1, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glColor3f(1, 1, 0);
+ glBegin(GL_TRIANGLES);
+ glVertex2f(0, 0);
+ glVertex2f(cos(angle * DEGTOR), sin(angle * DEGTOR));
+ glVertex2f(cos((angle + 20.0) * DEGTOR),
+ sin((angle + 20.0) * DEGTOR));
+ glEnd();
+ glFlush();
+
+ /* Swap buffers */
+ if (test == 2 || test == 4)
+ glXSwapBuffers(dpy, win1);
+ glXSwapBuffers(dpy, win2);
+
+ /* wait a while */
+ glXWaitX();
+ usleep(20000);
+ }
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/manytex.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/manytex.c
new file mode 100644
index 000000000..8add125a6
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/manytex.c
@@ -0,0 +1,381 @@
+/* $Id: manytex.c,v 1.4 2002/10/18 17:47:36 kschultz Exp $ */
+
+/*
+ * test handling of many texture maps
+ * Also tests texture priority and residency.
+ *
+ * Brian Paul
+ * August 2, 2000
+ */
+
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+static GLint NumTextures = 20;
+static GLuint *TextureID = NULL;
+static GLint *TextureWidth = NULL, *TextureHeight = NULL;
+static GLboolean *TextureResidency = NULL;
+static GLint TexWidth = 128, TexHeight = 128;
+static GLfloat Zrot = 0;
+static GLboolean Anim = GL_TRUE;
+static GLint WinWidth = 500, WinHeight = 400;
+static GLboolean MipMap = GL_FALSE;
+static GLboolean LinearFilter = GL_FALSE;
+static GLboolean RandomSize = GL_FALSE;
+static GLint Rows, Columns;
+static GLint LowPriorityCount = 0;
+
+
+static void Idle( void )
+{
+ Zrot += 1.0;
+ glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+ GLfloat spacing = WinWidth / Columns;
+ GLfloat size = spacing * 0.4;
+ GLint i;
+
+ /* test residency */
+ if (0)
+ {
+ GLboolean b;
+ GLint i, resident;
+ b = glAreTexturesResident(NumTextures, TextureID, TextureResidency);
+ if (b) {
+ printf("all resident\n");
+ }
+ else {
+ resident = 0;
+ for (i = 0; i < NumTextures; i++) {
+ if (TextureResidency[i]) {
+ resident++;
+ }
+ }
+ printf("%d of %d texture resident\n", resident, NumTextures);
+ }
+ }
+
+ /* render the textured quads */
+ glClear( GL_COLOR_BUFFER_BIT );
+ for (i = 0; i < NumTextures; i++) {
+ GLint row = i / Columns;
+ GLint col = i % Columns;
+ GLfloat x = col * spacing + spacing * 0.5;
+ GLfloat y = row * spacing + spacing * 0.5;
+
+ GLfloat maxDim = (TextureWidth[i] > TextureHeight[i])
+ ? TextureWidth[i] : TextureHeight[i];
+ GLfloat w = TextureWidth[i] / maxDim;
+ GLfloat h = TextureHeight[i] / maxDim;
+
+ glPushMatrix();
+ glTranslatef(x, y, 0.0);
+ glRotatef(Zrot, 0, 0, 1);
+ glScalef(size, size, 1);
+
+ glBindTexture(GL_TEXTURE_2D, TextureID[i]);
+ glBegin(GL_POLYGON);
+#if 0
+ glTexCoord2f(0, 0); glVertex2f(-1, -1);
+ glTexCoord2f(1, 0); glVertex2f( 1, -1);
+ glTexCoord2f(1, 1); glVertex2f( 1, 1);
+ glTexCoord2f(0, 1); glVertex2f(-1, 1);
+#else
+ glTexCoord2f(0, 0); glVertex2f(-w, -h);
+ glTexCoord2f(1, 0); glVertex2f( w, -h);
+ glTexCoord2f(1, 1); glVertex2f( w, h);
+ glTexCoord2f(0, 1); glVertex2f(-w, h);
+#endif
+ glEnd();
+ glPopMatrix();
+ }
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ WinWidth = width;
+ WinHeight = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(0, width, 0, height, -1, 1);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+}
+
+
+/*
+ * Return a random int in [min, max].
+ */
+static int RandomInt(int min, int max)
+{
+ int i = rand();
+ int j = i % (max - min + 1);
+ return min + j;
+}
+
+
+
+static void Init( void )
+{
+ GLint i;
+
+ if (RandomSize) {
+ printf("Creating %d %s random-size textures, ", NumTextures,
+ MipMap ? "Mipmapped" : "non-Mipmapped");
+ }
+ else {
+ printf("Creating %d %s %d x %d textures, ", NumTextures,
+ MipMap ? "Mipmapped" : "non-Mipmapped",
+ TexWidth, TexHeight);
+ }
+
+ if (LinearFilter) {
+ printf("bilinear filtering\n");
+ }
+ else {
+ printf("nearest filtering\n");
+ }
+
+
+ /* compute number of rows and columns of rects */
+ {
+ GLfloat area = (GLfloat) (WinWidth * WinHeight) / (GLfloat) NumTextures;
+ GLfloat edgeLen = sqrt(area);
+
+ Columns = WinWidth / edgeLen;
+ Rows = (NumTextures + Columns - 1) / Columns;
+ printf("Rows: %d Cols: %d\n", Rows, Columns);
+ }
+
+
+ if (!TextureID) {
+ TextureID = (GLuint *) malloc(sizeof(GLuint) * NumTextures);
+ assert(TextureID);
+ glGenTextures(NumTextures, TextureID);
+ }
+
+ if (!TextureResidency) {
+ TextureResidency = (GLboolean *) malloc(sizeof(GLboolean) * NumTextures);
+ assert(TextureResidency);
+ }
+
+ if (!TextureWidth) {
+ TextureWidth = (GLint *) malloc(sizeof(GLint) * NumTextures);
+ assert(TextureWidth);
+ }
+ if (!TextureHeight) {
+ TextureHeight = (GLint *) malloc(sizeof(GLint) * NumTextures);
+ assert(TextureHeight);
+ }
+
+ for (i = 0; i < NumTextures; i++) {
+ GLubyte color[4];
+ GLubyte *texImage;
+ GLint j, row, col;
+
+ row = i / Columns;
+ col = i % Columns;
+
+ glBindTexture(GL_TEXTURE_2D, TextureID[i]);
+
+ if (i < LowPriorityCount)
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 0.5F);
+
+ if (RandomSize) {
+#if 0
+ int k = (glutGet(GLUT_ELAPSED_TIME) % 7) + 2;
+ TexWidth = 1 << k;
+ TexHeight = 1 << k;
+#else
+ TexWidth = 1 << RandomInt(2, 7);
+ TexHeight = 1 << RandomInt(2, 7);
+ printf("Random size of %3d: %d x %d\n", i, TexWidth, TexHeight);
+#endif
+ }
+
+ TextureWidth[i] = TexWidth;
+ TextureHeight[i] = TexHeight;
+
+ texImage = (GLubyte*) malloc(4 * TexWidth * TexHeight * sizeof(GLubyte));
+ assert(texImage);
+
+ /* determine texture color */
+ color[0] = (GLint) (255.0 * ((float) col / (Columns - 1)));
+ color[1] = 127;
+ color[2] = (GLint) (255.0 * ((float) row / (Rows - 1)));
+ color[3] = 255;
+
+ /* fill in solid-colored teximage */
+ for (j = 0; j < TexWidth * TexHeight; j++) {
+ texImage[j*4+0] = color[0];
+ texImage[j*4+1] = color[1];
+ texImage[j*4+2] = color[2];
+ texImage[j*4+3] = color[3];
+ }
+
+ if (MipMap) {
+ GLint level = 0;
+ GLint w = TexWidth, h = TexHeight;
+ while (1) {
+ glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, texImage);
+ if (w == 1 && h == 1)
+ break;
+ if (w > 1)
+ w /= 2;
+ if (h > 1)
+ h /= 2;
+ level++;
+ /*printf("%d: %d x %d\n", level, w, h);*/
+ }
+ if (LinearFilter) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ }
+ else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST_MIPMAP_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+ }
+ else {
+ /* Set corners to white */
+ int k = 0;
+ texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255;
+ k = (TexWidth - 1) * 4;
+ texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255;
+ k = (TexWidth * TexHeight - TexWidth) * 4;
+ texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255;
+ k = (TexWidth * TexHeight - 1) * 4;
+ texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255;
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TexWidth, TexHeight, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, texImage);
+ if (LinearFilter) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ }
+ else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+ }
+
+ free(texImage);
+ }
+
+ glEnable(GL_TEXTURE_2D);
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 's':
+ Idle();
+ break;
+ case 'z':
+ Zrot -= step;
+ break;
+ case 'Z':
+ Zrot += step;
+ break;
+ case ' ':
+ Init();
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+int main( int argc, char *argv[] )
+{
+ GLint i;
+
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( WinWidth, WinHeight );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc(Idle);
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-n") == 0) {
+ NumTextures = atoi(argv[i+1]);
+ if (NumTextures <= 0) {
+ printf("Error, bad number of textures\n");
+ return 1;
+ }
+ i++;
+ }
+ else if (strcmp(argv[i], "-mipmap") == 0) {
+ MipMap = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "-linear") == 0) {
+ LinearFilter = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "-size") == 0) {
+ TexWidth = atoi(argv[i+1]);
+ TexHeight = atoi(argv[i+2]);
+ assert(TexWidth >= 1);
+ assert(TexHeight >= 1);
+ i += 2;
+ }
+ else if (strcmp(argv[i], "-randomsize") == 0) {
+ RandomSize = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "-lowpri") == 0) {
+ LowPriorityCount = atoi(argv[i+1]);
+ i++;
+ }
+ else {
+ printf("Usage:\n");
+ printf(" manytex [options]\n");
+ printf("Options:\n");
+ printf(" -n <number of texture objects>\n");
+ printf(" -size <width> <height> - specify texture size\n");
+ printf(" -randomsize - use random size textures\n");
+ printf(" -mipmap - generate mipmaps\n");
+ printf(" -linear - use linear filtering instead of nearest\n");
+ printf(" -lowpri <n> - Set lower priority on <n> textures\n");
+ return 0;
+ }
+ }
+
+ Init();
+
+ glutMainLoop();
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/multipal.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/multipal.c
new file mode 100644
index 000000000..c824b3870
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/multipal.c
@@ -0,0 +1,377 @@
+/* $Id: multipal.c,v 1.6 2003/12/08 09:03:36 joukj Exp $ */
+
+/*
+ * Test multitexture and paletted textures.
+ */
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef __VMS
+# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#else
+# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#endif
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#define GL_GLEXT_LEGACY
+#include <GL/glut.h>
+
+#include "../util/readtex.c" /* I know, this is a hack. */
+
+#define TEXTURE_1_FILE "../images/tile.rgb"
+#define TEXTURE_2_FILE "../images/reflect.rgb"
+
+#define TEX0 1
+#define TEX1 2
+#define TEXBOTH 3
+#define ANIMATE 10
+#define QUIT 100
+
+static GLboolean Animate = GL_TRUE;
+
+static GLfloat Drift = 0.0;
+static GLfloat Xrot = 20.0, Yrot = 30.0, Zrot = 0.0;
+
+
+
+static void Idle( void )
+{
+ if (Animate) {
+ Drift += 0.05;
+ if (Drift >= 1.0)
+ Drift = 0.0;
+
+#ifdef GL_ARB_multitexture
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+#endif
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glTranslatef(Drift, 0.0, 0.0);
+ glMatrixMode(GL_MODELVIEW);
+
+#ifdef GL_ARB_multitexture
+ glActiveTextureARB(GL_TEXTURE1_ARB);
+#endif
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glTranslatef(0.0, Drift, 0.0);
+ glMatrixMode(GL_MODELVIEW);
+
+ glutPostRedisplay();
+ }
+}
+
+
+static void DrawObject(void)
+{
+ glBegin(GL_QUADS);
+
+#ifdef GL_ARB_multitexture
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0);
+ glVertex2f(-1.0, -1.0);
+
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 2.0, 0.0);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0);
+ glVertex2f(1.0, -1.0);
+
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 2.0, 2.0);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0);
+ glVertex2f(1.0, 1.0);
+
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 2.0);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 1.0);
+ glVertex2f(-1.0, 1.0);
+#else
+ glTexCoord2f(0.0, 0.0);
+ glVertex2f(-1.0, -1.0);
+
+ glTexCoord2f(1.0, 0.0);
+ glVertex2f(1.0, -1.0);
+
+ glTexCoord2f(1.0, 1.0);
+ glVertex2f(1.0, 1.0);
+
+ glTexCoord2f(0.0, 1.0);
+ glVertex2f(-1.0, 1.0);
+#endif
+
+ glEnd();
+}
+
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+ glScalef(5.0, 5.0, 5.0);
+ DrawObject();
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 );
+ /*glOrtho( -6.0, 6.0, -6.0, 6.0, 10.0, 100.0 );*/
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -70.0 );
+}
+
+
+static void ModeMenu(int entry)
+{
+ GLboolean enable0 = GL_FALSE, enable1 = GL_FALSE;
+ if (entry==TEX0) {
+ enable0 = GL_TRUE;
+ }
+ else if (entry==TEX1) {
+ enable1 = GL_TRUE;
+ }
+ else if (entry==TEXBOTH) {
+ enable0 = GL_TRUE;
+ enable1 = GL_TRUE;
+ }
+ else if (entry==ANIMATE) {
+ Animate = !Animate;
+ }
+ else if (entry==QUIT) {
+ exit(0);
+ }
+
+ if (entry != ANIMATE) {
+#ifdef GL_ARB_multitexture
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+#endif
+ if (enable0) {
+ glEnable(GL_TEXTURE_2D);
+ }
+ else
+ glDisable(GL_TEXTURE_2D);
+
+#ifdef GL_ARB_multitexture
+ glActiveTextureARB(GL_TEXTURE1_ARB);
+#endif
+ if (enable1) {
+ glEnable(GL_TEXTURE_2D);
+ }
+ else
+ glDisable(GL_TEXTURE_2D);
+ }
+
+ glutPostRedisplay();
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ float step = 3.0;
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot += step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot -= step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void load_tex(const char *fname, int channel)
+{
+ GLubyte *image;
+ GLenum format;
+ GLint w, h;
+ GLubyte *grayImage;
+ int i;
+ GLubyte table[256][4];
+
+ image = LoadRGBImage(fname, &w, &h, &format);
+ if (!image)
+ exit(1);
+
+ printf("%s %d x %d\n", fname, w, h);
+ grayImage = malloc(w * h * 1);
+ assert(grayImage);
+ for (i = 0; i < w * h; i++) {
+ int g = (image[i*3+0] + image[i*3+1] + image[i*3+2]) / 3;
+ assert(g < 256);
+ grayImage[i] = g;
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX, w, h, 0, GL_COLOR_INDEX,
+ GL_UNSIGNED_BYTE, grayImage);
+
+ for (i = 0; i < 256; i++) {
+ table[i][0] = channel ? i : 0;
+ table[i][1] = i;
+ table[i][2] = channel ? 0 : i;
+ table[i][3] = 255;
+ }
+
+ glColorTableEXT(GL_TEXTURE_2D, /* target */
+ GL_RGBA, /* internal format */
+ 256, /* table size */
+ GL_RGBA, /* table format */
+ GL_UNSIGNED_BYTE, /* table type */
+ table); /* the color table */
+
+ free(grayImage);
+ free(image);
+}
+
+
+
+static void Init( int argc, char *argv[] )
+{
+ GLuint texObj[2];
+ GLint units;
+
+ if (!glutExtensionSupported("GL_ARB_multitexture")) {
+ printf("Sorry, GL_ARB_multitexture not supported by this renderer.\n");
+ exit(1);
+ }
+ if (!glutExtensionSupported("GL_EXT_paletted_texture")) {
+ printf("Sorry, GL_EXT_paletted_texture not supported by this renderer.\n");
+ exit(1);
+ }
+
+ glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &units);
+ printf("%d texture units supported\n", units);
+
+ /* allocate two texture objects */
+ glGenTextures(2, texObj);
+
+ /* setup texture obj 0 */
+ glBindTexture(GL_TEXTURE_2D, texObj[0]);
+#ifdef LINEAR_FILTER
+ /* linear filtering looks much nicer but is much slower for Mesa */
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+foo
+#else
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+#endif
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ load_tex(TEXTURE_1_FILE, 0);
+#if 0
+ if (!LoadRGBMipmaps(TEXTURE_1_FILE, GL_RGB)) {
+ printf("Error: couldn't load texture image\n");
+ exit(1);
+ }
+#endif
+
+ /* setup texture obj 1 */
+ glBindTexture(GL_TEXTURE_2D, texObj[1]);
+#ifdef LINEAR_FILTER
+ /* linear filtering looks much nicer but is much slower for Mesa */
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+foo
+#else
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+#endif
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ load_tex(TEXTURE_2_FILE, 1);
+#if 0
+ if (!LoadRGBMipmaps(TEXTURE_2_FILE, GL_RGB)) {
+ printf("Error: couldn't load texture image\n");
+ exit(1);
+ }
+#endif
+
+ /* now bind the texture objects to the respective texture units */
+#ifdef GL_ARB_multitexture
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+ glBindTexture(GL_TEXTURE_2D, texObj[0]);
+ glActiveTextureARB(GL_TEXTURE1_ARB);
+ glBindTexture(GL_TEXTURE_2D, texObj[1]);
+#endif
+
+ glShadeModel(GL_FLAT);
+ glClearColor(0.3, 0.3, 0.4, 1.0);
+
+ ModeMenu(TEXBOTH);
+
+ if (argc > 1 && strcmp(argv[1], "-info")==0) {
+ 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));
+ }
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowSize( 300, 300 );
+ glutInitWindowPosition( 0, 0 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0] );
+
+ Init( argc, argv );
+
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ glutIdleFunc( Idle );
+
+ glutCreateMenu(ModeMenu);
+ glutAddMenuEntry("Texture 0", TEX0);
+ glutAddMenuEntry("Texture 1", TEX1);
+ glutAddMenuEntry("Multi-texture", TEXBOTH);
+ glutAddMenuEntry("Toggle Animation", ANIMATE);
+ glutAddMenuEntry("Quit", QUIT);
+ glutAttachMenu(GLUT_RIGHT_BUTTON);
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/multitexarray.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/multitexarray.c
new file mode 100644
index 000000000..b4fab004a
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/multitexarray.c
@@ -0,0 +1,238 @@
+/*
+ * Test vertex arrays and multitexture.
+ * Press 'a' to toggle vertex arrays on/off.
+ * When you run this program you should see a square with four colors:
+ *
+ * +------+------+
+ * |yellow| pink |
+ * +------+------+
+ * |green | blue |
+ * +------+------+
+ */
+
+
+#include <assert.h>
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "GL/glut.h"
+
+static GLuint Window = 0;
+
+static GLuint TexObj[2];
+static GLfloat Angle = 0.0f;
+static GLboolean UseArrays = 1, Anim = 0;
+
+static GLfloat VertArray[4][2] = {
+ {-1.2, -1.2}, {1.2, -1.2}, {1.2, 1.2}, {-1.2, 1.2}
+};
+
+static GLfloat Tex0Array[4][2] = {
+ {0, 0}, {1, 0}, {1, 1}, {0, 1}
+};
+
+static GLfloat Tex1Array[4][2] = {
+ {0, 0}, {1, 0}, {1, 1}, {0, 1}
+};
+
+
+static void init_arrays(void)
+{
+ glVertexPointer(2, GL_FLOAT, 0, VertArray);
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ glClientActiveTextureARB(GL_TEXTURE0_ARB);
+ glTexCoordPointer(2, GL_FLOAT, 0, Tex0Array);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ glClientActiveTextureARB(GL_TEXTURE1_ARB);
+ glTexCoordPointer(2, GL_FLOAT, 0, Tex1Array);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+}
+
+
+static void draw( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glColor3f( 0.0, 0.0, 0.0 );
+
+ /* draw first polygon */
+ glPushMatrix();
+ glRotatef( Angle, 0.0, 0.0, 1.0 );
+
+ if (UseArrays) {
+ glDrawArrays(GL_POLYGON, 0, 4);
+ }
+ else {
+ glBegin( GL_POLYGON );
+ glTexCoord2f( 0.0, 0.0 );
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0);
+ glVertex2f( -1.0, -1.0 );
+
+ glTexCoord2f( 1.0, 0.0 );
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0);
+ glVertex2f( 1.0, -1.0 );
+
+ glTexCoord2f( 1.0, 1.0 );
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0);
+ glVertex2f( 1.0, 1.0 );
+
+ glTexCoord2f( 0.0, 1.0 );
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 1.0);
+ glVertex2f( -1.0, 1.0 );
+ glEnd();
+ }
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+
+static void idle( void )
+{
+ Angle += 2.0;
+ glutPostRedisplay();
+}
+
+
+
+/* change view Angle, exit upon ESC */
+static void key(unsigned char k, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (k) {
+ case 'a':
+ UseArrays = !UseArrays;
+ printf("UseArrays: %d\n", UseArrays);
+ break;
+ case ' ':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 27:
+ glDeleteTextures( 2, TexObj );
+ glutDestroyWindow(Window);
+ exit(0);
+ }
+ glutPostRedisplay();
+}
+
+
+
+/* new window size or exposure */
+static void reshape( int width, int height )
+{
+ glViewport(0, 0, (GLint)width, (GLint)height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/
+ glFrustum( -2.0, 2.0, -2.0, 2.0, 6.0, 20.0 );
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -8.0 );
+}
+
+
+static void init( void )
+{
+ static int width=8, height=8;
+ GLubyte tex[64][3];
+ GLint i, j;
+
+ /* generate texture object IDs */
+ glGenTextures( 2, TexObj );
+
+ /*
+ * setup first texture object
+ */
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+ glEnable( GL_TEXTURE_2D );
+ glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD );
+
+ glBindTexture( GL_TEXTURE_2D, TexObj[0] );
+ assert(glIsTexture(TexObj[0]));
+
+ /* red over black */
+ for (i=0;i<height;i++) {
+ for (j=0;j<width;j++) {
+ int p = i*width+j;
+ if (i < height / 2) {
+ tex[p][0] = 0; tex[p][1] = 0; tex[p][2] = 0;
+ }
+ else {
+ tex[p][0] = 255; tex[p][1] = 0; tex[p][2] = 0;
+ }
+ }
+ }
+
+ glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+
+
+ /*
+ * setup second texture object
+ */
+ glActiveTextureARB(GL_TEXTURE1_ARB);
+ glEnable( GL_TEXTURE_2D );
+ glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD );
+
+ glBindTexture( GL_TEXTURE_2D, TexObj[1] );
+ assert(glIsTexture(TexObj[1]));
+
+ /* left=green, right = blue */
+ for (i=0;i<height;i++) {
+ for (j=0;j<width;j++) {
+ int p = i*width+j;
+ if (j < width / 2) {
+ tex[p][0] = 0; tex[p][1] = 255; tex[p][2] = 0;
+ }
+ else {
+ tex[p][0] = 0; tex[p][1] = 0; tex[p][2] = 255;
+ }
+ }
+ }
+ glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+}
+
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(300, 300);
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+
+ Window = glutCreateWindow("Texture Objects");
+ if (!Window) {
+ exit(1);
+ }
+
+ init();
+ init_arrays();
+
+ glutReshapeFunc( reshape );
+ glutKeyboardFunc( key );
+ if (Anim)
+ glutIdleFunc( idle );
+ glutDisplayFunc( draw );
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/multiwindow.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/multiwindow.c
new file mode 100644
index 000000000..e004b0336
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/multiwindow.c
@@ -0,0 +1,169 @@
+/* $Id: multiwindow.c,v 1.1 2001/08/21 14:25:31 brianp Exp $ */
+
+/*
+ * A skeleton/template GLUT program
+ *
+ * Written by Brian Paul and in the public domain.
+ */
+
+
+/*
+ * $Log: multiwindow.c,v $
+ * Revision 1.1 2001/08/21 14:25:31 brianp
+ * simple multi-window GLUT test prog
+ *
+ * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
+ * Imported sources
+ *
+ * Revision 1.2 1998/11/07 14:20:14 brianp
+ * added simple rotation, animation of cube
+ *
+ * Revision 1.1 1998/11/07 14:14:37 brianp
+ * Initial revision
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+static GLint Window[2];
+
+static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
+static GLboolean Anim = GL_TRUE;
+
+
+static void Idle( void )
+{
+ Xrot += 3.0;
+ Yrot += 4.0;
+ Zrot += 2.0;
+
+ glutSetWindow(Window[0]);
+ glutPostRedisplay();
+ glutSetWindow(Window[1]);
+ glutPostRedisplay();
+}
+
+
+static void Display0( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_DEPTH_TEST);
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+
+ glColor3f(0, 1, 0);
+ glutSolidCube(2.0);
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Display1( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+
+ glShadeModel(GL_FLAT);
+
+ glBegin(GL_TRIANGLE_STRIP);
+ glColor3f(1, 0, 0);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glColor3f(1, 0, 0);
+ glVertex2f( -1, 1);
+ glColor3f(0, 0, 1);
+ glVertex2f( 1, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'z':
+ Zrot -= step;
+ break;
+ case 'Z':
+ Zrot += step;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 400, 400 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ Window[0] = glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display0 );
+ glutIdleFunc(Idle);
+ printf("GL_RENDERER[0] = %s\n", (char *) glGetString(GL_RENDERER));
+
+ glutInitWindowPosition( 500, 0 );
+ glutInitWindowSize( 400, 400 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ Window[1] = glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display1 );
+ glutIdleFunc(Idle);
+ printf("GL_RENDERER[1] = %s\n", (char *) glGetString(GL_RENDERER));
+
+ glutMainLoop();
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/no_s3tc.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/no_s3tc.c
new file mode 100644
index 000000000..d3383ff98
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/no_s3tc.c
@@ -0,0 +1,97 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 (including the next
+ * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+/**
+ * \file no_s3tc.c
+ * Test program to verify the behavior of an OpenGL implementation when
+ * an application calls \c glCompressedTexImage2D with an unsupported (but
+ * valid) compression format. The most common example is calling it with
+ * \c GL_COMPRESSED_RGBA_S3TC_DXT1_EXT when GL_EXT_texture_compression_s3tc
+ * is not supported.
+ *
+ * This tests Mesa bug #1028405.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+
+static unsigned data[16];
+
+int
+main( int argc, char ** argv )
+{
+ float gl_version;
+ GLenum format;
+ GLuint size;
+ GLuint width;
+ GLenum err;
+
+
+ glutInit( & argc, argv );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
+
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 300, 300 );
+ glutCreateWindow( "No S3TC Test" );
+
+ gl_version = strtod( (const char *) glGetString( GL_VERSION ), NULL );
+ if ( ! glutExtensionSupported( "GL_ARB_texture_compression" )
+ && (gl_version < 1.3) ) {
+ fprintf( stderr, "Either OpenGL 1.3 or GL_ARB_texture_compression "
+ "must be supported.\n" );
+ return( EXIT_SUCCESS );
+ }
+
+
+ if ( ! glutExtensionSupported( "GL_EXT_texture_compression_s3tc" ) ) {
+ format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ width = 4;
+ size = 8;
+ }
+ else if ( ! glutExtensionSupported( "GL_3DFX_texture_compression_FXT1" ) ) {
+ format = GL_COMPRESSED_RGBA_FXT1_3DFX;
+ width = 8;
+ size = 16;
+ }
+ else {
+ fprintf( stderr, "Either GL_EXT_texture_compression_s3tc or "
+ "GL_3DFX_texture_compression_FXT1 must NOT be supported.\n" );
+ return( EXIT_SUCCESS );
+ }
+
+ glCompressedTexImage2D( GL_TEXTURE_2D, 0, format, width, 4, 0,
+ size, data );
+ err = glGetError();
+ if ( err != GL_INVALID_ENUM ) {
+ fprintf( stderr, "GL error 0x%04x should have been generated, but "
+ "0x%04x was generated instead.\n", GL_INVALID_ENUM, err );
+ }
+
+ return (err == GL_INVALID_ENUM) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/packedpixels.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/packedpixels.c
new file mode 100644
index 000000000..842cf7f34
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/packedpixels.c
@@ -0,0 +1,299 @@
+/*
+ * Test packed pixel formats for textures.
+ * Brian Paul
+ * 12 May 2004
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include <GL/glut.h>
+
+
+struct pixel_format {
+ const char *name;
+ GLenum format;
+ GLenum type;
+ GLint bytes;
+ GLuint redTexel, greenTexel;
+};
+
+static const struct pixel_format Formats[] = {
+
+ { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8",
+ GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000000, 0x00ff0000 },
+ { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8_REV",
+ GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x000000ff, 0x0000ff00 },
+ { "GL_RGBA/GL_UNSIGNED_INT_10_10_10_2",
+ GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00000, 0x3ff000 },
+ { "GL_RGBA/GL_UNSIGNED_INT_2_10_10_10_REV",
+ GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0x3ff, 0xffc00 },
+ { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4",
+ GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf000, 0x0f00 },
+ { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4_REV",
+ GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x000f, 0x00f0 },
+ { "GL_RGBA/GL_UNSIGNED_SHORT_5_5_5_1",
+ GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf800, 0x7c0 },
+ { "GL_RGBA/GL_UNSIGNED_SHORT_1_5_5_5_REV",
+ GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x1f, 0x3e0 },
+
+ { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8",
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff00, 0x00ff0000 },
+ { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV",
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x00ff0000, 0x0000ff00 },
+ { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4",
+ GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f0, 0x0f00 },
+ { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4_REV",
+ GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x0f00, 0x00f0 },
+ { "GL_BGRA/GL_UNSIGNED_SHORT_5_5_5_1",
+ GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3e, 0x7c0 },
+ { "GL_BGRA/GL_UNSIGNED_SHORT_1_5_5_5_REV",
+ GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x7c00, 0x3e0 },
+
+ { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8",
+ GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x000000ff, 0x0000ff00 },
+ { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8_REV",
+ GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000000, 0x00ff0000 },
+ { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4",
+ GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x000f, 0x00f0 },
+ { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4_REV",
+ GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf000, 0x0f00 },
+ { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_5_5_5_1",
+ GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x1, 0x3e },
+ { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_1_5_5_5_REV",
+ GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x8000, 0x7c00 },
+
+ { "GL_RGB/GL_UNSIGNED_SHORT_5_6_5",
+ GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 2, 0xf800, 0x7e0 },
+ { "GL_RGB/GL_UNSIGNED_SHORT_5_6_5_REV",
+ GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, 2, 0x1f, 0x7e0 },
+ { "GL_RGB/GL_UNSIGNED_BYTE_3_3_2",
+ GL_RGB, GL_UNSIGNED_BYTE_3_3_2, 1, 0xe0, 0x1c },
+ { "GL_RGB/GL_UNSIGNED_BYTE_2_3_3_REV",
+ GL_RGB, GL_UNSIGNED_BYTE_2_3_3_REV, 1, 0x7, 0x38 },
+
+ { NULL, 0, 0, 0, 0, 0 }
+};
+
+
+struct name_format {
+ const char *name;
+ GLenum format;
+};
+
+static const struct name_format IntFormats[] = {
+ { "GL_RGBA", GL_RGBA },
+ { "GL_RGBA2", GL_RGBA2 },
+ { "GL_RGBA4", GL_RGBA4 },
+ { "GL_RGB5_A1", GL_RGB5_A1 },
+ { "GL_RGBA8", GL_RGBA8 },
+ { "GL_RGBA12", GL_RGBA12 },
+ { "GL_RGBA16", GL_RGBA16 },
+ { "GL_RGB10_A2", GL_RGB10_A2 },
+
+ { "GL_RGB", GL_RGB },
+ { "GL_R3_G3_B2", GL_R3_G3_B2 },
+ { "GL_RGB4", GL_RGB4 },
+ { "GL_RGB5", GL_RGB5 },
+ { "GL_RGB8", GL_RGB8 },
+ { "GL_RGB10", GL_RGB10 },
+ { "GL_RGB12", GL_RGB12 },
+ { "GL_RGB16", GL_RGB16 },
+
+};
+
+#define NUM_INT_FORMATS (sizeof(IntFormats) / sizeof(IntFormats[0]))
+static GLuint CurFormat = 0;
+
+
+static void
+PrintString(const char *s)
+{
+ while (*s) {
+ glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
+ s++;
+ }
+}
+
+
+static void
+MakeTexture(const struct pixel_format *format, GLenum intFormat, GLboolean swap)
+{
+ GLubyte texBuffer[1000];
+ int i;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, swap);
+
+ if (format->bytes == 1) {
+ for (i = 0; i < 8; i++) {
+ texBuffer[i] = format->redTexel;
+ }
+ for (i = 8; i < 16; i++) {
+ texBuffer[i] = format->greenTexel;
+ }
+ }
+ else if (format->bytes == 2) {
+ GLushort *us = (GLushort *) texBuffer;
+ for (i = 0; i < 8; i++) {
+ us[i] = format->redTexel;
+ }
+ for (i = 8; i < 16; i++) {
+ us[i] = format->greenTexel;
+ }
+ if (swap) {
+ for (i = 0; i < 16; i++)
+ us[i] = (us[i] << 8) | (us[i] >> 8);
+ }
+ }
+ else if (format->bytes == 4) {
+ GLuint *ui = (GLuint *) texBuffer;
+ for (i = 0; i < 8; i++) {
+ ui[i] = format->redTexel;
+ }
+ for (i = 8; i < 16; i++) {
+ ui[i] = format->greenTexel;
+ }
+ if (swap) {
+ for (i = 0; i < 16; i++) {
+ GLuint b = ui[i];
+ ui[i] = (b >> 24)
+ | ((b >> 8) & 0xff00)
+ | ((b << 8) & 0xff0000)
+ | ((b << 24) & 0xff000000);
+ }
+ }
+ }
+ else {
+ abort();
+ }
+ glTexImage2D(GL_TEXTURE_2D, 0, intFormat, 4, 4, 0,
+ format->format, format->type, texBuffer);
+
+ if (glGetError()) {
+ printf("GL Error for %s\n", format->name);
+ memset(texBuffer, 255, 1000);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, texBuffer);
+ }
+}
+
+
+
+static void
+Draw(void)
+{
+ char s[1000];
+ int w = 350, h = 20;
+ int i, swap;
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ for (swap = 0; swap < 2; swap++) {
+ for (i = 0; Formats[i].name; i++) {
+ glPushMatrix();
+ glTranslatef(swap * (w + 2), i * (h + 2), 0);
+
+ MakeTexture(Formats + i, IntFormats[CurFormat].format, swap);
+
+ glEnable(GL_TEXTURE_2D);
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0); glVertex2f(0, 0);
+ glTexCoord2f(1, 0); glVertex2f(w, 0);
+ glTexCoord2f(1, 1); glVertex2f(w, h);
+ glTexCoord2f(0, 1); glVertex2f(0, h);
+ glEnd();
+
+ glDisable(GL_TEXTURE_2D);
+ glColor3f(0, 0, 0);
+ glRasterPos2i(8, 6);
+ PrintString(Formats[i].name);
+
+ glPopMatrix();
+ }
+ }
+
+ glPushMatrix();
+ glTranslatef(2, i * (h + 2), 0);
+ glColor3f(1, 1, 1);
+ glRasterPos2i(8, 6);
+ PrintString("Normal");
+ glRasterPos2i(w + 2, 6);
+ PrintString("Byte Swapped");
+ glPopMatrix();
+
+ glPushMatrix();
+ glTranslatef(2, (i + 1) * (h + 2), 0);
+ glRasterPos2i(8, 6);
+ sprintf(s, "Internal Texture Format [f/F]: %s (%d of %d)",
+ IntFormats[CurFormat].name, CurFormat + 1, NUM_INT_FORMATS);
+ PrintString(s);
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, width, 0, height, -1, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'F':
+ if (CurFormat == 0)
+ CurFormat = NUM_INT_FORMATS - 1;
+ else
+ CurFormat--;
+ break;
+ case 'f':
+ CurFormat++;
+ if (CurFormat == NUM_INT_FORMATS)
+ CurFormat = 0;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(700, 800);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/pbo.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/pbo.c
new file mode 100644
index 000000000..a74e8e148
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/pbo.c
@@ -0,0 +1,283 @@
+/*
+ * GL_EXT_pixel_buffer_object test
+ *
+ * Brian Paul
+ * 11 March 2004
+ */
+
+#define GL_GLEXT_PROTOTYPES
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+#include "../util/readtex.c" /* a hack, I know */
+
+#define IMAGE_FILE "../images/girl.rgb"
+
+static int ImgWidth, ImgHeight;
+static GLenum ImgFormat;
+static GLubyte *Image = NULL;
+
+static int APosX, APosY; /* simple drawpixels */
+static int BPosX, BPosY; /* read/draw pixels */
+static int CPosX, CPosY; /* copypixels */
+
+static GLboolean DrawFront = GL_FALSE;
+static GLboolean ScaleAndBias = GL_FALSE;
+static GLboolean Benchmark = GL_FALSE;
+
+static GLuint DrawPBO, TempPBO;
+
+
+static GLenum ReadFormat = GL_RGBA;
+static GLenum ReadType = GL_UNSIGNED_BYTE;
+
+
+
+
+static void
+Reset( void )
+{
+ APosX = 5; APosY = 20;
+ BPosX = APosX + ImgWidth + 5; BPosY = 20;
+ CPosX = BPosX + ImgWidth + 5; CPosY = 20;
+}
+
+
+static void
+PrintString(const char *s)
+{
+ while (*s) {
+ glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
+ s++;
+ }
+}
+
+
+static void
+SetupPixelTransfer(GLboolean invert)
+{
+ if (invert) {
+ glPixelTransferf(GL_RED_SCALE, -1.0);
+ glPixelTransferf(GL_RED_BIAS, 1.0);
+ glPixelTransferf(GL_GREEN_SCALE, -1.0);
+ glPixelTransferf(GL_GREEN_BIAS, 1.0);
+ glPixelTransferf(GL_BLUE_SCALE, -1.0);
+ glPixelTransferf(GL_BLUE_BIAS, 1.0);
+ }
+ else {
+ glPixelTransferf(GL_RED_SCALE, 1.0);
+ glPixelTransferf(GL_RED_BIAS, 0.0);
+ glPixelTransferf(GL_GREEN_SCALE, 1.0);
+ glPixelTransferf(GL_GREEN_BIAS, 0.0);
+ glPixelTransferf(GL_BLUE_SCALE, 1.0);
+ glPixelTransferf(GL_BLUE_BIAS, 0.0);
+ }
+}
+
+
+static void
+Display( void )
+{
+ glClearColor(.3, .3, .3, 1);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ /** Unbind UNPACK pixel buffer before calling glBitmap */
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
+
+ glRasterPos2i(5, ImgHeight+25);
+ PrintString("f = toggle front/back s = toggle scale/bias b = benchmark");
+
+ glRasterPos2i(5, ImgHeight+40);
+ PrintString("GL_EXT_pixel_buffer_object test");
+
+ /* draw original image */
+ glRasterPos2i(APosX, 5);
+ PrintString("Original");
+ glRasterPos2i(APosX, APosY);
+ glEnable(GL_DITHER);
+ SetupPixelTransfer(GL_FALSE);
+ /*** Draw from the DrawPBO */
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
+ glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, 0);
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
+
+ /* do readpixels, drawpixels */
+ glRasterPos2i(BPosX, 5);
+ PrintString("Read/DrawPixels");
+ SetupPixelTransfer(ScaleAndBias);
+ /*** read into the Temp PBO */
+ glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, TempPBO);
+ if (Benchmark) {
+ GLint reads = 0;
+ GLint endTime;
+ GLint startTime = glutGet(GLUT_ELAPSED_TIME);
+ GLdouble seconds, pixelsPerSecond;
+ printf("Benchmarking...\n");
+ do {
+ glReadPixels(APosX, APosY, ImgWidth, ImgHeight,
+ ReadFormat, ReadType, 0);
+ reads++;
+ endTime = glutGet(GLUT_ELAPSED_TIME);
+ } while (endTime - startTime < 4000); /* 4 seconds */
+ seconds = (double) (endTime - startTime) / 1000.0;
+ pixelsPerSecond = reads * ImgWidth * ImgHeight / seconds;
+ printf("Result: %d reads in %f seconds = %f pixels/sec\n",
+ reads, seconds, pixelsPerSecond);
+ Benchmark = GL_FALSE;
+ }
+ else {
+ glReadPixels(APosX, APosY, ImgWidth, ImgHeight,
+ ReadFormat, ReadType, 0);
+ }
+ glRasterPos2i(BPosX, BPosY);
+ glDisable(GL_DITHER);
+ SetupPixelTransfer(GL_FALSE);
+ /*** draw from the Temp PBO */
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, TempPBO);
+ glDrawPixels(ImgWidth, ImgHeight, ReadFormat, ReadType, 0);
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
+
+ /* do copypixels */
+ glRasterPos2i(CPosX, 5);
+ PrintString("CopyPixels");
+ glRasterPos2i(CPosX, CPosY);
+ glDisable(GL_DITHER);
+ SetupPixelTransfer(ScaleAndBias);
+ glCopyPixels(APosX, APosY, ImgWidth, ImgHeight, GL_COLOR);
+
+ if (!DrawFront)
+ glutSwapBuffers();
+ else
+ glFinish();
+}
+
+
+static void
+Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho( 0.0, width, 0.0, height, -1.0, 1.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+}
+
+
+static void
+Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'b':
+ Benchmark = GL_TRUE;
+ break;
+ case 's':
+ ScaleAndBias = !ScaleAndBias;
+ break;
+ case 'f':
+ DrawFront = !DrawFront;
+ if (DrawFront) {
+ glDrawBuffer(GL_FRONT);
+ glReadBuffer(GL_FRONT);
+ }
+ else {
+ glDrawBuffer(GL_BACK);
+ glReadBuffer(GL_BACK);
+ }
+ printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK");
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init( GLboolean ciMode )
+{
+ printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ if (!glutExtensionSupported("GL_EXT_pixel_buffer_object")) {
+ printf("Sorry, this demo requires GL_EXT_pixel_buffer_object\n");
+ exit(0);
+ }
+
+ Image = LoadRGBImage( IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat );
+ if (!Image) {
+ printf("Couldn't read %s\n", IMAGE_FILE);
+ exit(0);
+ }
+
+ if (ciMode) {
+ /* Convert RGB image to grayscale */
+ GLubyte *indexImage = (GLubyte *) malloc( ImgWidth * ImgHeight );
+ GLint i;
+ for (i=0; i<ImgWidth*ImgHeight; i++) {
+ int gray = Image[i*3] + Image[i*3+1] + Image[i*3+2];
+ indexImage[i] = gray / 3;
+ }
+ free(Image);
+ Image = indexImage;
+ ImgFormat = GL_COLOR_INDEX;
+
+ for (i=0;i<255;i++) {
+ float g = i / 255.0;
+ glutSetColor(i, g, g, g);
+ }
+ }
+
+ printf("Loaded %d by %d image\n", ImgWidth, ImgHeight );
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, ImgWidth);
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ glPixelStorei(GL_PACK_ROW_LENGTH, ImgWidth);
+
+ Reset();
+
+ /* put image into DrawPBO */
+ glGenBuffersARB(1, &DrawPBO);
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
+ glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT,
+ ImgWidth * ImgHeight * 4, Image, GL_STATIC_DRAW);
+
+ /* Setup TempPBO - used for glReadPixels & glDrawPixels */
+ glGenBuffersARB(1, &TempPBO);
+ glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, TempPBO);
+ glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT,
+ ImgWidth * ImgHeight * 4, NULL, GL_DYNAMIC_COPY);
+
+}
+
+
+int
+main( int argc, char *argv[] )
+{
+ GLboolean ciMode = GL_FALSE;
+ if (argc > 1 && strcmp(argv[1], "-ci")==0) {
+ ciMode = GL_TRUE;
+ }
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 750, 250 );
+ if (ciMode)
+ glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE );
+ else
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0]);
+ Init(ciMode);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/projtex.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/projtex.c
new file mode 100644
index 000000000..e3ef948ab
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/projtex.c
@@ -0,0 +1,1028 @@
+
+/* projtex.c - by David Yu and David Blythe, SGI */
+
+/**
+ ** Demonstrates simple projective texture mapping.
+ **
+ ** Button1 changes view, Button2 moves texture.
+ **
+ ** (See: Segal, Korobkin, van Widenfelt, Foran, and Haeberli
+ ** "Fast Shadows and Lighting Effects Using Texture Mapping", SIGGRAPH '92)
+ **
+ ** 1994,1995 -- David G Yu
+ **
+ ** cc -o projtex projtex.c texture.c -lglut -lGLU -lGL -lX11 -lm
+ **/
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#if 0
+#include "texture.h"
+#else
+#include "../util/readtex.c"
+#endif
+
+
+/* Some <math.h> files do not define M_PI... */
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#define MAX_TEX 4
+int NumTextures = 1;
+
+int winWidth, winHeight;
+
+GLboolean redrawContinuously = GL_FALSE;
+
+float angle, axis[3];
+enum MoveModes {
+ MoveNone, MoveView, MoveObject, MoveTexture
+};
+enum MoveModes mode = MoveNone;
+
+GLfloat objectXform[4][4];
+GLfloat textureXform[MAX_TEX][4][4];
+
+void (*drawObject) (void);
+void (*loadTexture) (void);
+GLboolean textureEnabled = GL_TRUE;
+GLboolean showProjection = GL_TRUE;
+GLboolean linearFilter = GL_TRUE;
+
+char *texFilename[MAX_TEX] = {
+ "../images/girl.rgb",
+ "../images/tile.rgb",
+ "../images/bw.rgb",
+ "../images/reflect.rgb"
+};
+
+
+GLfloat zoomFactor = 1.0;
+
+/*****************************************************************/
+
+
+void ActiveTexture(int i)
+{
+ glActiveTextureARB(i);
+}
+
+
+/* matrix = identity */
+void
+matrixIdentity(GLfloat matrix[16])
+{
+ matrix[0] = 1.0;
+ matrix[1] = 0.0;
+ matrix[2] = 0.0;
+ matrix[3] = 0.0;
+ matrix[4] = 0.0;
+ matrix[5] = 1.0;
+ matrix[6] = 0.0;
+ matrix[7] = 0.0;
+ matrix[8] = 0.0;
+ matrix[9] = 0.0;
+ matrix[10] = 1.0;
+ matrix[11] = 0.0;
+ matrix[12] = 0.0;
+ matrix[13] = 0.0;
+ matrix[14] = 0.0;
+ matrix[15] = 1.0;
+}
+
+/* matrix2 = transpose(matrix1) */
+void
+matrixTranspose(GLfloat matrix2[16], GLfloat matrix1[16])
+{
+ matrix2[0] = matrix1[0];
+ matrix2[1] = matrix1[4];
+ matrix2[2] = matrix1[8];
+ matrix2[3] = matrix1[12];
+
+ matrix2[4] = matrix1[1];
+ matrix2[5] = matrix1[5];
+ matrix2[6] = matrix1[9];
+ matrix2[7] = matrix1[13];
+
+ matrix2[8] = matrix1[2];
+ matrix2[9] = matrix1[6];
+ matrix2[10] = matrix1[10];
+ matrix2[11] = matrix1[14];
+
+ matrix2[12] = matrix1[3];
+ matrix2[13] = matrix1[7];
+ matrix2[14] = matrix1[14];
+ matrix2[15] = matrix1[15];
+}
+
+/*****************************************************************/
+
+/* load SGI .rgb image (pad with a border of the specified width and color) */
+#if 0
+static void
+imgLoad(char *filenameIn, int borderIn, GLfloat borderColorIn[4],
+ int *wOut, int *hOut, GLubyte ** imgOut)
+{
+ int border = borderIn;
+ int width, height;
+ int w, h;
+ GLubyte *image, *img, *p;
+ int i, j, components;
+
+ image = (GLubyte *) read_texture(filenameIn, &width, &height, &components);
+ w = width + 2 * border;
+ h = height + 2 * border;
+ img = (GLubyte *) calloc(w * h, 4 * sizeof(unsigned char));
+
+ p = img;
+ for (j = -border; j < height + border; ++j) {
+ for (i = -border; i < width + border; ++i) {
+ if (0 <= j && j <= height - 1 && 0 <= i && i <= width - 1) {
+ p[0] = image[4 * (j * width + i) + 0];
+ p[1] = image[4 * (j * width + i) + 1];
+ p[2] = image[4 * (j * width + i) + 2];
+ p[3] = 0xff;
+ } else {
+ p[0] = borderColorIn[0] * 0xff;
+ p[1] = borderColorIn[1] * 0xff;
+ p[2] = borderColorIn[2] * 0xff;
+ p[3] = borderColorIn[3] * 0xff;
+ }
+ p += 4;
+ }
+ }
+ free(image);
+ *wOut = w;
+ *hOut = h;
+ *imgOut = img;
+}
+#endif
+
+
+/*****************************************************************/
+
+/* Load the image file specified on the command line as the current texture */
+void
+loadImageTextures(void)
+{
+ GLfloat borderColor[4] =
+ {1.0, 1.0, 1.0, 1.0};
+ int tex;
+
+ for (tex = 0; tex < NumTextures; tex++) {
+ GLubyte *image, *texData3, *texData4;
+ GLint imgWidth, imgHeight;
+ GLenum imgFormat;
+ int i, j;
+
+ printf("loading %s\n", texFilename[tex]);
+ image = LoadRGBImage(texFilename[tex], &imgWidth, &imgHeight, &imgFormat);
+ if (!image) {
+ printf("can't find %s\n", texFilename[tex]);
+ exit(1);
+ }
+ assert(imgFormat == GL_RGB);
+
+ /* scale to 256x256 */
+ texData3 = malloc(256 * 256 * 4);
+ texData4 = malloc(256 * 256 * 4);
+ assert(texData3);
+ assert(texData4);
+ gluScaleImage(imgFormat, imgWidth, imgHeight, GL_UNSIGNED_BYTE, image,
+ 256, 256, GL_UNSIGNED_BYTE, texData3);
+
+ /* convert to rgba */
+ for (i = 0; i < 256 * 256; i++) {
+ texData4[i*4+0] = texData3[i*3+0];
+ texData4[i*4+1] = texData3[i*3+1];
+ texData4[i*4+2] = texData3[i*3+2];
+ texData4[i*4+3] = 128;
+ }
+
+ /* put transparent border around image */
+ for (i = 0; i < 256; i++) {
+ texData4[i*4+0] = 255;
+ texData4[i*4+1] = 255;
+ texData4[i*4+2] = 255;
+ texData4[i*4+3] = 0;
+ }
+ j = 256 * 255 * 4;
+ for (i = 0; i < 256; i++) {
+ texData4[j + i*4+0] = 255;
+ texData4[j + i*4+1] = 255;
+ texData4[j + i*4+2] = 255;
+ texData4[j + i*4+3] = 0;
+ }
+ for (i = 0; i < 256; i++) {
+ j = i * 256 * 4;
+ texData4[j+0] = 255;
+ texData4[j+1] = 255;
+ texData4[j+2] = 255;
+ texData4[j+3] = 0;
+ }
+ for (i = 0; i < 256; i++) {
+ j = i * 256 * 4 + 255 * 4;
+ texData4[j+0] = 255;
+ texData4[j+1] = 255;
+ texData4[j+2] = 255;
+ texData4[j+3] = 0;
+ }
+
+ ActiveTexture(GL_TEXTURE0_ARB + tex);
+ glBindTexture(GL_TEXTURE_2D, tex + 1);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, texData4);
+
+ if (linearFilter) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ } else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+ glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
+ }
+}
+
+/* Create a simple spotlight pattern and make it the current texture */
+void
+loadSpotlightTexture(void)
+{
+ static int texWidth = 64, texHeight = 64;
+ static GLubyte *texData;
+ GLfloat borderColor[4] =
+ {0.1, 0.1, 0.1, 1.0};
+
+ if (!texData) {
+ GLubyte *p;
+ int i, j;
+
+ texData = (GLubyte *) malloc(texWidth * texHeight * 4 * sizeof(GLubyte));
+
+ p = texData;
+ for (j = 0; j < texHeight; ++j) {
+ float dy = (texHeight * 0.5 - j + 0.5) / (texHeight * 0.5);
+
+ for (i = 0; i < texWidth; ++i) {
+ float dx = (texWidth * 0.5 - i + 0.5) / (texWidth * 0.5);
+ float r = cos(M_PI / 2.0 * sqrt(dx * dx + dy * dy));
+ float c;
+
+ r = (r < 0) ? 0 : r * r;
+ c = 0xff * (r + borderColor[0]);
+ p[0] = (c <= 0xff) ? c : 0xff;
+ c = 0xff * (r + borderColor[1]);
+ p[1] = (c <= 0xff) ? c : 0xff;
+ c = 0xff * (r + borderColor[2]);
+ p[2] = (c <= 0xff) ? c : 0xff;
+ c = 0xff * (r + borderColor[3]);
+ p[3] = (c <= 0xff) ? c : 0xff;
+ p += 4;
+ }
+ }
+ }
+ if (linearFilter) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ } else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+ glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
+ gluBuild2DMipmaps(GL_TEXTURE_2D, 4, texWidth, texHeight,
+ GL_RGBA, GL_UNSIGNED_BYTE, texData);
+}
+
+/*****************************************************************/
+
+void
+checkErrors(void)
+{
+ GLenum error;
+ while ((error = glGetError()) != GL_NO_ERROR) {
+ fprintf(stderr, "Error: %s\n", (char *) gluErrorString(error));
+ }
+}
+
+void
+drawCube(void)
+{
+ glBegin(GL_QUADS);
+
+ glNormal3f(-1.0, 0.0, 0.0);
+ glColor3f(0.80, 0.50, 0.50);
+ glVertex3f(-0.5, -0.5, -0.5);
+ glVertex3f(-0.5, -0.5, 0.5);
+ glVertex3f(-0.5, 0.5, 0.5);
+ glVertex3f(-0.5, 0.5, -0.5);
+
+ glNormal3f(1.0, 0.0, 0.0);
+ glColor3f(0.50, 0.80, 0.50);
+ glVertex3f(0.5, 0.5, 0.5);
+ glVertex3f(0.5, -0.5, 0.5);
+ glVertex3f(0.5, -0.5, -0.5);
+ glVertex3f(0.5, 0.5, -0.5);
+
+ glNormal3f(0.0, -1.0, 0.0);
+ glColor3f(0.50, 0.50, 0.80);
+ glVertex3f(-0.5, -0.5, -0.5);
+ glVertex3f(0.5, -0.5, -0.5);
+ glVertex3f(0.5, -0.5, 0.5);
+ glVertex3f(-0.5, -0.5, 0.5);
+
+ glNormal3f(0.0, 1.0, 0.0);
+ glColor3f(0.50, 0.80, 0.80);
+ glVertex3f(0.5, 0.5, 0.5);
+ glVertex3f(0.5, 0.5, -0.5);
+ glVertex3f(-0.5, 0.5, -0.5);
+ glVertex3f(-0.5, 0.5, 0.5);
+
+ glNormal3f(0.0, 0.0, -1.0);
+ glColor3f(0.80, 0.50, 0.80);
+ glVertex3f(-0.5, -0.5, -0.5);
+ glVertex3f(-0.5, 0.5, -0.5);
+ glVertex3f(0.5, 0.5, -0.5);
+ glVertex3f(0.5, -0.5, -0.5);
+
+ glNormal3f(0.0, 0.0, 1.0);
+ glColor3f(1.00, 0.80, 0.50);
+ glVertex3f(0.5, 0.5, 0.5);
+ glVertex3f(-0.5, 0.5, 0.5);
+ glVertex3f(-0.5, -0.5, 0.5);
+ glVertex3f(0.5, -0.5, 0.5);
+ glEnd();
+}
+
+void
+drawDodecahedron(void)
+{
+#define A (0.5 * 1.61803) /* (sqrt(5) + 1) / 2 */
+#define B (0.5 * 0.61803) /* (sqrt(5) - 1) / 2 */
+#define C (0.5 * 1.0)
+ GLfloat vertexes[20][3] =
+ {
+ {-A, 0.0, B},
+ {-A, 0.0, -B},
+ {A, 0.0, -B},
+ {A, 0.0, B},
+ {B, -A, 0.0},
+ {-B, -A, 0.0},
+ {-B, A, 0.0},
+ {B, A, 0.0},
+ {0.0, B, -A},
+ {0.0, -B, -A},
+ {0.0, -B, A},
+ {0.0, B, A},
+ {-C, -C, C},
+ {-C, -C, -C},
+ {C, -C, -C},
+ {C, -C, C},
+ {-C, C, C},
+ {-C, C, -C},
+ {C, C, -C},
+ {C, C, C},
+ };
+#undef A
+#undef B
+#undef C
+ GLint polygons[12][5] =
+ {
+ {0, 12, 10, 11, 16},
+ {1, 17, 8, 9, 13},
+ {2, 14, 9, 8, 18},
+ {3, 19, 11, 10, 15},
+ {4, 14, 2, 3, 15},
+ {5, 12, 0, 1, 13},
+ {6, 17, 1, 0, 16},
+ {7, 19, 3, 2, 18},
+ {8, 17, 6, 7, 18},
+ {9, 14, 4, 5, 13},
+ {10, 12, 5, 4, 15},
+ {11, 19, 7, 6, 16},
+ };
+ int i;
+
+ glColor3f(0.75, 0.75, 0.75);
+ for (i = 0; i < 12; ++i) {
+ GLfloat *p0, *p1, *p2, d;
+ GLfloat u[3], v[3], n[3];
+
+ p0 = &vertexes[polygons[i][0]][0];
+ p1 = &vertexes[polygons[i][1]][0];
+ p2 = &vertexes[polygons[i][2]][0];
+
+ u[0] = p2[0] - p1[0];
+ u[1] = p2[1] - p1[1];
+ u[2] = p2[2] - p1[2];
+
+ v[0] = p0[0] - p1[0];
+ v[1] = p0[1] - p1[1];
+ v[2] = p0[2] - p1[2];
+
+ n[0] = u[1] * v[2] - u[2] * v[1];
+ n[1] = u[2] * v[0] - u[0] * v[2];
+ n[2] = u[0] * v[1] - u[1] * v[0];
+
+ d = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
+ n[0] *= d;
+ n[1] *= d;
+ n[2] *= d;
+
+ glBegin(GL_POLYGON);
+ glNormal3fv(n);
+ glVertex3fv(p0);
+ glVertex3fv(p1);
+ glVertex3fv(p2);
+ glVertex3fv(vertexes[polygons[i][3]]);
+ glVertex3fv(vertexes[polygons[i][4]]);
+ glEnd();
+ }
+}
+
+void
+drawSphere(void)
+{
+ int numMajor = 24;
+ int numMinor = 32;
+ float radius = 0.8;
+ double majorStep = (M_PI / numMajor);
+ double minorStep = (2.0 * M_PI / numMinor);
+ int i, j;
+
+ glColor3f(0.50, 0.50, 0.50);
+ for (i = 0; i < numMajor; ++i) {
+ double a = i * majorStep;
+ double b = a + majorStep;
+ double r0 = radius * sin(a);
+ double r1 = radius * sin(b);
+ GLfloat z0 = radius * cos(a);
+ GLfloat z1 = radius * cos(b);
+
+ glBegin(GL_TRIANGLE_STRIP);
+ for (j = 0; j <= numMinor; ++j) {
+ double c = j * minorStep;
+ GLfloat x = cos(c);
+ GLfloat y = sin(c);
+
+ glNormal3f((x * r0) / radius, (y * r0) / radius, z0 / radius);
+ glTexCoord2f(j / (GLfloat) numMinor, i / (GLfloat) numMajor);
+ glVertex3f(x * r0, y * r0, z0);
+
+ glNormal3f((x * r1) / radius, (y * r1) / radius, z1 / radius);
+ glTexCoord2f(j / (GLfloat) numMinor, (i + 1) / (GLfloat) numMajor);
+ glVertex3f(x * r1, y * r1, z1);
+ }
+ glEnd();
+ }
+}
+
+/*****************************************************************/
+
+float xmin = -0.035, xmax = 0.035;
+float ymin = -0.035, ymax = 0.035;
+float nnear = 0.1;
+float ffar = 1.9;
+float distance = -1.0;
+
+static void
+loadTextureProjection(int texUnit, GLfloat m[16])
+{
+ GLfloat mInverse[4][4];
+
+ /* Should use true inverse, but since m consists only of rotations, we can
+ just use the transpose. */
+ matrixTranspose((GLfloat *) mInverse, m);
+
+ ActiveTexture(GL_TEXTURE0_ARB + texUnit);
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glTranslatef(0.5, 0.5, 0.0);
+ glScalef(0.5, 0.5, 1.0);
+ glFrustum(xmin, xmax, ymin, ymax, nnear, ffar);
+ glTranslatef(0.0, 0.0, distance);
+ glMultMatrixf((GLfloat *) mInverse);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void
+drawTextureProjection(void)
+{
+ float t = ffar / nnear;
+ GLfloat n[4][3];
+ GLfloat f[4][3];
+
+ n[0][0] = xmin;
+ n[0][1] = ymin;
+ n[0][2] = -(nnear + distance);
+
+ n[1][0] = xmax;
+ n[1][1] = ymin;
+ n[1][2] = -(nnear + distance);
+
+ n[2][0] = xmax;
+ n[2][1] = ymax;
+ n[2][2] = -(nnear + distance);
+
+ n[3][0] = xmin;
+ n[3][1] = ymax;
+ n[3][2] = -(nnear + distance);
+
+ f[0][0] = xmin * t;
+ f[0][1] = ymin * t;
+ f[0][2] = -(ffar + distance);
+
+ f[1][0] = xmax * t;
+ f[1][1] = ymin * t;
+ f[1][2] = -(ffar + distance);
+
+ f[2][0] = xmax * t;
+ f[2][1] = ymax * t;
+ f[2][2] = -(ffar + distance);
+
+ f[3][0] = xmin * t;
+ f[3][1] = ymax * t;
+ f[3][2] = -(ffar + distance);
+
+ glColor3f(1.0, 1.0, 0.0);
+ glBegin(GL_LINE_LOOP);
+ glVertex3fv(n[0]);
+ glVertex3fv(n[1]);
+ glVertex3fv(n[2]);
+ glVertex3fv(n[3]);
+ glVertex3fv(f[3]);
+ glVertex3fv(f[2]);
+ glVertex3fv(f[1]);
+ glVertex3fv(f[0]);
+ glVertex3fv(n[0]);
+ glVertex3fv(n[1]);
+ glVertex3fv(f[1]);
+ glVertex3fv(f[0]);
+ glVertex3fv(f[3]);
+ glVertex3fv(f[2]);
+ glVertex3fv(n[2]);
+ glVertex3fv(n[3]);
+ glEnd();
+}
+
+/*****************************************************************/
+
+void
+initialize(void)
+{
+ GLfloat light0Pos[4] =
+ {0.3, 0.3, 0.0, 1.0};
+ GLfloat matAmb[4] =
+ {0.01, 0.01, 0.01, 1.00};
+ GLfloat matDiff[4] =
+ {0.65, 0.65, 0.65, 1.00};
+ GLfloat matSpec[4] =
+ {0.30, 0.30, 0.30, 1.00};
+ GLfloat matShine = 10.0;
+ GLfloat eyePlaneS[] =
+ {1.0, 0.0, 0.0, 0.0};
+ GLfloat eyePlaneT[] =
+ {0.0, 1.0, 0.0, 0.0};
+ GLfloat eyePlaneR[] =
+ {0.0, 0.0, 1.0, 0.0};
+ GLfloat eyePlaneQ[] =
+ {0.0, 0.0, 0.0, 1.0};
+ int i;
+
+ /* Setup Misc. */
+ glClearColor(0.41, 0.41, 0.31, 0.0);
+
+ glEnable(GL_DEPTH_TEST);
+
+ /* glLineWidth(2.0);*/
+
+ glCullFace(GL_FRONT);
+ glEnable(GL_CULL_FACE);
+
+ glMatrixMode(GL_PROJECTION);
+ glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 3);
+ glMatrixMode(GL_MODELVIEW);
+ glTranslatef(0, 0, -2);
+
+ matrixIdentity((GLfloat *) objectXform);
+ for (i = 0; i < NumTextures; i++) {
+ matrixIdentity((GLfloat *) textureXform[i]);
+ }
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0, 1, 0, 1, -1, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glRasterPos2i(0, 0);
+
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+
+ /* Setup Lighting */
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, matAmb);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matSpec);
+ glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, matShine);
+
+ glEnable(GL_COLOR_MATERIAL);
+
+ glLightfv(GL_LIGHT0, GL_POSITION, light0Pos);
+ glEnable(GL_LIGHT0);
+
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
+ glEnable(GL_LIGHTING);
+
+ /* Setup Texture */
+
+ (*loadTexture) ();
+
+
+ for (i = 0; i < NumTextures; i++) {
+ ActiveTexture(GL_TEXTURE0_ARB + i);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+ glTexGenfv(GL_S, GL_EYE_PLANE, eyePlaneS);
+
+ glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+ glTexGenfv(GL_T, GL_EYE_PLANE, eyePlaneT);
+
+ glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+ glTexGenfv(GL_R, GL_EYE_PLANE, eyePlaneR);
+
+ glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+ glTexGenfv(GL_Q, GL_EYE_PLANE, eyePlaneQ);
+ }
+}
+
+void
+display(void)
+{
+ int i;
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ if (textureEnabled) {
+ if (mode == MoveTexture || mode == MoveView) {
+ /* Have OpenGL compute the new transformation (simple but slow). */
+ for (i = 0; i < NumTextures; i++) {
+ glPushMatrix();
+ glLoadIdentity();
+#if 0
+ if (i & 1)
+ glRotatef(angle, axis[0], axis[1], axis[2]);
+ else
+#endif
+ glRotatef(angle*(i+1), axis[0], axis[1], axis[2]);
+
+ glMultMatrixf((GLfloat *) textureXform[i]);
+ glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) textureXform[i]);
+ glPopMatrix();
+ }
+ }
+ for (i = 0; i < NumTextures; i++) {
+ loadTextureProjection(i, (GLfloat *) textureXform[i]);
+ }
+
+ if (showProjection) {
+ for (i = 0; i < NumTextures; i++) {
+ ActiveTexture(GL_TEXTURE0_ARB + i);
+ glPushMatrix();
+ glMultMatrixf((GLfloat *) textureXform[i]);
+ glDisable(GL_LIGHTING);
+ drawTextureProjection();
+ glEnable(GL_LIGHTING);
+ glPopMatrix();
+ }
+ }
+ for (i = 0; i < NumTextures; i++) {
+ ActiveTexture(GL_TEXTURE0_ARB + i);
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_TEXTURE_GEN_S);
+ glEnable(GL_TEXTURE_GEN_T);
+ glEnable(GL_TEXTURE_GEN_R);
+ glEnable(GL_TEXTURE_GEN_Q);
+ }
+ }
+ if (mode == MoveObject || mode == MoveView) {
+ /* Have OpenGL compute the new transformation (simple but slow). */
+ glPushMatrix();
+ glLoadIdentity();
+ glRotatef(angle, axis[0], axis[1], axis[2]);
+ glMultMatrixf((GLfloat *) objectXform);
+ glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) objectXform);
+ glPopMatrix();
+ }
+ glPushMatrix();
+ glMultMatrixf((GLfloat *) objectXform);
+ (*drawObject) ();
+ glPopMatrix();
+
+ for (i = 0; i < NumTextures; i++) {
+ ActiveTexture(GL_TEXTURE0_ARB + i);
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_TEXTURE_GEN_S);
+ glDisable(GL_TEXTURE_GEN_T);
+ glDisable(GL_TEXTURE_GEN_R);
+ glDisable(GL_TEXTURE_GEN_Q);
+ }
+
+ if (zoomFactor > 1.0) {
+ glDisable(GL_DEPTH_TEST);
+ glCopyPixels(0, 0, winWidth / zoomFactor, winHeight / zoomFactor, GL_COLOR);
+ glEnable(GL_DEPTH_TEST);
+ }
+ glFlush();
+ glutSwapBuffers();
+ checkErrors();
+}
+
+/*****************************************************************/
+
+/* simple trackball-like motion control */
+float lastPos[3];
+int lastTime;
+
+void
+ptov(int x, int y, int width, int height, float v[3])
+{
+ float d, a;
+
+ /* project x,y onto a hemi-sphere centered within width, height */
+ v[0] = (2.0 * x - width) / width;
+ v[1] = (height - 2.0 * y) / height;
+ d = sqrt(v[0] * v[0] + v[1] * v[1]);
+ v[2] = cos((M_PI / 2.0) * ((d < 1.0) ? d : 1.0));
+ a = 1.0 / sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
+ v[0] *= a;
+ v[1] *= a;
+ v[2] *= a;
+}
+
+void
+startMotion(int x, int y, int but, int time)
+{
+ if (but == GLUT_LEFT_BUTTON) {
+ mode = MoveView;
+ } else if (but == GLUT_MIDDLE_BUTTON) {
+ mode = MoveTexture;
+ } else {
+ return;
+ }
+
+ lastTime = time;
+ ptov(x, y, winWidth, winHeight, lastPos);
+}
+
+void
+animate(void)
+{
+ glutPostRedisplay();
+}
+
+void
+vis(int visible)
+{
+ if (visible == GLUT_VISIBLE) {
+ if (redrawContinuously)
+ glutIdleFunc(animate);
+ } else {
+ if (redrawContinuously)
+ glutIdleFunc(NULL);
+ }
+}
+
+void
+stopMotion(int but, int time)
+{
+ if ((but == GLUT_LEFT_BUTTON && mode == MoveView) ||
+ (but == GLUT_MIDDLE_BUTTON && mode == MoveTexture)) {
+ } else {
+ return;
+ }
+
+ if (time == lastTime) {
+ /* redrawContinuously = GL_TRUE;*/
+ glutIdleFunc(animate);
+ } else {
+ angle = 0.0;
+ redrawContinuously = GL_FALSE;
+ glutIdleFunc(0);
+ }
+ if (!redrawContinuously) {
+ mode = MoveNone;
+ }
+}
+
+void
+trackMotion(int x, int y)
+{
+ float curPos[3], dx, dy, dz;
+
+ ptov(x, y, winWidth, winHeight, curPos);
+
+ dx = curPos[0] - lastPos[0];
+ dy = curPos[1] - lastPos[1];
+ dz = curPos[2] - lastPos[2];
+ angle = 90.0 * sqrt(dx * dx + dy * dy + dz * dz);
+
+ axis[0] = lastPos[1] * curPos[2] - lastPos[2] * curPos[1];
+ axis[1] = lastPos[2] * curPos[0] - lastPos[0] * curPos[2];
+ axis[2] = lastPos[0] * curPos[1] - lastPos[1] * curPos[0];
+
+ lastTime = glutGet(GLUT_ELAPSED_TIME);
+ lastPos[0] = curPos[0];
+ lastPos[1] = curPos[1];
+ lastPos[2] = curPos[2];
+ glutPostRedisplay();
+}
+
+/*****************************************************************/
+
+void
+object(void)
+{
+ static int object;
+
+ object++;
+ object %= 3;
+ switch (object) {
+ case 0:
+ drawObject = drawCube;
+ break;
+ case 1:
+ drawObject = drawDodecahedron;
+ break;
+ case 2:
+ drawObject = drawSphere;
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+nop(void)
+{
+}
+
+void
+texture(void)
+{
+ static int texture = 0;
+
+ texture++;
+ texture %= 3;
+ if (texture == 1 && texFilename == NULL) {
+ /* Skip file texture if not loaded. */
+ texture++;
+ }
+ switch (texture) {
+ case 0:
+ loadTexture = nop;
+ textureEnabled = GL_FALSE;
+ break;
+ case 1:
+ loadTexture = loadImageTextures;
+ (*loadTexture) ();
+ textureEnabled = GL_TRUE;
+ break;
+ case 2:
+ loadTexture = loadSpotlightTexture;
+ (*loadTexture) ();
+ textureEnabled = GL_TRUE;
+ break;
+ default:
+ break;
+ }
+}
+
+void
+help(void)
+{
+ printf("'h' - help\n");
+ printf("'l' - toggle linear/nearest filter\n");
+ printf("'s' - toggle projection frustum\n");
+ printf("'t' - toggle projected texture\n");
+ printf("'o' - toggle object\n");
+ printf("'z' - increase zoom factor\n");
+ printf("'Z' - decrease zoom factor\n");
+ printf("left mouse - move view\n");
+ printf("middle mouse - move projection\n");
+}
+
+/* ARGSUSED1 */
+void
+key(unsigned char key, int x, int y)
+{
+ switch (key) {
+ case '\033':
+ exit(0);
+ break;
+ case 'l':
+ linearFilter = !linearFilter;
+ (*loadTexture) ();
+ break;
+ case 's':
+ showProjection = !showProjection;
+ break;
+ case 't':
+ texture();
+ break;
+ case 'o':
+ object();
+ break;
+ case 'z':
+ zoomFactor += 1.0;
+ glPixelZoom(zoomFactor, zoomFactor);
+ glViewport(0, 0, winWidth / zoomFactor, winHeight / zoomFactor);
+ break;
+ case 'Z':
+ zoomFactor -= 1.0;
+ if (zoomFactor < 1.0)
+ zoomFactor = 1.0;
+ glPixelZoom(zoomFactor, zoomFactor);
+ glViewport(0, 0, winWidth / zoomFactor, winHeight / zoomFactor);
+ break;
+ case 'h':
+ help();
+ break;
+ }
+ glutPostRedisplay();
+}
+
+void
+mouse(int button, int state, int x, int y)
+{
+ if (state == GLUT_DOWN)
+ startMotion(x, y, button, glutGet(GLUT_ELAPSED_TIME));
+ else if (state == GLUT_UP)
+ stopMotion(button, glutGet(GLUT_ELAPSED_TIME));
+ glutPostRedisplay();
+}
+
+void
+reshape(int w, int h)
+{
+ winWidth = w;
+ winHeight = h;
+ glViewport(0, 0, w / zoomFactor, h / zoomFactor);
+}
+
+
+void
+menu(int selection)
+{
+ if (selection == 666) {
+ exit(0);
+ }
+ key((unsigned char) selection, 0, 0);
+}
+
+int
+main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+
+ if (argc > 1) {
+ NumTextures = atoi(argv[1]);
+ }
+ assert(NumTextures <= MAX_TEX);
+
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
+ (void) glutCreateWindow("projtex");
+
+ loadTexture = loadImageTextures;
+ drawObject = drawCube;
+ initialize();
+ glutDisplayFunc(display);
+ glutKeyboardFunc(key);
+ glutReshapeFunc(reshape);
+ glutMouseFunc(mouse);
+ glutMotionFunc(trackMotion);
+ glutVisibilityFunc(vis);
+ glutCreateMenu(menu);
+ glutAddMenuEntry("Toggle showing projection", 's');
+ glutAddMenuEntry("Switch texture", 't');
+ glutAddMenuEntry("Switch object", 'o');
+ glutAddMenuEntry("Toggle filtering", 'l');
+ glutAddMenuEntry("Quit", 666);
+ glutAttachMenu(GLUT_RIGHT_BUTTON);
+ texture();
+ glutMainLoop();
+ return 0; /* ANSI C requires main to return int. */
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/seccolor.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/seccolor.c
new file mode 100644
index 000000000..77fd40647
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/seccolor.c
@@ -0,0 +1,145 @@
+/*
+ * Exercise GL_EXT_secondary_color
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+static int Width = 600;
+static int Height = 200;
+static GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+ GLfloat t;
+
+ glClearColor(0.2, 0.2, 0.8, 0);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ for (t = 0.0; t <= 1.0; t += 0.25) {
+ GLfloat x = t * 10.0 - 5.0;
+ GLfloat g = t;
+
+ /* top row: untextured */
+ glColor3f(1, 0, 0);
+ glPushMatrix();
+ glTranslatef(x, 1.2, 0);
+#if defined(GL_EXT_secondary_color)
+ glSecondaryColor3fEXT(0, g, 0);
+#endif
+ glBegin(GL_POLYGON);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+ glPopMatrix();
+
+ /* bottom row: textured */
+ glColor3f(1, 1, 1);
+ glEnable(GL_TEXTURE_2D);
+ glPushMatrix();
+ glTranslatef(x, -1.2, 0);
+#if defined(GL_EXT_secondary_color)
+ glSecondaryColor3fEXT(0, g, 0);
+#endif
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0); glVertex2f(-1, -1);
+ glTexCoord2f(1, 0); glVertex2f( 1, -1);
+ glTexCoord2f(1, 1); glVertex2f( 1, 1);
+ glTexCoord2f(0, 1); glVertex2f(-1, 1);
+ glEnd();
+ glPopMatrix();
+ glDisable(GL_TEXTURE_2D);
+ }
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ GLubyte image[4*4][3];
+ GLint i;
+ if (!glutExtensionSupported("GL_EXT_secondary_color")) {
+ printf("Sorry, this program requires GL_EXT_secondary_color\n");
+ exit(1);
+ }
+
+ /* setup red texture with one back texel */
+ for (i = 0; i < 4*4; i++) {
+ if (i == 0) {
+ image[i][0] = 0;
+ image[i][1] = 0;
+ image[i][2] = 0;
+ }
+ else {
+ image[i][0] = 255;
+ image[i][1] = 0;
+ image[i][2] = 0;
+ }
+ }
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, image);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+#if defined(GL_EXT_secondary_color)
+ glEnable(GL_COLOR_SUM_EXT);
+#endif
+ glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+
+ printf("Squares should be colored from red -> orange -> yellow.\n");
+ printf("Top row is untextured.\n");
+ printf("Bottom row is textured (red texture with one black texel).\n");
+ printf("Rows should be identical, except for lower-left texel.\n");
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/sharedtex.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/sharedtex.c
new file mode 100644
index 000000000..ebe73f19f
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/sharedtex.c
@@ -0,0 +1,438 @@
+/* $Id: sharedtex.c,v 1.2 2002/01/16 14:32:46 joukj Exp $ */
+
+/*
+ * Test sharing of display lists and texture objects between GLX contests.
+ * Brian Paul
+ * Summer 2000
+ *
+ *
+ * Copyright (C) 2000 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 <GL/gl.h>
+#include <GL/glx.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+
+struct window {
+ char DisplayName[1000];
+ Display *Dpy;
+ Window Win;
+ GLXContext Context;
+ float Angle;
+ int Id;
+};
+
+
+#define MAX_WINDOWS 20
+static struct window Windows[MAX_WINDOWS];
+static int NumWindows = 0;
+
+
+static GLuint Textures[3];
+static GLuint CubeList;
+
+
+
+static void
+Error(const char *display, const char *msg)
+{
+ fprintf(stderr, "Error on display %s - %s\n", display, msg);
+ exit(1);
+}
+
+
+static struct window *
+AddWindow(const char *displayName, int xpos, int ypos,
+ const struct window *shareWindow)
+{
+ Display *dpy;
+ Window win;
+ GLXContext ctx;
+ int attrib[] = { GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ GLX_DEPTH_SIZE, 1,
+ None };
+ int scrnum;
+ XSetWindowAttributes attr;
+ unsigned long mask;
+ Window root;
+ XVisualInfo *visinfo;
+ int width = 300, height = 300;
+
+ if (NumWindows >= MAX_WINDOWS)
+ return NULL;
+
+ dpy = XOpenDisplay(displayName);
+ if (!dpy) {
+ Error(displayName, "Unable to open display");
+ return NULL;
+ }
+
+ scrnum = DefaultScreen(dpy);
+ root = RootWindow(dpy, scrnum);
+
+ visinfo = glXChooseVisual(dpy, scrnum, attrib);
+ if (!visinfo) {
+ Error(displayName, "Unable to find RGB, double-buffered visual");
+ return NULL;
+ }
+
+ /* window attributes */
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+ win = XCreateWindow(dpy, root, xpos, ypos, width, height,
+ 0, visinfo->depth, InputOutput,
+ visinfo->visual, mask, &attr);
+ if (!win) {
+ Error(displayName, "Couldn't create window");
+ return NULL;
+ }
+
+ {
+ XSizeHints sizehints;
+ sizehints.x = xpos;
+ sizehints.y = ypos;
+ sizehints.width = width;
+ sizehints.height = height;
+ sizehints.flags = USSize | USPosition;
+ XSetNormalHints(dpy, win, &sizehints);
+ XSetStandardProperties(dpy, win, displayName, displayName,
+ None, (char **)NULL, 0, &sizehints);
+ }
+
+
+ ctx = glXCreateContext(dpy, visinfo,
+ shareWindow ? shareWindow->Context : NULL,
+ True);
+ if (!ctx) {
+ Error(displayName, "Couldn't create GLX context");
+ return NULL;
+ }
+
+ XMapWindow(dpy, win);
+
+ if (!glXMakeCurrent(dpy, win, ctx)) {
+ Error(displayName, "glXMakeCurrent failed");
+ printf("glXMakeCurrent failed in Redraw()\n");
+ return NULL;
+ }
+
+ /* save the info for this window */
+ {
+ static int id = 0;
+ struct window *h = &Windows[NumWindows];
+ strcpy(h->DisplayName, displayName);
+ h->Dpy = dpy;
+ h->Win = win;
+ h->Context = ctx;
+ h->Angle = 0.0;
+ h->Id = id++;
+ NumWindows++;
+ return &Windows[NumWindows-1];
+ }
+
+}
+
+
+static void
+InitGLstuff(struct window *h)
+{
+ if (!glXMakeCurrent(h->Dpy, h->Win, h->Context)) {
+ Error(h->DisplayName, "glXMakeCurrent failed in InitGLstuff");
+ return;
+ }
+
+ glGenTextures(3, Textures);
+
+ /* setup first texture object */
+ {
+ GLubyte image[16][16][4];
+ GLint i, j;
+ glBindTexture(GL_TEXTURE_2D, Textures[0]);
+
+ /* red/white checkerboard */
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ if ((i ^ j) & 1) {
+ image[i][j][0] = 255;
+ image[i][j][1] = 255;
+ image[i][j][2] = 255;
+ image[i][j][3] = 255;
+ }
+ else {
+ image[i][j][0] = 255;
+ image[i][j][1] = 0;
+ image[i][j][2] = 0;
+ image[i][j][3] = 255;
+ }
+ }
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, image);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+
+ /* setup second texture object */
+ {
+ GLubyte image[8][8][3];
+ GLint i, j;
+ glBindTexture(GL_TEXTURE_2D, Textures[1]);
+
+ /* green/yellow checkerboard */
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ if ((i ^ j) & 1) {
+ image[i][j][0] = 0;
+ image[i][j][1] = 255;
+ image[i][j][2] = 0;
+ }
+ else {
+ image[i][j][0] = 255;
+ image[i][j][1] = 255;
+ image[i][j][2] = 0;
+ }
+ }
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 8, 8, 0, GL_RGB,
+ GL_UNSIGNED_BYTE, image);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+
+ /* setup second texture object */
+ {
+ GLubyte image[4][4][3];
+ GLint i, j;
+ glBindTexture(GL_TEXTURE_2D, Textures[2]);
+
+ /* blue/gray checkerboard */
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ if ((i ^ j) & 1) {
+ image[i][j][0] = 0;
+ image[i][j][1] = 0;
+ image[i][j][2] = 255;
+ }
+ else {
+ image[i][j][0] = 200;
+ image[i][j][1] = 200;
+ image[i][j][2] = 200;
+ }
+ }
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB,
+ GL_UNSIGNED_BYTE, image);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+
+ /* Now make the cube object display list */
+ CubeList = glGenLists(1);
+ glNewList(CubeList, GL_COMPILE);
+ {
+ glBindTexture(GL_TEXTURE_2D, Textures[0]);
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0); glVertex3f(-1, -1, -1);
+ glTexCoord2f(1, 0); glVertex3f(-1, 1, -1);
+ glTexCoord2f(1, 1); glVertex3f(-1, 1, 1);
+ glTexCoord2f(0, 1); glVertex3f(-1, -1, 1);
+ glEnd();
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0); glVertex3f(1, -1, -1);
+ glTexCoord2f(1, 0); glVertex3f(1, 1, -1);
+ glTexCoord2f(1, 1); glVertex3f(1, 1, 1);
+ glTexCoord2f(0, 1); glVertex3f(1, -1, 1);
+ glEnd();
+
+ glBindTexture(GL_TEXTURE_2D, Textures[1]);
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0); glVertex3f(-1, -1, -1);
+ glTexCoord2f(1, 0); glVertex3f( 1, -1, -1);
+ glTexCoord2f(1, 1); glVertex3f( 1, -1, 1);
+ glTexCoord2f(0, 1); glVertex3f(-1, -1, 1);
+ glEnd();
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0); glVertex3f(-1, 1, -1);
+ glTexCoord2f(1, 0); glVertex3f( 1, 1, -1);
+ glTexCoord2f(1, 1); glVertex3f( 1, 1, 1);
+ glTexCoord2f(0, 1); glVertex3f(-1, 1, 1);
+ glEnd();
+
+ glBindTexture(GL_TEXTURE_2D, Textures[2]);
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0); glVertex3f(-1, -1, -1);
+ glTexCoord2f(1, 0); glVertex3f( 1, -1, -1);
+ glTexCoord2f(1, 1); glVertex3f( 1, 1, -1);
+ glTexCoord2f(0, 1); glVertex3f(-1, 1, -1);
+ glEnd();
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 0); glVertex3f(-1, -1, 1);
+ glTexCoord2f(1, 0); glVertex3f( 1, -1, 1);
+ glTexCoord2f(1, 1); glVertex3f( 1, 1, 1);
+ glTexCoord2f(0, 1); glVertex3f(-1, 1, 1);
+ glEnd();
+ }
+ glEndList();
+
+ 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));
+}
+
+
+
+static void
+Redraw(struct window *h)
+{
+ if (!glXMakeCurrent(h->Dpy, h->Win, h->Context)) {
+ Error(h->DisplayName, "glXMakeCurrent failed");
+ printf("glXMakeCurrent failed in Redraw()\n");
+ return;
+ }
+
+ h->Angle += 1.0;
+
+ glShadeModel(GL_FLAT);
+ glClearColor(0.25, 0.25, 0.25, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_DEPTH_TEST);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+
+ glColor3f(1, 1, 1);
+
+ glPushMatrix();
+ if (h->Id == 0)
+ glRotatef(h->Angle, 0, 1, -1);
+ else if (h->Id == 1)
+ glRotatef(-(h->Angle), 0, 1, -1);
+ else if (h->Id == 2)
+ glRotatef(h->Angle, 0, 1, 1);
+ else if (h->Id == 3)
+ glRotatef(-(h->Angle), 0, 1, 1);
+ glCallList(CubeList);
+ glPopMatrix();
+
+ glXSwapBuffers(h->Dpy, h->Win);
+}
+
+
+
+static void
+Resize(const struct window *h, unsigned int width, unsigned int height)
+{
+ if (!glXMakeCurrent(h->Dpy, h->Win, h->Context)) {
+ Error(h->DisplayName, "glXMakeCurrent failed in Resize()");
+ return;
+ }
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1, 1, -1, 1, 2, 10);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0, 0, -3.5);
+}
+
+
+
+static void
+EventLoop(void)
+{
+ while (1) {
+ int i;
+ for (i = 0; i < NumWindows; i++) {
+ struct window *h = &Windows[i];
+ while (XPending(h->Dpy) > 0) {
+ XEvent event;
+ XNextEvent(h->Dpy, &event);
+ if (event.xany.window == h->Win) {
+ switch (event.type) {
+ case Expose:
+ Redraw(h);
+ break;
+ case ConfigureNotify:
+ Resize(h, event.xconfigure.width, event.xconfigure.height);
+ break;
+ case KeyPress:
+ return;
+ default:
+ /*no-op*/ ;
+ }
+ }
+ else {
+ printf("window mismatch\n");
+ }
+ }
+ Redraw(h);
+ }
+ usleep(1);
+ }
+}
+
+
+
+static void
+PrintInfo(const struct window *h)
+{
+ printf("Name: %s\n", h->DisplayName);
+ printf(" Display: 0x%x\n", h->Dpy);
+ printf(" Window: 0x%x\n", h->Win);
+ printf(" Context: 0x%x\n", h->Context);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+ struct window *h0, *h1, *h2, *h3;
+
+ /* four windows and contexts sharing display lists and texture objects */
+ h0 = AddWindow(":0", 10, 10, NULL);
+ h1 = AddWindow(":0", 330, 10, h0);
+ h2 = AddWindow(":0", 10, 350, h0);
+ h3 = AddWindow(":0", 330, 350, h0);
+
+ InitGLstuff(h0);
+
+ EventLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/stencil_wrap.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/stencil_wrap.c
new file mode 100644
index 000000000..88cf3809c
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/stencil_wrap.c
@@ -0,0 +1,257 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 (including the next
+ * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+/**
+ * \file stencil_wrap.c
+ *
+ * Simple test of GL_EXT_stencil_wrap functionality. Four squares are drawn
+ * with different stencil modes, but all should be rendered with the same
+ * final color.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int Width = 550;
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+ GLint max_stencil;
+ GLint stencil_bits;
+ unsigned i;
+
+
+ glGetIntegerv( GL_STENCIL_BITS, & stencil_bits );
+ max_stencil = (1U << stencil_bits) - 1;
+ printf( "Stencil bits = %u, maximum stencil value = 0x%08x\n",
+ stencil_bits, max_stencil );
+
+ glClearStencil( 0 );
+ glClearColor( 0.2, 0.2, 0.8, 0 );
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
+ | GL_STENCIL_BUFFER_BIT );
+
+
+ glPushMatrix();
+
+ /* This is the "reference" square.
+ */
+
+ glDisable(GL_STENCIL_TEST);
+ glTranslatef(-6.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ glEnable(GL_STENCIL_TEST);
+
+ /* Draw the first two squares using the two non-wrap (i.e., saturate)
+ * modes.
+ */
+
+ glStencilFunc(GL_ALWAYS, 0, ~0);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
+
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.9, 0.9 );
+
+ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ }
+ glEnd();
+
+ glStencilFunc(GL_EQUAL, max_stencil, ~0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ glStencilFunc(GL_ALWAYS, 0, ~0);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
+
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.9, 0.9 );
+
+ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ }
+ glEnd();
+
+ glStencilFunc(GL_EQUAL, 0, ~0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+
+
+ /* Draw the last two squares using the two wrap modes.
+ */
+
+ glStencilFunc(GL_ALWAYS, 0, ~0);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP);
+
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.9, 0.9 );
+
+ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ }
+ glEnd();
+
+ glStencilFunc(GL_EQUAL, 4, ~0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+
+ glStencilFunc(GL_ALWAYS, 0, ~0);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP);
+
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.9, 0.9 );
+
+ for ( i = 0 ; i < 5 ; i++ ) {
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ }
+ glEnd();
+
+ glStencilFunc(GL_EQUAL, (max_stencil - 4), ~0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ const char * const ver_string = (const char * const)
+ glGetString( GL_VERSION );
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", ver_string);
+
+ if ( !glutExtensionSupported("GL_EXT_stencil_wrap")
+ && (atof( ver_string ) < 1.4) ) {
+ printf("Sorry, this program requires either GL_EXT_stencil_wrap or OpenGL 1.4.\n");
+ exit(1);
+ }
+
+ printf("\nAll 5 squares should be the same color.\n");
+ glEnable( GL_BLEND );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL );
+ glutCreateWindow( "GL_EXT_stencil_wrap test" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/stencilwrap.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/stencilwrap.c
new file mode 100644
index 000000000..753375d0f
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/stencilwrap.c
@@ -0,0 +1,281 @@
+/* Test GL_EXT_stencil_wrap extension.
+ * This is by no means complete, just a quick check.
+ *
+ * Brian Paul 30 October 2002
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+GLboolean wrapping;
+
+static void RunTest(void)
+{
+ const GLenum prim = GL_QUAD_STRIP;
+ GLubyte val;
+ int bits, max, i;
+ int expected;
+ GLboolean failed;
+
+ glGetIntegerv(GL_STENCIL_BITS, &bits);
+ max = (1 << bits) - 1;
+
+
+ glEnable(GL_STENCIL_TEST);
+ glStencilFunc(GL_ALWAYS, 0, ~0);
+
+ /* test GL_KEEP */
+ glClearStencil(max);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ failed = GL_FALSE;
+ printf("Testing GL_KEEP...\n");
+ expected = max;
+ glBegin(prim);
+ glVertex2f(0, 0);
+ glVertex2f(10, 0);
+ glVertex2f(0, 10);
+ glVertex2f(10, 10);
+ glEnd();
+ glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
+ if (val != expected) {
+ printf("Failed GL_KEEP test(got %u, expected %u)\n", val, expected);
+ failed = GL_TRUE;
+ }
+ else
+ printf("OK!\n");
+
+ /* test GL_ZERO */
+ glClearStencil(max);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
+ failed = GL_FALSE;
+ printf("Testing GL_ZERO...\n");
+ expected = 0;
+ glBegin(prim);
+ glVertex2f(0, 0);
+ glVertex2f(10, 0);
+ glVertex2f(0, 10);
+ glVertex2f(10, 10);
+ glEnd();
+ glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
+ if (val != expected) {
+ printf("Failed GL_ZERO test(got %u, expected %u)\n", val, expected);
+ failed = GL_TRUE;
+ }
+ else
+ printf("OK!\n");
+
+ /* test GL_REPLACE */
+ glClearStencil(max);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+ failed = GL_FALSE;
+ printf("Testing GL_REPLACE...\n");
+ expected = 0;
+ glBegin(prim);
+ glVertex2f(0, 0);
+ glVertex2f(10, 0);
+ glVertex2f(0, 10);
+ glVertex2f(10, 10);
+ glEnd();
+ glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
+ if (val != expected) {
+ printf("Failed GL_REPLACE test(got %u, expected %u)\n", val, expected);
+ failed = GL_TRUE;
+ }
+ else
+ printf("OK!\n");
+
+ /* test GL_INCR (saturation) */
+ glClearStencil(0);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
+ failed = GL_FALSE;
+ printf("Testing GL_INCR...\n");
+ for (i = 1; i < max+10; i++) {
+ expected = (i > max) ? max : i;
+ glBegin(prim);
+ glVertex2f(0, 0); glVertex2f(10, 0);
+ glVertex2f(0, 10); glVertex2f(10, 10);
+ glEnd();
+
+ glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
+ if (val != expected) {
+ printf( "Failed GL_INCR test on iteration #%u "
+ "(got %u, expected %u)\n", i, val, expected );
+ failed = GL_TRUE;
+ }
+ }
+ if ( !failed )
+ printf("OK!\n");
+
+ /* test GL_DECR (saturation) */
+ glClearStencil(max);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
+ failed = GL_FALSE;
+ printf("Testing GL_DECR...\n");
+ for (i = max-1; i > -10; i--) {
+ expected = (i < 0) ? 0 : i;
+ glBegin(prim);
+ glVertex2f(0, 0); glVertex2f(10, 0);
+ glVertex2f(0, 10); glVertex2f(10, 10);
+ glEnd();
+ glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
+ if (val != expected) {
+ printf( "Failed GL_DECR test on iteration #%u "
+ "(got %u, expected %u)\n", max - i, val, expected );
+ failed = GL_TRUE;
+ }
+ }
+ if ( !failed )
+ printf("OK!\n");
+
+ /* test GL_INVERT */
+ glClearStencil(0);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT);
+ failed = GL_FALSE;
+ printf("Testing GL_INVERT...\n");
+ expected = max;
+ glBegin(prim);
+ glVertex2f(0, 0);
+ glVertex2f(10, 0);
+ glVertex2f(0, 10);
+ glVertex2f(10, 10);
+ glEnd();
+ glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
+ if (val != expected) {
+ printf("Failed GL_INVERT test(got %u, expected %u)\n", val, expected);
+ failed = GL_TRUE;
+ }
+ else
+ printf("OK!\n");
+
+ if(wrapping)
+ {
+ /* test GL_INCR_WRAP_EXT (wrap around) */
+ glClearStencil(0);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
+ failed = GL_FALSE;
+ printf("Testing GL_INCR_WRAP_EXT...\n");
+ for (i = 1; i < max+10; i++) {
+ expected = i % (max + 1);
+ glBegin(prim);
+ glVertex2f(0, 0); glVertex2f(10, 0);
+ glVertex2f(0, 10); glVertex2f(10, 10);
+ glEnd();
+ glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
+ if (val != expected) {
+ printf( "Failed GL_INCR_WRAP test on iteration #%u "
+ "(got %u, expected %u)\n", i, val, expected );
+ failed = GL_TRUE;
+ }
+ }
+ if ( !failed )
+ printf("OK!\n");
+
+ /* test GL_DECR_WRAP_EXT (wrap-around) */
+ glClearStencil(max);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
+ failed = GL_FALSE;
+ printf("Testing GL_DECR_WRAP_EXT...\n");
+ for (i = max-1; i > -10; i--) {
+ expected = (i < 0) ? max + i + 1: i;
+ glBegin(prim);
+ glVertex2f(0, 0); glVertex2f(10, 0);
+ glVertex2f(0, 10); glVertex2f(10, 10);
+ glEnd();
+ glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
+ if (val != expected) {
+ printf( "Failed GL_DECR_WRAP test on iteration #%u "
+ "(got %u, expected %u)\n", max - i, val, expected );
+ failed = GL_TRUE;
+ }
+ }
+ if ( !failed )
+ printf("OK!\n");
+ }
+
+ glDisable(GL_STENCIL_TEST);
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ RunTest();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(0, width, 0, height, -1, 1);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ const char * ver_str;
+ float version;
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+
+
+ /* Check for both the extension string and GL version 1.4 on the
+ * outside chance that some vendor exports version 1.4 but doesn't
+ * export the extension string. The stencil-wrap modes are a required
+ * part of GL 1.4.
+ */
+
+ ver_str = glGetString( GL_VERSION );
+ version = (ver_str == NULL) ? 1.0 : atof( ver_str );
+
+ wrapping = (glutExtensionSupported("GL_EXT_stencil_wrap") || (version >= 1.4));
+ if (!wrapping)
+ printf("GL_EXT_stencil_wrap not supported. Only testing the rest.\n");
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 400, 400 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_STENCIL );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/tex1d.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/tex1d.c
new file mode 100644
index 000000000..1fab849dd
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/tex1d.c
@@ -0,0 +1,139 @@
+
+/* Exercise 1D textures
+ */
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "GL/glut.h"
+
+static GLuint Window = 0;
+static GLuint TexObj[2];
+static GLfloat Angle = 0.0f;
+
+
+static void draw( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glColor3f( 1.0, 1.0, 1.0 );
+
+ /* draw first polygon */
+ glPushMatrix();
+ glTranslatef( -1.0, 0.0, 0.0 );
+ glRotatef( Angle, 0.0, 0.0, 1.0 );
+ glBindTexture( GL_TEXTURE_1D, TexObj[0] );
+ glBegin( GL_POLYGON );
+ glTexCoord1f( 0.0 ); glVertex2f( -1.0, -1.0 );
+ glTexCoord1f( 1.0 ); glVertex2f( 1.0, -1.0 );
+ glTexCoord1f( 1.0 ); glVertex2f( 1.0, 1.0 );
+ glTexCoord1f( 0.0 ); glVertex2f( -1.0, 1.0 );
+ glEnd();
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+
+static void idle( void )
+{
+ Angle += 2.0;
+ glutPostRedisplay();
+}
+
+
+
+/* change view Angle, exit upon ESC */
+static void key(unsigned char k, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (k) {
+ case 27:
+ exit(0);
+ }
+}
+
+
+
+/* new window size or exposure */
+static void reshape( int width, int height )
+{
+ glViewport(0, 0, (GLint)width, (GLint)height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/
+ glFrustum( -2.0, 2.0, -2.0, 2.0, 6.0, 20.0 );
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -8.0 );
+}
+
+
+static void init( void )
+{
+ GLubyte tex[256][3];
+ GLint i;
+
+
+ glDisable( GL_DITHER );
+
+ /* Setup texturing */
+ glEnable( GL_TEXTURE_1D );
+ glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
+
+
+ /* generate texture object IDs */
+ glGenTextures( 2, TexObj );
+
+ /* setup first texture object */
+ glBindTexture( GL_TEXTURE_1D, TexObj[0] );
+
+
+ for (i = 0; i < 256; i++) {
+ GLfloat f;
+
+ /* map 0..255 to -PI .. PI */
+ f = ((i / 255.0) - .5) * (3.141592 * 2);
+
+ f = sin(f);
+
+ /* map -1..1 to 0..255 */
+ tex[i][0] = (f+1.0)/2.0 * 255.0;
+ tex[i][1] = 0;
+ tex[i][2] = 0;
+ }
+
+ glTexImage1D( GL_TEXTURE_1D, 0, 3, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, tex );
+ glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT );
+ glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+}
+
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(300, 300);
+ glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
+
+ Window = glutCreateWindow("Texture Objects");
+ if (!Window) {
+ exit(1);
+ }
+
+ init();
+
+ glutReshapeFunc( reshape );
+ glutKeyboardFunc( key );
+/* glutIdleFunc( idle ); */
+ glutDisplayFunc( draw );
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/texcmp.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/texcmp.c
new file mode 100644
index 000000000..6e822fb68
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/texcmp.c
@@ -0,0 +1,414 @@
+/*
+ * Compressed texture demo. Written by Daniel Borca.
+ * This program is in the public domain.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES 1
+#include <GL/glut.h>
+
+#include "readtex.c" /* I know, this is a hack. */
+#define TEXTURE_FILE "../images/tree2.rgba"
+
+
+static float Rot = 0.0;
+static GLboolean Anim = 1;
+
+typedef struct {
+ GLubyte *data;
+ GLuint size;
+ GLenum format;
+ GLuint w, h;
+
+ GLenum TC;
+
+ GLubyte *cData;
+ GLuint cSize;
+ GLenum cFormat;
+} TEXTURE;
+
+static TEXTURE *Tx, t1, t2, t3;
+static GLboolean fxt1, dxtc, s3tc;
+
+
+static const char *TextureName (GLenum TC)
+{
+ switch (TC) {
+ case GL_RGB:
+ return "RGB";
+ case GL_RGBA:
+ return "RGBA";
+ case GL_COMPRESSED_RGB:
+ return "COMPRESSED_RGB";
+ case GL_COMPRESSED_RGBA:
+ return "COMPRESSED_RGBA";
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return "GL_COMPRESSED_RGB_FXT1_3DFX";
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return "GL_COMPRESSED_RGBA_FXT1_3DFX";
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return "GL_COMPRESSED_RGB_S3TC_DXT1_EXT";
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT";
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT";
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT";
+ case GL_RGB_S3TC:
+ return "GL_RGB_S3TC";
+ case GL_RGB4_S3TC:
+ return "GL_RGB4_S3TC";
+ case GL_RGBA_S3TC:
+ return "GL_RGBA_S3TC";
+ case GL_RGBA4_S3TC:
+ return "GL_RGBA4_S3TC";
+ case 0:
+ return "Invalid format";
+ default:
+ return "Unknown format";
+ }
+}
+
+
+static void
+PrintString(const char *s)
+{
+ while (*s) {
+ glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
+ s++;
+ }
+}
+
+
+static void Idle( void )
+{
+ float t = glutGet(GLUT_ELAPSED_TIME) * 0.001; /* in seconds */
+ Rot = t * 360 / 4; /* 1 rotation per 4 seconds */
+ glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+ /* draw background gradient */
+ glDisable(GL_TEXTURE_2D);
+ glBegin(GL_POLYGON);
+ glColor3f(1.0, 0.0, 0.2); glVertex2f(-1.5, -1.0);
+ glColor3f(1.0, 0.0, 0.2); glVertex2f( 1.5, -1.0);
+ glColor3f(0.0, 0.0, 1.0); glVertex2f( 1.5, 1.0);
+ glColor3f(0.0, 0.0, 1.0); glVertex2f(-1.5, 1.0);
+ glEnd();
+
+ glPushMatrix();
+ glRotatef(Rot, 0, 0, 1);
+
+ glEnable(GL_TEXTURE_2D);
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0, 1); glVertex2f(-1, -0.5);
+ glTexCoord2f(1, 1); glVertex2f( 1, -0.5);
+ glTexCoord2f(1, 0); glVertex2f( 1, 0.5);
+ glTexCoord2f(0, 0); glVertex2f(-1, 0.5);
+ glEnd();
+
+ glPopMatrix();
+
+ /* info */
+ glColor4f(1, 1, 1, 1);
+
+ glRasterPos3f(-1.2, -0.7, 0);
+ PrintString("Selected: ");
+ PrintString(TextureName(Tx->TC));
+ if (Tx->cData) {
+ char tmp[64];
+ glRasterPos3f(-1.2, -0.8, 0);
+ PrintString("Internal: ");
+ PrintString(TextureName(Tx->cFormat));
+ glRasterPos3f(-1.2, -0.9, 0);
+ PrintString("Size : ");
+ sprintf(tmp, "%d (%d%% of %d)", Tx->cSize, Tx->cSize * 100 / Tx->size, Tx->size);
+ PrintString(tmp);
+ }
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho( -1.5, 1.5, -1.0, 1.0, -1.0, 1.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+}
+
+
+static void ReInit( GLenum TC, TEXTURE *Tx )
+{
+ GLint rv;
+
+ if ((Tx->TC == TC) && (Tx->cData != NULL)) {
+ glCompressedTexImage2DARB(GL_TEXTURE_2D, /* target */
+ 0, /* level */
+ Tx->cFormat, /* real format */
+ Tx->w, /* original width */
+ Tx->h, /* original height */
+ 0, /* border */
+ Tx->cSize, /* compressed size*/
+ Tx->cData); /* compressed data*/
+ } else {
+ glTexImage2D(GL_TEXTURE_2D, /* target */
+ 0, /* level */
+ TC, /* internal format */
+ Tx->w, Tx->h, /* width, height */
+ 0, /* border */
+ Tx->format, /* texture format */
+ GL_UNSIGNED_BYTE, /* texture type */
+ Tx->data); /* the texture */
+
+ /* okay, now cache the compressed texture */
+ Tx->TC = TC;
+ if (Tx->cData != NULL) {
+ free(Tx->cData);
+ Tx->cData = NULL;
+ }
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &rv);
+ if (rv) {
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, (GLint *)&Tx->cFormat);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, (GLint *)&Tx->cSize);
+ if ((Tx->cData = malloc(Tx->cSize)) != NULL) {
+ glGetCompressedTexImageARB(GL_TEXTURE_2D, 0, Tx->cData);
+ }
+ }
+ }
+}
+
+
+static void Init( void )
+{
+ /* HEIGHT * WIDTH + 1 (for trailing '\0') */
+ static char pattern[8 * 32 + 1] = {"\
+ \
+ MMM EEEE SSS AAA \
+ M M M E S S A A \
+ M M M EEEE SS A A \
+ M M M E SS AAAAA \
+ M M E S S A A \
+ M M EEEE SSS A A \
+ "
+ };
+
+ GLuint i, j;
+
+ GLubyte (*texture1)[8 * 32][4];
+ GLubyte (*texture2)[256][256][4];
+
+ t1.w = 32;
+ t1.h = 8;
+ t1.size = t1.w * t1.h * 4;
+ t1.data = malloc(t1.size);
+ t1.format = GL_RGBA;
+ t1.TC = GL_RGBA;
+
+ texture1 = (GLubyte (*)[8 * 32][4])t1.data;
+ for (i = 0; i < sizeof(pattern) - 1; i++) {
+ switch (pattern[i]) {
+ default:
+ case ' ':
+ (*texture1)[i][0] = 255;
+ (*texture1)[i][1] = 255;
+ (*texture1)[i][2] = 255;
+ (*texture1)[i][3] = 64;
+ break;
+ case 'M':
+ (*texture1)[i][0] = 255;
+ (*texture1)[i][1] = 0;
+ (*texture1)[i][2] = 0;
+ (*texture1)[i][3] = 255;
+ break;
+ case 'E':
+ (*texture1)[i][0] = 0;
+ (*texture1)[i][1] = 255;
+ (*texture1)[i][2] = 0;
+ (*texture1)[i][3] = 255;
+ break;
+ case 'S':
+ (*texture1)[i][0] = 0;
+ (*texture1)[i][1] = 0;
+ (*texture1)[i][2] = 255;
+ (*texture1)[i][3] = 255;
+ break;
+ case 'A':
+ (*texture1)[i][0] = 255;
+ (*texture1)[i][1] = 255;
+ (*texture1)[i][2] = 0;
+ (*texture1)[i][3] = 255;
+ break;
+ }
+ }
+
+ t2.w = 256;
+ t2.h = 256;
+ t2.size = t2.w * t2.h * 4;
+ t2.data = malloc(t2.size);
+ t2.format = GL_RGBA;
+ t2.TC = GL_RGBA;
+
+ texture2 = (GLubyte (*)[256][256][4])t2.data;
+ for (j = 0; j < t2.h; j++) {
+ for (i = 0; i < t2.w; i++) {
+ (*texture2)[j][i][0] = sqrt(i * j * 255 * 255 / (t2.w * t2.h));
+ (*texture2)[j][i][1] = 0;
+ (*texture2)[j][i][2] = 0;
+ (*texture2)[j][i][3] = 255;
+ }
+ }
+
+ t3.data = LoadRGBImage(TEXTURE_FILE, (GLint *)&t3.w, (GLint *)&t3.h, &t3.format);
+ t3.size = t3.w * t3.h * ((t3.format == GL_RGB) ? 3 : 4);
+ t3.TC = GL_RGBA;
+
+ ReInit(GL_RGBA, Tx = &t1);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glEnable(GL_TEXTURE_2D);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ case ' ':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc( Idle );
+ else
+ glutIdleFunc( NULL );
+ break;
+ case 't':
+ if (Tx == &t1) {
+ Tx = &t2;
+ } else if (Tx == &t2) {
+ Tx = &t3;
+ } else {
+ Tx = &t1;
+ }
+ ReInit(Tx->TC, Tx);
+ break;
+ case '9':
+ ReInit(GL_RGB, Tx);
+ break;
+ case '0':
+ ReInit(GL_RGBA, Tx);
+ break;
+ case '1':
+ ReInit(GL_COMPRESSED_RGB, Tx);
+ break;
+ case '2':
+ ReInit(GL_COMPRESSED_RGBA, Tx);
+ break;
+ case '3':
+ if (fxt1) ReInit(GL_COMPRESSED_RGB_FXT1_3DFX, Tx);
+ break;
+ case '4':
+ if (fxt1) ReInit(GL_COMPRESSED_RGBA_FXT1_3DFX, Tx);
+ break;
+ case '5':
+ if (dxtc) ReInit(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, Tx);
+ break;
+ case '6':
+ if (dxtc) ReInit(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, Tx);
+ break;
+ case '7':
+ if (dxtc) ReInit(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, Tx);
+ break;
+ case '8':
+ if (dxtc) ReInit(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, Tx);
+ break;
+ case 'a':
+ if (s3tc) ReInit(GL_RGB_S3TC, Tx);
+ break;
+ case 's':
+ if (s3tc) ReInit(GL_RGB4_S3TC, Tx);
+ break;
+ case 'd':
+ if (s3tc) ReInit(GL_RGBA_S3TC, Tx);
+ break;
+ case 'f':
+ if (s3tc) ReInit(GL_RGBA4_S3TC, Tx);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+int main( int argc, char *argv[] )
+{
+ float gl_version;
+ GLint num_formats;
+ GLint i;
+ GLint formats[64];
+
+
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 400, 300 );
+
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+
+ if (glutCreateWindow(argv[0]) <= 0) {
+ printf("Couldn't create window\n");
+ exit(0);
+ }
+
+ gl_version = atof( (const char *) glGetString( GL_VERSION ) );
+ if ( (gl_version < 1.3)
+ && !glutExtensionSupported("GL_ARB_texture_compression") ) {
+ printf("Sorry, GL_ARB_texture_compression not supported\n");
+ exit(0);
+ }
+ if (glutExtensionSupported("GL_3DFX_texture_compression_FXT1")) {
+ fxt1 = GL_TRUE;
+ }
+ if (glutExtensionSupported("GL_EXT_texture_compression_s3tc")) {
+ dxtc = GL_TRUE;
+ }
+ if (glutExtensionSupported("GL_S3_s3tc")) {
+ s3tc = GL_TRUE;
+ }
+
+ glGetIntegerv( GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, & num_formats );
+
+ (void) memset( formats, 0, sizeof( formats ) );
+ glGetIntegerv( GL_COMPRESSED_TEXTURE_FORMATS_ARB, formats );
+
+ printf( "The following texture formats are supported:\n" );
+ for ( i = 0 ; i < num_formats ; i++ ) {
+ printf( "\t%s\n", TextureName( formats[i] ) );
+ }
+
+ Init();
+
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc( Idle );
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/texgenmix.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/texgenmix.c
new file mode 100644
index 000000000..be8f6775c
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/texgenmix.c
@@ -0,0 +1,640 @@
+
+/*
+ * Demonstrates mixed texgen/non-texgen texture coordinates.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+
+#undef max
+#undef min
+#define max( a, b ) ((a) >= (b) ? (a) : (b))
+#define min( a, b ) ((a) <= (b) ? (a) : (b))
+
+GLfloat labelColor0[4] = { 1.0, 1.0, 1.0, 1.0 };
+GLfloat labelColor1[4] = { 1.0, 1.0, 0.4, 1.0 };
+GLfloat *labelInfoColor = labelColor0;
+
+GLboolean doubleBuffered = GL_TRUE;
+GLboolean drawTextured = GL_TRUE;
+
+int textureWidth = 64;
+int textureHeight = 64;
+
+int winWidth = 580, winHeight = 720;
+
+const GLfloat texmat_swap_rq[16] = { 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0,
+ 0.0, 0.0, 1.0, 0.0};
+
+const GLfloat nullPlane[4] = { 0.0, 0.0, 0.0, 0.0 };
+const GLfloat ObjPlaneS1[4] = { 1.0, 0.0, 1.0, 0.0 };
+const GLfloat ObjPlaneS2[4] = { 0.5, 0.0, 0.0, 0.0 };
+const GLfloat ObjPlaneS3[4] = { 1.0, 0.0, 0.0, 0.0 };
+const GLfloat ObjPlaneT[4] = { 0.0, 1.0, 0.0, 0.0 };
+const GLfloat ObjPlaneT2[4] = { 0.0, 0.5, 0.0, 0.0 };
+const GLfloat ObjPlaneT3[4] = { 0.0, 1.0, 0.0, 0.0 };
+const GLfloat ObjPlaneR[4] = { 0.0, 0.0, 1.0, 0.0 };
+const GLfloat ObjPlaneQ[4] = { 0.0, 0.0, 0.0, 0.5 };
+
+
+static void checkErrors( void )
+{
+ GLenum error;
+
+ while ( (error = glGetError()) != GL_NO_ERROR ) {
+ fprintf( stderr, "Error: %s\n", (char *) gluErrorString( error ) );
+ }
+}
+
+static void drawString( const char *string, GLfloat x, GLfloat y,
+ const GLfloat color[4] )
+{
+ glColor4fv( color );
+ glRasterPos2f( x, y );
+
+ while ( *string ) {
+ glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_10, *string );
+ string++;
+ }
+}
+
+static void begin2D( int width, int height )
+{
+ glMatrixMode( GL_PROJECTION );
+
+ glPushMatrix();
+ glLoadIdentity();
+
+ glOrtho( 0, width, 0, height, -1, 1 );
+ glMatrixMode( GL_MODELVIEW );
+
+ glPushMatrix();
+ glLoadIdentity();
+}
+
+static void end2D( void )
+{
+ glMatrixMode( GL_PROJECTION );
+ glPopMatrix();
+ glMatrixMode( GL_MODELVIEW );
+ glPopMatrix();
+}
+
+static void initialize( void )
+{
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+
+ glOrtho( -1.5, 1.5, -1.5, 1.5, -1.5, 1.5 );
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ glShadeModel( GL_FLAT );
+}
+
+/* ARGSUSED1 */
+static void keyboard( unsigned char c, int x, int y )
+{
+ switch ( c ) {
+ case 't':
+ drawTextured = !drawTextured;
+ break;
+ case 27: /* Escape key should force exit. */
+ exit(0);
+ break;
+ default:
+ break;
+ }
+ glutPostRedisplay();
+}
+
+/* ARGSUSED1 */
+static void special( int key, int x, int y )
+{
+ switch ( key ) {
+ case GLUT_KEY_DOWN:
+ break;
+ case GLUT_KEY_UP:
+ break;
+ case GLUT_KEY_LEFT:
+ break;
+ case GLUT_KEY_RIGHT:
+ break;
+ default:
+ break;
+ }
+ glutPostRedisplay();
+}
+
+static void
+reshape( int w, int h )
+{
+ winWidth = w;
+ winHeight = h;
+ /* No need to call glViewPort here since "draw" calls it! */
+}
+
+static void loadTexture( int width, int height )
+{
+ int alphaSize = 1;
+ int rgbSize = 3;
+ GLubyte *texImage, *p;
+ int elementsPerGroup, elementSize, groupSize, rowSize;
+ int i, j;
+
+
+ elementsPerGroup = alphaSize + rgbSize;
+ elementSize = sizeof(GLubyte);
+ groupSize = elementsPerGroup * elementSize;
+ rowSize = width * groupSize;
+
+ if ( (texImage = (GLubyte *) malloc( height * rowSize ) ) == NULL ) {
+ fprintf( stderr, "texture malloc failed\n" );
+ return;
+ }
+
+ for ( i = 0 ; i < height ; i++ )
+ {
+ p = texImage + i * rowSize;
+
+ for ( j = 0 ; j < width ; j++ )
+ {
+ if ( rgbSize > 0 )
+ {
+ /**
+ ** +-----+-----+
+ ** | | |
+ ** | R | G |
+ ** | | |
+ ** +-----+-----+
+ ** | | |
+ ** | Y | B |
+ ** | | |
+ ** +-----+-----+
+ **/
+ if ( i > height / 2 ) {
+ if ( j < width / 2 ) {
+ p[0] = 0xff;
+ p[1] = 0x00;
+ p[2] = 0x00;
+ } else {
+ p[0] = 0x00;
+ p[1] = 0xff;
+ p[2] = 0x00;
+ }
+ } else {
+ if ( j < width / 2 ) {
+ p[0] = 0xff;
+ p[1] = 0xff;
+ p[2] = 0x00;
+ } else {
+ p[0] = 0x00;
+ p[1] = 0x00;
+ p[2] = 0xff;
+ }
+ }
+ p += 3 * elementSize;
+ }
+
+ if ( alphaSize > 0 )
+ {
+ /**
+ ** +-----------+
+ ** | W |
+ ** | +-----+ |
+ ** | | | |
+ ** | | B | |
+ ** | | | |
+ ** | +-----+ |
+ ** | |
+ ** +-----------+
+ **/
+ int i2 = i - height / 2;
+ int j2 = j - width / 2;
+ int h8 = height / 8;
+ int w8 = width / 8;
+ if ( -h8 <= i2 && i2 <= h8 && -w8 <= j2 && j2 <= w8 ) {
+ p[0] = 0x00;
+ } else if ( -2 * h8 <= i2 && i2 <= 2 * h8 && -2 * w8 <= j2 && j2 <= 2 * w8 ) {
+ p[0] = 0x55;
+ } else if ( -3 * h8 <= i2 && i2 <= 3 * h8 && -3 * w8 <= j2 && j2 <= 3 * w8 ) {
+ p[0] = 0xaa;
+ } else {
+ p[0] = 0xff;
+ }
+ p += elementSize;
+ }
+ }
+ }
+
+ glTexImage2D( GL_TEXTURE_2D, 0,
+ GL_RGBA, width, height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, texImage );
+
+ free( texImage );
+}
+
+
+static void drawSample( int x, int y, int w, int h,
+ int texgenenabled, int coordnr )
+{
+ char buf[255];
+
+ glViewport( x, y, w, h );
+ glScissor( x, y, w, h );
+
+ glClearColor( 0.1, 0.1, 0.1, 1.0 );
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ begin2D( w, h );
+ if (texgenenabled == 2) {
+ sprintf( buf, "TexCoord%df", coordnr);
+ drawString( buf, 10, h - 15, labelInfoColor );
+ sprintf( buf, "texgen enabled for %s coordinate(s)", coordnr == 2 ? "S" : "S/T");
+ drawString( buf, 10, 5, labelInfoColor );
+ }
+ else if (texgenenabled == 0) {
+ sprintf( buf, "TexCoord%df", coordnr);
+ drawString( buf, 10, h - 15, labelInfoColor );
+ drawString( "no texgen", 10, 5, labelInfoColor );
+ }
+ else if (texgenenabled == 1) {
+ drawString( "no TexCoord", 10, h - 15, labelInfoColor );
+ sprintf( buf, "texgen enabled for %s coordinate(s)",
+ coordnr == 2 ? "S/T" : (coordnr == 3 ? "S/T/R" : "S/T/R/Q"));
+ drawString( buf, 10, 5, labelInfoColor );
+ }
+
+ end2D();
+
+ glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
+
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
+
+ loadTexture( textureWidth, textureHeight );
+
+ if ( drawTextured ) {
+ glEnable( GL_TEXTURE_2D );
+ }
+
+ glDisable( GL_TEXTURE_GEN_S );
+ glDisable( GL_TEXTURE_GEN_T );
+ glDisable( GL_TEXTURE_GEN_R );
+ glDisable( GL_TEXTURE_GEN_Q );
+
+ glMatrixMode( GL_TEXTURE );
+ glLoadIdentity();
+ glMatrixMode( GL_MODELVIEW );
+ glPushMatrix();
+
+ switch (coordnr) {
+ case 2:
+ switch (texgenenabled) {
+ case 0:
+ glBegin( GL_QUADS );
+ glTexCoord2f( 0.0, 0.0 );
+ glVertex2f( -0.8, -0.8 );
+
+ glTexCoord2f( 1.0, 0.0 );
+ glVertex2f( 0.8, -0.8 );
+
+ glTexCoord2f( 1.0, 1.0 );
+ glVertex2f( 0.8, 0.8 );
+
+ glTexCoord2f( 0.0, 1.0 );
+ glVertex2f( -0.8, 0.8 );
+ glEnd();
+ break;
+ case 1:
+ glTranslatef( -0.8, -0.8, 0.0 );
+ glScalef( 1.6, 1.6, 1.0 );
+ glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS3);
+ glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT3);
+ glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane);
+ glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);
+
+ glEnable( GL_TEXTURE_GEN_S );
+ glEnable( GL_TEXTURE_GEN_T );
+
+ /* Issue a texcoord here to be sure Q isn't left over from a
+ * previous sample.
+ */
+ glTexCoord1f( 0.0 );
+ glBegin( GL_QUADS );
+ glVertex2f( 0.0, 0.0 );
+ glVertex2f( 1.0, 0.0 );
+ glVertex2f( 1.0, 1.0 );
+ glVertex2f( 0.0, 1.0 );
+ glEnd();
+ break;
+ case 2:
+ /* make sure that texgen T and non-texgen S coordinate are wrong */
+ glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS1);
+ glTexGenfv(GL_T, GL_OBJECT_PLANE, nullPlane);
+ glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane);
+ glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);
+
+ glEnable( GL_TEXTURE_GEN_S );
+
+ glBegin( GL_QUADS );
+ /* use z coordinate to get correct texgen values... */
+ glTexCoord2f( 0.0, 0.0 );
+ glVertex3f( -0.8, -0.8, 0.8 );
+
+ glTexCoord2f( 0.0, 0.0 );
+ glVertex3f( 0.8, -0.8, 0.2 );
+
+ glTexCoord2f( 0.0, 1.0 );
+ glVertex3f( 0.8, 0.8, 0.2 );
+
+ glTexCoord2f( 0.0, 1.0 );
+ glVertex3f( -0.8, 0.8, 0.8 );
+ glEnd();
+ break;
+ }
+ break;
+ case 3:
+ glMatrixMode( GL_TEXTURE );
+ glLoadMatrixf( texmat_swap_rq );
+ glMatrixMode( GL_MODELVIEW );
+ glTranslatef( -0.8, -0.8, 0.0 );
+ glScalef( 1.6, 1.6, 1.0 );
+ switch (texgenenabled) {
+ case 0:
+ glBegin( GL_QUADS );
+ glTexCoord3f( 0.0, 0.0, 0.5 );
+ glVertex2f( 0.0, 0.0 );
+
+ glTexCoord3f( 0.5, 0.0, 0.5 );
+ glVertex2f( 1.0, 0.0 );
+
+ glTexCoord3f( 0.5, 0.5, 0.5 );
+ glVertex2f( 1.0, 1.0 );
+
+ glTexCoord3f( 0.0, 0.5, 0.5 );
+ glVertex2f( 0.0, 1.0 );
+ glEnd();
+ break;
+ case 1:
+ glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2);
+ glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2);
+ glTexGenfv(GL_R, GL_OBJECT_PLANE, ObjPlaneR);
+ glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);
+
+ glEnable( GL_TEXTURE_GEN_S );
+ glEnable( GL_TEXTURE_GEN_T );
+ glEnable( GL_TEXTURE_GEN_R );
+
+ glTexCoord1f( 0.0 ); /* to make sure Q is 1.0 */
+ glBegin( GL_QUADS );
+ glVertex3f( 0.0, 0.0, 0.5 );
+ glVertex3f( 1.0, 0.0, 0.5 );
+ glVertex3f( 1.0, 1.0, 0.5 );
+ glVertex3f( 0.0, 1.0, 0.5 );
+ glEnd();
+ break;
+ case 2:
+ /* make sure that texgen R/Q and non-texgen S/T coordinates are wrong */
+ glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2);
+ glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2);
+ glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane);
+ glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);
+
+ glEnable( GL_TEXTURE_GEN_S );
+ glEnable( GL_TEXTURE_GEN_T );
+
+ glBegin( GL_QUADS );
+ glTexCoord3f( 0.0, 0.0, 0.5 );
+ glVertex2f( 0.0, 0.0);
+
+ glTexCoord3f( 0.0, 0.0, 0.5 );
+ glVertex2f( 1.0, 0.0);
+
+ glTexCoord3f( 0.0, 0.0, 0.5 );
+ glVertex2f( 1.0, 1.0);
+
+ glTexCoord3f( 0.0, 0.0, 0.5 );
+ glVertex2f( 0.0, 1.0);
+ glEnd();
+ break;
+ }
+ break;
+ case 4:
+ switch (texgenenabled) {
+ case 0:
+ glBegin( GL_QUADS );
+ /* don't need r coordinate but still setting it I'm mean */
+ glTexCoord4f( 0.0, 0.0, 0.0, 0.5 );
+ glVertex2f( -0.8, -0.8 );
+
+ glTexCoord4f( 0.5, 0.0, 0.2, 0.5 );
+ glVertex2f( 0.8, -0.8 );
+
+ glTexCoord4f( 0.5, 0.5, 0.5, 0.5 );
+ glVertex2f( 0.8, 0.8 );
+
+ glTexCoord4f( 0.0, 0.5, 0.5, 0.5 );
+ glVertex2f( -0.8, 0.8 );
+ glEnd();
+ break;
+ case 1:
+ glTranslatef( -0.8, -0.8, 0.0 );
+ glScalef( 1.6, 1.6, 1.0 );
+ /* make sure that texgen R/Q and non-texgen S/T coordinates are wrong */
+ glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2);
+ glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2);
+ glTexGenfv(GL_R, GL_OBJECT_PLANE, ObjPlaneR);
+ glTexGenfv(GL_Q, GL_OBJECT_PLANE, ObjPlaneQ);
+
+ glEnable( GL_TEXTURE_GEN_S );
+ glEnable( GL_TEXTURE_GEN_T );
+ glEnable( GL_TEXTURE_GEN_R );
+ glEnable( GL_TEXTURE_GEN_Q );
+
+ glBegin( GL_QUADS );
+ glVertex2f( 0.0, 0.0 );
+ glVertex2f( 1.0, 0.0 );
+ glVertex2f( 1.0, 1.0 );
+ glVertex2f( 0.0, 1.0 );
+ glEnd();
+ break;
+ case 2:
+ glTranslatef( -0.8, -0.8, 0.0 );
+ glScalef( 1.6, 1.6, 1.0 );
+ /* make sure that texgen R/Q and non-texgen S/T coordinates are wrong */
+ glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
+ glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2);
+ glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2);
+ glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane);
+ glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);
+
+ glEnable( GL_TEXTURE_GEN_S );
+ glEnable( GL_TEXTURE_GEN_T );
+
+ glBegin( GL_QUADS );
+ glTexCoord4f( 0.0, 0.0, 0.0, 0.5 );
+ glVertex2f( 0.0, 0.0 );
+
+ glTexCoord4f( 0.0, 0.0, 0.2, 0.5 );
+ glVertex2f( 1.0, 0.0 );
+
+ glTexCoord4f( 0.0, 0.0, 0.5, 0.5 );
+ glVertex2f( 1.0, 1.0 );
+
+ glTexCoord4f( 0.0, 0.0, 0.75, 0.5 );
+ glVertex2f( 0.0, 1.0 );
+ glEnd();
+ break;
+ }
+ break;
+ }
+
+ glPopMatrix();
+ glDisable( GL_TEXTURE_2D );
+
+}
+
+static void display( void )
+{
+ int numX = 3, numY = 3;
+ float xBase = (float) winWidth * 0.01;
+ float xOffset = (winWidth - xBase) / numX;
+ float xSize = max( xOffset - xBase, 1 );
+ float yBase = (float) winHeight * 0.01;
+ float yOffset = (winHeight - yBase) / numY;
+ float ySize = max( yOffset - yBase, 1 );
+ float x, y;
+ int i, j;
+
+ glViewport( 0, 0, winWidth, winHeight );
+ glDisable( GL_SCISSOR_TEST );
+ glClearColor( 0.0, 0.0, 0.0, 0.0 );
+ glClear( GL_COLOR_BUFFER_BIT );
+ glEnable( GL_SCISSOR_TEST );
+
+ x = xBase;
+ y = (winHeight - 1) - yOffset;
+
+ for ( i = 0 ; i < numY ; i++ )
+ {
+
+ labelInfoColor = labelColor1;
+
+
+ for ( j = 0 ; j < numX ; j++ ) {
+ drawSample( x, y, xSize, ySize, i, j+2 );
+ x += xOffset;
+ }
+
+ x = xBase;
+ y -= yOffset;
+ }
+
+ if ( doubleBuffered ) {
+ glutSwapBuffers();
+ } else {
+ glFlush();
+ }
+
+ checkErrors();
+}
+
+static void usage( char *name )
+{
+ fprintf( stderr, "usage: %s [ options ]\n", name );
+ fprintf( stderr, "\n" );
+ fprintf( stderr, "options:\n" );
+ fprintf( stderr, " -sb single buffered\n" );
+ fprintf( stderr, " -db double buffered\n" );
+ fprintf( stderr, " -info print OpenGL driver info\n" );
+}
+
+static void instructions( void )
+{
+ fprintf( stderr, "texgenmix - mixed texgen/non-texgen texture coordinate test\n" );
+ fprintf( stderr, "all quads should look the same!\n" );
+ fprintf( stderr, "\n" );
+ fprintf( stderr, " [t] - toggle texturing\n" );
+}
+
+int main( int argc, char *argv[] )
+{
+ GLboolean info = GL_FALSE;
+ int i;
+
+ glutInit( &argc, argv );
+
+ for ( i = 1 ; i < argc ; i++ ) {
+ if ( !strcmp( "-sb", argv[i] ) ) {
+ doubleBuffered = GL_FALSE;
+ } else if ( !strcmp( "-db", argv[i] ) ) {
+ doubleBuffered = GL_TRUE;
+ } else if ( !strcmp( "-info", argv[i] ) ) {
+ info = GL_TRUE;
+ } else {
+ usage( argv[0] );
+ exit( 1 );
+ }
+ }
+
+ if ( doubleBuffered ) {
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ } else {
+ glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE );
+ }
+
+ glutInitWindowSize( winWidth, winHeight );
+ glutInitWindowPosition( 0, 0 );
+ glutCreateWindow( "Mixed texgen/non-texgen texture coordinate test" );
+
+ initialize();
+ instructions();
+
+ if ( info ) {
+ printf( "\n" );
+ 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 ) );
+ }
+
+ glutDisplayFunc( display );
+ glutReshapeFunc( reshape );
+ glutKeyboardFunc( keyboard );
+ glutSpecialFunc( special );
+ glutMainLoop();
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/texline.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/texline.c
new file mode 100644
index 000000000..3d59d9ac2
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/texline.c
@@ -0,0 +1,269 @@
+/* $Id: texline.c,v 1.5 2004/01/28 10:07:48 keithw Exp $ */
+
+/*
+ * Test textured lines.
+ *
+ * Brian Paul
+ * September 2000
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#include "../util/readtex.c" /* I know, this is a hack. */
+
+#define TEXTURE_FILE "../images/girl.rgb"
+
+static GLboolean Antialias = GL_FALSE;
+static GLboolean Animate = GL_FALSE;
+static GLint Texture = 1;
+static GLboolean Stipple = GL_FALSE;
+static GLfloat LineWidth = 1.0;
+
+static GLfloat Xrot = -60.0, Yrot = 0.0, Zrot = 0.0;
+static GLfloat DYrot = 1.0;
+static GLboolean Points = GL_FALSE;
+static GLfloat Scale = 1.0;
+
+static void Idle( void )
+{
+ if (Animate) {
+ Zrot += DYrot;
+ glutPostRedisplay();
+ }
+}
+
+
+static void Display( void )
+{
+ GLfloat x, y, s, t;
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+ glScalef(Scale, Scale, Scale);
+
+ if (Texture)
+ glColor3f(1, 1, 1);
+
+ if (Points) {
+ glBegin(GL_POINTS);
+ for (t = 0.0; t <= 1.0; t += 0.025) {
+ for (s = 0.0; s <= 1.0; s += 0.025) {
+ x = s * 2.0 - 1.0;
+ y = t * 2.0 - 1.0;
+ if (!Texture)
+ glColor3f(1, 0, 1);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t, s);
+ glTexCoord2f(s, t);
+ glVertex2f(x, y);
+ }
+ }
+ glEnd();
+ }
+ else {
+ glBegin(GL_LINES);
+ for (t = 0.0; t <= 1.0; t += 0.025) {
+ x = t * 2.0 - 1.0;
+ if (!Texture)
+ glColor3f(1, 0, 1);
+ glTexCoord2f(t, 0.0);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, t);
+ glVertex2f(x, -1.0);
+ if (!Texture)
+ glColor3f(0, 1, 0);
+ glTexCoord2f(t, 1.0);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, t);
+ glVertex2f(x, 1.0);
+ }
+ glEnd();
+ }
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, 10.0, 100.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -12.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Antialias = !Antialias;
+ if (Antialias) {
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_POINT_SMOOTH);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ else {
+ glDisable(GL_LINE_SMOOTH);
+ glDisable(GL_POINT_SMOOTH);
+ glDisable(GL_BLEND);
+ }
+ break;
+ case 't':
+ Texture++;
+ if (Texture > 2)
+ Texture = 0;
+ if (Texture == 0) {
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+ glDisable(GL_TEXTURE_2D);
+ glActiveTextureARB(GL_TEXTURE1_ARB);
+ glDisable(GL_TEXTURE_2D);
+ }
+ else if (Texture == 1) {
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+ glEnable(GL_TEXTURE_2D);
+ glActiveTextureARB(GL_TEXTURE1_ARB);
+ glDisable(GL_TEXTURE_2D);
+ }
+ else {
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+ glEnable(GL_TEXTURE_2D);
+ glActiveTextureARB(GL_TEXTURE1_ARB);
+ glEnable(GL_TEXTURE_2D);
+ }
+ break;
+ case 'w':
+ LineWidth -= 0.25;
+ if (LineWidth < 0.25)
+ LineWidth = 0.25;
+ glLineWidth(LineWidth);
+ glPointSize(LineWidth);
+ break;
+ case 'W':
+ LineWidth += 0.25;
+ if (LineWidth > 8.0)
+ LineWidth = 8.0;
+ glLineWidth(LineWidth);
+ glPointSize(LineWidth);
+ break;
+ case 'p':
+ Points = !Points;
+ break;
+ case 's':
+ Stipple = !Stipple;
+ if (Stipple)
+ glEnable(GL_LINE_STIPPLE);
+ else
+ glDisable(GL_LINE_STIPPLE);
+ break;
+ case ' ':
+ Animate = !Animate;
+ if (Animate)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ printf("LineWidth, PointSize = %f\n", LineWidth);
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ float step = 3.0;
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot += step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot -= step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( int argc, char *argv[] )
+{
+ GLuint u;
+ for (u = 0; u < 2; u++) {
+ glActiveTextureARB(GL_TEXTURE0_ARB + u);
+ glBindTexture(GL_TEXTURE_2D, 10+u);
+ if (u == 0)
+ glEnable(GL_TEXTURE_2D);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ if (u == 0)
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ else
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
+ printf("Error: couldn't load texture image\n");
+ exit(1);
+ }
+ }
+
+ glLineStipple(1, 0xff);
+
+ if (argc > 1 && strcmp(argv[1], "-info")==0) {
+ 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));
+ }
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize( 400, 300 );
+
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+
+ glutCreateWindow(argv[0] );
+
+ Init(argc, argv);
+
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ if (Animate)
+ glutIdleFunc( Idle );
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/texobjshare.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/texobjshare.c
new file mode 100644
index 000000000..2b31cb6c4
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/texobjshare.c
@@ -0,0 +1,219 @@
+/*
+ * Create several OpenGL rendering contexts, sharing textures, display
+ * lists, etc. Exercise binding, deleting, etc.
+ *
+ * Brian Paul
+ * 21 December 2004
+ */
+
+
+#include <GL/gl.h>
+#include <GL/glx.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <X11/keysym.h>
+
+
+/*
+ * Each display/window/context:
+ */
+struct context {
+ char DisplayName[1000];
+ Display *Dpy;
+ Window Win;
+ GLXContext Context;
+};
+
+
+#define MAX_CONTEXTS 200
+static struct context Contexts[MAX_CONTEXTS];
+static int NumContexts = 0;
+
+
+static void
+Error(const char *display, const char *msg)
+{
+ fprintf(stderr, "Error on display %s - %s\n", display, msg);
+ exit(1);
+}
+
+
+static struct context *
+CreateContext(const char *displayName, const char *name)
+{
+ Display *dpy;
+ Window win;
+ GLXContext ctx;
+ int attrib[] = { GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ None };
+ int scrnum;
+ XSetWindowAttributes attr;
+ unsigned long mask;
+ Window root;
+ XVisualInfo *visinfo;
+ int width = 90, height = 90;
+ int xpos = 0, ypos = 0;
+
+ if (NumContexts >= MAX_CONTEXTS)
+ return NULL;
+
+ dpy = XOpenDisplay(displayName);
+ if (!dpy) {
+ Error(displayName, "Unable to open display");
+ return NULL;
+ }
+
+ scrnum = DefaultScreen(dpy);
+ root = RootWindow(dpy, scrnum);
+
+ visinfo = glXChooseVisual(dpy, scrnum, attrib);
+ if (!visinfo) {
+ Error(displayName, "Unable to find RGB, double-buffered visual");
+ return NULL;
+ }
+
+ /* window attributes */
+ xpos = (NumContexts % 10) * 100;
+ ypos = (NumContexts / 10) * 100;
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+ win = XCreateWindow(dpy, root, xpos, ypos, width, height,
+ 0, visinfo->depth, InputOutput,
+ visinfo->visual, mask, &attr);
+ if (!win) {
+ Error(displayName, "Couldn't create window");
+ return NULL;
+ }
+
+ {
+ XSizeHints sizehints;
+ sizehints.x = xpos;
+ sizehints.y = ypos;
+ sizehints.width = width;
+ sizehints.height = height;
+ sizehints.flags = USSize | USPosition;
+ XSetNormalHints(dpy, win, &sizehints);
+ XSetStandardProperties(dpy, win, name, name,
+ None, (char **)NULL, 0, &sizehints);
+ }
+
+ if (NumContexts == 0) {
+ ctx = glXCreateContext(dpy, visinfo, NULL, True);
+ }
+ else {
+ /* share textures & dlists with 0th context */
+ ctx = glXCreateContext(dpy, visinfo, Contexts[0].Context, True);
+ }
+ if (!ctx) {
+ Error(displayName, "Couldn't create GLX context");
+ return NULL;
+ }
+
+ XMapWindow(dpy, win);
+
+ if (!glXMakeCurrent(dpy, win, ctx)) {
+ Error(displayName, "glXMakeCurrent failed");
+ return NULL;
+ }
+
+ if (NumContexts == 0) {
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ }
+
+ /* save the info for this context */
+ {
+ struct context *h = &Contexts[NumContexts];
+ strcpy(h->DisplayName, name);
+ h->Dpy = dpy;
+ h->Win = win;
+ h->Context = ctx;
+ NumContexts++;
+ return &Contexts[NumContexts-1];
+ }
+}
+
+
+static void
+MakeCurrent(int i)
+{
+ if (!glXMakeCurrent(Contexts[i].Dpy, Contexts[i].Win, Contexts[i].Context)) {
+ fprintf(stderr, "glXMakeCurrent failed!\n");
+ }
+}
+
+
+
+static void
+DestroyContext(int i)
+{
+ XDestroyWindow(Contexts[i].Dpy, Contexts[i].Win);
+ glXDestroyContext(Contexts[i].Dpy, Contexts[i].Context);
+ XCloseDisplay(Contexts[i].Dpy);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ char *dpyName = NULL;
+ int i;
+ GLuint t;
+ GLint tb;
+
+ for (i = 0; i < 2; i++) {
+ CreateContext(dpyName, "context");
+ }
+
+ /* Create texture and bind it in context 0 */
+ MakeCurrent(0);
+ glGenTextures(1, &t);
+ printf("Generated texture ID %u\n", t);
+ assert(!glIsTexture(t));
+ glBindTexture(GL_TEXTURE_2D, t);
+ assert(glIsTexture(t));
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb);
+ assert(tb == t);
+
+ /* Bind texture in context 1 */
+ MakeCurrent(1);
+ assert(glIsTexture(t));
+ glBindTexture(GL_TEXTURE_2D, t);
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb);
+ assert(tb == t);
+
+ /* Delete texture from context 0 */
+ MakeCurrent(0);
+ glDeleteTextures(1, &t);
+ assert(!glIsTexture(t));
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb);
+ printf("After delete, binding = %d\n", tb);
+
+ /* Check texture state from context 1 */
+ MakeCurrent(1);
+ assert(!glIsTexture(t));
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb);
+ printf("In second context, binding = %d\n", tb);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb);
+ assert(tb == 0);
+
+
+ for (i = 0; i < NumContexts; i++) {
+ DestroyContext(i);
+ }
+
+ printf("Success!\n");
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/texrect.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/texrect.c
new file mode 100644
index 000000000..61c1fdd6b
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/texrect.c
@@ -0,0 +1,360 @@
+/* $Id: texrect.c,v 1.5 2004/05/06 20:27:32 brianp Exp $ */
+
+/* GL_NV_texture_rectangle test
+ *
+ * Brian Paul
+ * 14 June 2002
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+#include "readtex.h"
+
+#define TEXTURE_0_FILE "../images/girl.rgb"
+#define TEXTURE_1_FILE "../images/reflect.rgb"
+
+#define TEX0 1
+#define TEX7 8
+#define ANIMATE 10
+#define CLAMP 20
+#define CLAMP_TO_EDGE 21
+#define CLAMP_TO_BORDER 22
+#define LINEAR_FILTER 30
+#define NEAREST_FILTER 31
+#define QUIT 100
+
+static GLboolean Animate = GL_FALSE;
+static GLint NumUnits = 2;
+static GLboolean TexEnabled[8];
+static GLint Width[8], Height[8]; /* image sizes */
+static GLenum Format[8];
+
+static GLfloat Xrot = 00.0, Yrot = 00.0, Zrot = 0.0;
+
+
+static void Idle( void )
+{
+ Zrot = glutGet(GLUT_ELAPSED_TIME) * 0.01;
+ glutPostRedisplay();
+}
+
+
+static void DrawObject(void)
+{
+ GLint i;
+ GLfloat d = 10; /* so we can see how borders are handled */
+
+ glColor3f(.1, .1, .1); /* modulate this */
+
+ glPushMatrix();
+
+ glRotatef(Zrot, 0, 0, 1);
+
+ glBegin(GL_QUADS);
+
+ for (i = 0; i < NumUnits; i++)
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, -d, -d);
+ glVertex2f(-1.0, -1.0);
+
+ for (i = 0; i < NumUnits; i++)
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, Width[i]+d, -d);
+ glVertex2f(1.0, -1.0);
+
+ for (i = 0; i < NumUnits; i++)
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, Width[i]+d, Height[i]+d);
+ glVertex2f(1.0, 1.0);
+
+ for (i = 0; i < NumUnits; i++)
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, -d, Height[i]+d);
+ glVertex2f(-1.0, 1.0);
+
+ glEnd();
+ glPopMatrix();
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+ glScalef(5.0, 5.0, 5.0);
+ DrawObject();
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 100.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -35.0 );
+}
+
+
+static void ModeMenu(int entry)
+{
+ GLint i;
+ if (entry >= TEX0 && entry < TEX0 + NumUnits) {
+ /* toggle */
+ i = entry - TEX0;
+ TexEnabled[i] = !TexEnabled[i];
+ glActiveTextureARB(GL_TEXTURE0_ARB + i);
+ if (TexEnabled[i]) {
+ glEnable(GL_TEXTURE_RECTANGLE_NV);
+ }
+ else {
+ glDisable(GL_TEXTURE_RECTANGLE_NV);
+ }
+ printf("Enabled: ");
+ for (i = 0; i < NumUnits; i++)
+ printf("%d ", (int) TexEnabled[i]);
+ printf("\n");
+ }
+ else if (entry==ANIMATE) {
+ Animate = !Animate;
+ if (Animate)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ }
+ else if (entry==CLAMP) {
+ for (i = 0; i < NumUnits; i++) {
+ glActiveTextureARB(GL_TEXTURE0_ARB + i);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ }
+ }
+ else if (entry==CLAMP_TO_EDGE) {
+ for (i = 0; i < NumUnits; i++) {
+ glActiveTextureARB(GL_TEXTURE0_ARB + i);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ }
+ }
+ else if (entry==CLAMP_TO_BORDER) {
+ for (i = 0; i < NumUnits; i++) {
+ glActiveTextureARB(GL_TEXTURE0_ARB + i);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
+ }
+ }
+ else if (entry==NEAREST_FILTER) {
+ for (i = 0; i < NumUnits; i++) {
+ glActiveTextureARB(GL_TEXTURE0_ARB + i);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+ }
+ else if (entry==LINEAR_FILTER) {
+ for (i = 0; i < NumUnits; i++) {
+ glActiveTextureARB(GL_TEXTURE0_ARB + i);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ }
+ }
+
+ else if (entry==QUIT) {
+ exit(0);
+ }
+
+ glutPostRedisplay();
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'z':
+ Zrot -= 1.0;
+ break;
+ case 'Z':
+ Zrot += 1.0;
+ break;
+ case 'a':
+ Animate = !Animate;
+ if (Animate)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ float step = 3.0;
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot += step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot -= step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( int argc, char *argv[] )
+{
+ const GLenum wrap = GL_CLAMP;
+ GLuint texObj[8];
+ GLint size, i;
+
+ if (!glutExtensionSupported("GL_ARB_multitexture")) {
+ printf("Sorry, GL_ARB_multitexture needed by this program\n");
+ exit(1);
+ }
+
+ if (!glutExtensionSupported("GL_NV_texture_rectangle")) {
+ printf("Sorry, GL_NV_texture_rectangle needed by this program\n");
+ exit(1);
+ }
+
+ glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &NumUnits);
+ printf("%d texture units supported, using 2.\n", NumUnits);
+ if (NumUnits > 2)
+ NumUnits = 2;
+
+ glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &size);
+ printf("%d x %d max texture rectangle size\n", size, size);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ for (i = 0; i < NumUnits; i++) {
+ TexEnabled[i] = GL_TRUE;
+ }
+
+ /* allocate two texture objects */
+ glGenTextures(NumUnits, texObj);
+
+ /* setup the texture objects */
+ for (i = 0; i < NumUnits; i++) {
+
+ glActiveTextureARB(GL_TEXTURE0_ARB + i);
+
+ glBindTexture(GL_TEXTURE_RECTANGLE_NV, texObj[i]);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV,
+ GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV,
+ GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, wrap);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, wrap);
+
+ if (i == 0) {
+ GLubyte *img = LoadRGBImage(TEXTURE_0_FILE, &Width[0], &Height[0],
+ &Format[0]);
+ if (!img) {
+ printf("Error: couldn't load texture image\n");
+ exit(1);
+ }
+ printf("Texture %d: %s (%d x %d)\n", i,
+ TEXTURE_0_FILE, Width[0], Height[0]);
+ glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB,
+ Width[0], Height[0], 0,
+ Format[0], GL_UNSIGNED_BYTE, img);
+ }
+ else {
+ GLubyte *img = LoadRGBImage(TEXTURE_1_FILE, &Width[1], &Height[1],
+ &Format[1]);
+ if (!img) {
+ printf("Error: couldn't load texture image\n");
+ exit(1);
+ }
+ printf("Texture %d: %s (%d x %d)\n", i,
+ TEXTURE_1_FILE, Width[1], Height[1]);
+ glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB,
+ Width[1], Height[1], 0,
+ Format[1], GL_UNSIGNED_BYTE, img);
+ }
+
+ if (i < 1)
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
+ else
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
+
+ if (TexEnabled[i])
+ glEnable(GL_TEXTURE_RECTANGLE_NV);
+ }
+
+ glShadeModel(GL_FLAT);
+ glClearColor(0.3, 0.3, 0.4, 1.0);
+
+ if (argc > 1 && strcmp(argv[1], "-info")==0) {
+ 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));
+ }
+}
+
+
+int main( int argc, char *argv[] )
+{
+ GLint i;
+
+ glutInit( &argc, argv );
+ glutInitWindowSize( 300, 300 );
+ glutInitWindowPosition( 0, 0 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0] );
+
+ Init( argc, argv );
+
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ if (Animate)
+ glutIdleFunc( Idle );
+
+ glutCreateMenu(ModeMenu);
+
+ for (i = 0; i < NumUnits; i++) {
+ char s[100];
+ sprintf(s, "Toggle Texture %d", i);
+ glutAddMenuEntry(s, TEX0 + i);
+ }
+ glutAddMenuEntry("Toggle Animation", ANIMATE);
+ glutAddMenuEntry("GL_CLAMP", CLAMP);
+ glutAddMenuEntry("GL_CLAMP_TO_EDGE", CLAMP_TO_EDGE);
+ glutAddMenuEntry("GL_CLAMP_TO_BORDER", CLAMP_TO_BORDER);
+ glutAddMenuEntry("GL_NEAREST", NEAREST_FILTER);
+ glutAddMenuEntry("GL_LINEAR", LINEAR_FILTER);
+ glutAddMenuEntry("Quit", QUIT);
+ glutAttachMenu(GLUT_RIGHT_BUTTON);
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/texwrap.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/texwrap.c
new file mode 100644
index 000000000..35f5050ef
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/texwrap.c
@@ -0,0 +1,303 @@
+/* $Id: texwrap.c,v 1.7 2003/09/02 19:25:18 idr Exp $ */
+
+/*
+ * Test texture wrap modes.
+ * Press 'b' to toggle texture image borders. You should see the same
+ * rendering whether or not you're using borders.
+ *
+ * Brian Paul March 2001
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+#ifndef GL_CLAMP_TO_BORDER
+#define GL_CLAMP_TO_BORDER 0x812D
+#endif
+
+#ifndef GL_MIRRORED_REPEAT
+#define GL_MIRRORED_REPEAT 0x8370
+#endif
+
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_MIRROR_CLAMP_EXT 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
+#endif
+
+#define BORDER_TEXTURE 1
+#define NO_BORDER_TEXTURE 2
+
+#define SIZE 8
+static GLubyte BorderImage[SIZE+2][SIZE+2][4];
+static GLubyte NoBorderImage[SIZE][SIZE][4];
+static GLuint Border = 0;
+
+
+#define WRAP_MODE(m) { m , # m, GL_TRUE, 1.0, { NULL, NULL } }
+#define WRAP_EXT(m,e1,e2,v) { m , # m, GL_FALSE, v, { e1, e2 } }
+
+struct wrap_mode {
+ GLenum mode;
+ const char * name;
+ GLboolean supported;
+ GLfloat version;
+ const char * extension_names[2];
+};
+
+static struct wrap_mode modes[] = {
+ WRAP_MODE( GL_REPEAT ),
+ WRAP_MODE( GL_CLAMP ),
+ WRAP_EXT ( GL_CLAMP_TO_EDGE, "GL_EXT_texture_edge_clamp",
+ "GL_SGIS_texture_edge_clamp",
+ 1.2 ),
+ WRAP_EXT ( GL_CLAMP_TO_BORDER, "GL_ARB_texture_border_clamp",
+ "GL_SGIS_texture_border_clamp",
+ 1.3 ),
+ WRAP_EXT ( GL_MIRRORED_REPEAT, "GL_ARB_texture_mirrored_repeat",
+ "GL_IBM_texture_mirrored_repeat",
+ 1.4 ),
+ WRAP_EXT ( GL_MIRROR_CLAMP_EXT, "GL_ATI_texture_mirror_once",
+ "GL_EXT_texture_mirror_clamp",
+ 999.0 ),
+ WRAP_EXT ( GL_MIRROR_CLAMP_TO_EDGE_EXT, "GL_ATI_texture_mirror_once",
+ "GL_EXT_texture_mirror_clamp",
+ 999.0 ),
+ WRAP_EXT ( GL_MIRROR_CLAMP_TO_BORDER_EXT, "GL_EXT_texture_mirror_clamp",
+ NULL,
+ 999.0 ),
+ { 0 }
+};
+
+static void
+PrintString(const char *s)
+{
+ while (*s) {
+ glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
+ s++;
+ }
+}
+
+
+static void Display( void )
+{
+ GLenum i, j;
+ GLint offset;
+ GLfloat version;
+
+ /* Fill in the extensions that are supported.
+ */
+
+ version = atof( (char *) glGetString( GL_VERSION ) );
+ for ( i = 0 ; modes[i].mode != 0 ; i++ ) {
+ if ( ((modes[i].extension_names[0] != NULL)
+ && glutExtensionSupported(modes[i].extension_names[0]))
+ || ((modes[i].extension_names[1] != NULL)
+ && glutExtensionSupported(modes[i].extension_names[1])) ) {
+ modes[i].supported = GL_TRUE;
+ }
+ else if ( !modes[i].supported && (modes[i].version <= version) ) {
+ fprintf( stderr, "WARNING: OpenGL library meets minimum version\n"
+ " requirement for %s, but the\n"
+ " extension string is not advertised.\n"
+ " (%s%s%s)\n",
+ modes[i].name,
+ modes[i].extension_names[0],
+ (modes[i].extension_names[1] != NULL)
+ ? " or " : "",
+ (modes[i].extension_names[1] != NULL)
+ ? modes[i].extension_names[1] : "" );
+ modes[i].supported = GL_TRUE;
+ }
+ }
+
+
+ glClearColor(0.5, 0.5, 0.5, 1.0);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+#if 0
+ /* draw texture as image */
+ glDisable(GL_TEXTURE_2D);
+ glWindowPos2iARB(1, 1);
+ glDrawPixels(6, 6, GL_RGBA, GL_UNSIGNED_BYTE, (void *) TexImage);
+#endif
+
+ glBindTexture(GL_TEXTURE_2D, Border ? BORDER_TEXTURE : NO_BORDER_TEXTURE);
+
+
+ /* loop over min/mag filters */
+ for (i = 0; i < 2; i++) {
+ offset = 0;
+
+ if (i) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ }
+ else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+
+ /* loop over border modes */
+ for (j = 0; j < modes[j].mode != 0; j++) {
+ const GLfloat x0 = 0, y0 = 0, x1 = 140, y1 = 140;
+ const GLfloat b = 1.2;
+ const GLfloat s0 = -b, t0 = -b, s1 = 1.0+b, t1 = 1.0+b;
+
+ if ( modes[j].supported != GL_TRUE )
+ continue;
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, modes[j].mode);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, modes[j].mode);
+
+ glPushMatrix();
+ glTranslatef(offset * 150 + 10, i * 150 + 40, 0);
+ offset++;
+
+ glEnable(GL_TEXTURE_2D);
+ glColor3f(1, 1, 1);
+ glBegin(GL_POLYGON);
+ glTexCoord2f(s0, t0); glVertex2f(x0, y0);
+ glTexCoord2f(s1, t0); glVertex2f(x1, y0);
+ glTexCoord2f(s1, t1); glVertex2f(x1, y1);
+ glTexCoord2f(s0, t1); glVertex2f(x0, y1);
+ glEnd();
+
+ /* draw red outline showing bounds of texture at s=0,1 and t=0,1 */
+ glDisable(GL_TEXTURE_2D);
+ glColor3f(1, 0, 0);
+ glBegin(GL_LINE_LOOP);
+ glVertex2f(x0 + b * (x1-x0) / (s1-s0), y0 + b * (y1-y0) / (t1-t0));
+ glVertex2f(x1 - b * (x1-x0) / (s1-s0), y0 + b * (y1-y0) / (t1-t0));
+ glVertex2f(x1 - b * (x1-x0) / (s1-s0), y1 - b * (y1-y0) / (t1-t0));
+ glVertex2f(x0 + b * (x1-x0) / (s1-s0), y1 - b * (y1-y0) / (t1-t0));
+ glEnd();
+
+ glPopMatrix();
+ }
+ }
+
+ glDisable(GL_TEXTURE_2D);
+ glColor3f(1, 1, 1);
+ offset = 0;
+ for (i = 0; i < modes[i].mode != 0; i++) {
+ if ( modes[i].supported ) {
+ glWindowPos2iARB( offset * 150 + 10, 5 + ((offset & 1) * 15) );
+ PrintString(modes[i].name);
+ offset++;
+ }
+ }
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(0, width, 0, height, -1, 1);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'b':
+ Border = !Border;
+ printf("Texture Border Size = %d\n", Border);
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ static const GLubyte border[4] = { 0, 255, 0, 255 };
+ static const GLfloat borderf[4] = { 0, 1.0, 0, 1.0 };
+ GLint i, j;
+
+ for (i = 0; i < SIZE+2; i++) {
+ for (j = 0; j < SIZE+2; j++) {
+ if (i == 0 || j == 0 || i == SIZE+1 || j == SIZE+1) {
+ /* border color */
+ BorderImage[i][j][0] = border[0];
+ BorderImage[i][j][1] = border[1];
+ BorderImage[i][j][2] = border[2];
+ BorderImage[i][j][3] = border[3];
+ }
+ else if ((i + j) & 1) {
+ /* white */
+ BorderImage[i][j][0] = 255;
+ BorderImage[i][j][1] = 255;
+ BorderImage[i][j][2] = 255;
+ BorderImage[i][j][3] = 255;
+ }
+ else {
+ /* black */
+ BorderImage[i][j][0] = 0;
+ BorderImage[i][j][1] = 0;
+ BorderImage[i][j][2] = 0;
+ BorderImage[i][j][3] = 0;
+ }
+ }
+ }
+
+ glBindTexture(GL_TEXTURE_2D, BORDER_TEXTURE);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE+2, SIZE+2, 1,
+ GL_RGBA, GL_UNSIGNED_BYTE, (void *) BorderImage);
+
+ for (i = 0; i < SIZE; i++) {
+ for (j = 0; j < SIZE; j++) {
+ if ((i + j) & 1) {
+ /* white */
+ NoBorderImage[i][j][0] = 255;
+ NoBorderImage[i][j][1] = 255;
+ NoBorderImage[i][j][2] = 255;
+ NoBorderImage[i][j][3] = 255;
+ }
+ else {
+ /* black */
+ NoBorderImage[i][j][0] = 0;
+ NoBorderImage[i][j][1] = 0;
+ NoBorderImage[i][j][2] = 0;
+ NoBorderImage[i][j][3] = 0;
+ }
+ }
+ }
+
+ glBindTexture(GL_TEXTURE_2D, NO_BORDER_TEXTURE);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE, SIZE, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, (void *) NoBorderImage);
+ glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderf);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 800, 355 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/vparray.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/vparray.c
new file mode 100644
index 000000000..580a670f8
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/vparray.c
@@ -0,0 +1,294 @@
+/*
+ * Test vertex arrays with GL_NV_vertex_program
+ *
+ * Based on a stripped-down version of the isosurf demo.
+ * The vertex program is trivial: compute the resulting
+ * RGB color as a linear function of vertex XYZ.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include "GL/glut.h"
+
+#define MAXVERTS 10000
+static float data[MAXVERTS][6];
+static GLint numverts;
+
+static GLfloat xrot;
+static GLfloat yrot;
+static GLboolean useArrays = GL_TRUE;
+static GLboolean useProgram = GL_TRUE;
+static GLboolean useList = GL_FALSE;
+
+
+static void read_surface( char *filename )
+{
+ FILE *f;
+
+ f = fopen(filename,"r");
+ if (!f) {
+ printf("couldn't read %s\n", filename);
+ exit(1);
+ }
+
+ numverts = 0;
+ while (!feof(f) && numverts < MAXVERTS) {
+ fscanf( f, "%f %f %f %f %f %f",
+ &data[numverts][0], &data[numverts][1], &data[numverts][2],
+ &data[numverts][3], &data[numverts][4], &data[numverts][5] );
+ numverts++;
+ }
+ numverts--;
+
+ printf("%d vertices, %d triangles\n", numverts, numverts-2);
+ printf("data = %p\n", (void *) data);
+ fclose(f);
+}
+
+
+
+
+static void Display(void)
+{
+ if (useProgram)
+ glEnable(GL_VERTEX_PROGRAM_NV);
+ else
+ glDisable(GL_VERTEX_PROGRAM_NV);
+
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(xrot, 1, 0, 0);
+ glRotatef(yrot, 0, 1, 0);
+ glScalef(2, 2, 2);
+ if (useArrays) {
+ if (useProgram) {
+ glVertexAttribPointerNV( 0, 3, GL_FLOAT, 6 * sizeof(GLfloat), data );
+ glEnableClientState( GL_VERTEX_ATTRIB_ARRAY0_NV );
+ glVertexAttribPointerNV( 2, 3, GL_FLOAT, 6 * sizeof(GLfloat), ((GLfloat *) data) + 3);
+ glEnableClientState( GL_VERTEX_ATTRIB_ARRAY2_NV);
+ }
+ else {
+ glVertexPointer( 3, GL_FLOAT, 6 * sizeof(GLfloat), data );
+ glEnableClientState( GL_VERTEX_ARRAY );
+ glNormalPointer( GL_FLOAT, 6 * sizeof(GLfloat), ((GLfloat *) data) + 3);
+ glEnableClientState( GL_NORMAL_ARRAY );
+ }
+
+ if (useList) {
+ /* dumb, but a good test */
+ glNewList(1,GL_COMPILE);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, numverts);
+ glEndList();
+ glCallList(1);
+ }
+ else {
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, numverts);
+ }
+
+ glDisableClientState( GL_VERTEX_ATTRIB_ARRAY0_NV );
+ glDisableClientState( GL_VERTEX_ATTRIB_ARRAY2_NV);
+ glDisableClientState( GL_VERTEX_ARRAY );
+ glDisableClientState( GL_NORMAL_ARRAY );
+ }
+ else {
+ int i;
+ glBegin(GL_TRIANGLE_STRIP);
+ for (i = 0; i < numverts; i++) {
+ glNormal3fv( data[i] + 3 );
+ glVertex3fv( data[i] + 0 );
+ }
+ glEnd();
+ }
+ glPopMatrix();
+
+ if (glGetError())
+ printf("Error!\n");
+
+ glutSwapBuffers();
+}
+
+
+static void InitMaterials(void)
+{
+ static float ambient[] = {0.1, 0.1, 0.1, 1.0};
+ static float diffuse[] = {0.5, 1.0, 1.0, 1.0};
+ static float position0[] = {0.0, 0.0, 20.0, 0.0};
+ static float position1[] = {0.0, 0.0, -20.0, 0.0};
+ static float front_mat_shininess[] = {60.0};
+ static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0};
+ static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0};
+ /*
+ static float back_mat_shininess[] = {60.0};
+ static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0};
+ static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0};
+ */
+ static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0};
+ static float lmodel_twoside[] = {GL_FALSE};
+
+ glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+ glLightfv(GL_LIGHT0, GL_POSITION, position0);
+ glEnable(GL_LIGHT0);
+
+ glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
+ glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
+ glLightfv(GL_LIGHT1, GL_POSITION, position1);
+ glEnable(GL_LIGHT1);
+
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_mat_shininess);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_mat_specular);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, front_mat_diffuse);
+ glEnable(GL_LIGHTING);
+}
+
+
+static void init_program(void)
+{
+ /*
+ * c[0..3] = modelview matrix
+ * c[4..7] = inverse modelview matrix
+ * c[30] = color scale
+ * c[31] = color bias
+ */
+ static const char prog[] =
+ "!!VP1.0\n"
+
+ "# RGB is proportional to XYZ \n"
+
+ "MUL R0, v[OPOS], c[30]; \n"
+ "ADD o[COL0], R0, c[31]; \n"
+
+ "# Continue with typical modelview/projection\n"
+ "MOV R3, v[OPOS]; \n"
+ "DP4 o[HPOS].x, c[0], R3 ; # object x MVP -> clip\n"
+ "DP4 o[HPOS].y, c[1], R3 ;\n"
+ "DP4 o[HPOS].z, c[2], R3 ;\n"
+ "DP4 o[HPOS].w, c[3], R3 ;\n"
+
+ "END";
+
+ static const GLfloat scale[4] = {2.0, 2.0, 2.0, 0.0};
+ static const GLfloat bias[4] = {1.0, 1.0, 1.0, 0.0};
+
+ if (!glutExtensionSupported("GL_NV_vertex_program")) {
+ printf("Sorry, this program requires GL_NV_vertex_program");
+ exit(1);
+ }
+
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1,
+ strlen(prog), (const GLubyte *) prog);
+ assert(glIsProgramNV(1));
+ glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1);
+
+ /* Load the program registers */
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV);
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV);
+
+ glProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV, 30, scale);
+ glProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV, 31, bias);
+}
+
+
+static void init(void)
+{
+ xrot = 0;
+ yrot = 0;
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+ glEnable( GL_DEPTH_TEST );
+ glEnable(GL_NORMALIZE);
+ InitMaterials();
+ read_surface( "../demos/isosurf.dat" );
+ init_program();
+}
+
+
+static void Reshape(int width, int height)
+{
+ glViewport(0, 0, (GLint)width, (GLint)height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5, 25 );
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0, 0, -15);
+}
+
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ case 'a':
+ useArrays = !useArrays;
+ printf("use arrays: %s\n", useArrays ? "yes" : "no");
+ break;
+ case 'l':
+ useList = !useList;
+ printf("use list: %s\n", useList ? "yes" : "no");
+ break;
+ case 'p':
+ useProgram = !useProgram;
+ printf("use program: %s\n", useProgram ? "yes" : "no");
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_LEFT:
+ yrot -= 15.0;
+ break;
+ case GLUT_KEY_RIGHT:
+ yrot += 15.0;
+ break;
+ case GLUT_KEY_UP:
+ xrot += 15.0;
+ break;
+ case GLUT_KEY_DOWN:
+ xrot -= 15.0;
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
+
+
+int main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+ glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE );
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(400, 400);
+ if (glutCreateWindow("Isosurface") <= 0) {
+ exit(0);
+ }
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Display);
+
+ init();
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/vpeval.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/vpeval.c
new file mode 100644
index 000000000..8b6996d3b
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/vpeval.c
@@ -0,0 +1,231 @@
+/*
+ * Vertex program evaluators test.
+ * Based on book/bezmesh.c
+ *
+ * Brian Paul
+ * 22 June 2002
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+/*
+ * Transform position by modelview/projection.
+ * Square incoming color.
+ */
+static const char prog[] =
+"!!VP1.0\n"
+
+"# Typical modelview/projection\n"
+"DP4 o[HPOS].x, c[0], v[OPOS] ; # object x MVP -> clip\n"
+"DP4 o[HPOS].y, c[1], v[OPOS] ;\n"
+"DP4 o[HPOS].z, c[2], v[OPOS] ;\n"
+"DP4 o[HPOS].w, c[3], v[OPOS] ;\n"
+
+"MOV R0, v[COL0];\n # square the color\n"
+"MUL R0, R0, R0;\n"
+"MOV o[COL0], R0;\n # store output color\n"
+
+"END";
+
+
+static int program = 1;
+
+
+GLfloat ctrlpoints[4][4][4] =
+{
+ {
+ {-1.5, -1.5, 4.0, 1.0},
+ {-0.5, -1.5, 2.0, 1.0},
+ {0.5, -1.5, -1.0, 1.0},
+ {1.5, -1.5, 2.0, 1.0}},
+ {
+ {-1.5, -0.5, 1.0, 1.0},
+ {-0.5, -0.5, 3.0, 1.0},
+ {0.5, -0.5, 0.0, 1.0},
+ {1.5, -0.5, -1.0, 1.0}},
+ {
+ {-1.5, 0.5, 4.0, 1.0},
+ {-0.5, 0.5, 0.0, 1.0},
+ {0.5, 0.5, 3.0, 1.0},
+ {1.5, 0.5, 4.0, 1.0}},
+ {
+ {-1.5, 1.5, -2.0, 1.0},
+ {-0.5, 1.5, -2.0, 1.0},
+ {0.5, 1.5, 0.0, 1.0},
+ {1.5, 1.5, -1.0, 1.0}}
+};
+
+/*
+ * +-------------+
+ * |green |yellow
+ * | |
+ * | |
+ * |black |red
+ * +-------------+
+ */
+GLfloat colorPoints[4][4][4] =
+{
+ {
+ {0.0, 0.0, 0.0, 1.0},
+ {0.3, 0.0, 0.0, 1.0},
+ {0.6, 0.0, 0.0, 1.0},
+ {1.0, 0.0, 0.0, 1.0}},
+ {
+ {0.0, 0.3, 0.0, 1.0},
+ {0.3, 0.3, 0.0, 1.0},
+ {0.6, 0.3, 0.0, 1.0},
+ {1.0, 0.3, 0.0, 1.0}},
+ {
+ {0.0, 0.6, 0.0, 1.0},
+ {0.3, 0.6, 0.0, 1.0},
+ {0.6, 0.6, 0.0, 1.0},
+ {1.0, 0.6, 0.0, 1.0}},
+ {
+ {0.0, 1.0, 0.0, 1.0},
+ {0.3, 1.0, 0.0, 1.0},
+ {0.6, 1.0, 0.0, 1.0},
+ {1.0, 1.0, 0.0, 1.0}}
+};
+
+
+void
+initlights(void)
+{
+ GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0};
+ GLfloat position[] = {0.0, 0.0, 2.0, 1.0};
+ GLfloat mat_diffuse[] = {0.6, 0.6, 0.6, 1.0};
+ GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
+ GLfloat mat_shininess[] = {50.0};
+
+#if 0 /* no lighting for now */
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+
+ glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+ glLightfv(GL_LIGHT0, GL_POSITION, position);
+
+ glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
+#endif
+}
+
+void
+display(void)
+{
+ glClearColor(.3, .3, .3, 0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glPushMatrix();
+#if 1
+ glRotatef(85.0, 1.0, 1.0, 1.0);
+#endif
+ glEvalMesh2(GL_FILL, 0, 8, 0, 8);
+ glPopMatrix();
+ glFlush();
+}
+
+void
+myinit(int argc, char *argv[])
+{
+ glClearColor(0.0, 0.0, 0.0, 1.0);
+ glEnable(GL_DEPTH_TEST);
+
+ initlights(); /* for lighted version only */
+
+ glMapGrid2f(8, 0.0, 1.0, 8, 0.0, 1.0);
+
+ if (argc > 1)
+ program = 0;
+
+ printf("Using vertex program attribs? %s\n", program ? "yes" : "no");
+
+ if (!program) {
+ glMap2f(GL_MAP2_VERTEX_4,
+ 0.0, 1.0, 4, 4,
+ 0.0, 1.0, 16, 4, &ctrlpoints[0][0][0]);
+ glMap2f(GL_MAP2_COLOR_4,
+ 0.0, 1.0, 4, 4,
+ 0.0, 1.0, 16, 4, &colorPoints[0][0][0]);
+ glEnable(GL_MAP2_VERTEX_4);
+ glEnable(GL_MAP2_COLOR_4);
+ /*
+ glEnable(GL_AUTO_NORMAL);
+ glEnable(GL_NORMALIZE);
+ */
+ }
+ else {
+ glMap2f(GL_MAP2_VERTEX_ATTRIB0_4_NV,
+ 0.0, 1.0, 4, 4,
+ 0.0, 1.0, 16, 4, &ctrlpoints[0][0][0]);
+ glMap2f(GL_MAP2_VERTEX_ATTRIB3_4_NV,
+ 0.0, 1.0, 4, 4,
+ 0.0, 1.0, 16, 4, &colorPoints[0][0][0]);
+ glEnable(GL_MAP2_VERTEX_ATTRIB0_4_NV);
+ glEnable(GL_MAP2_VERTEX_ATTRIB3_4_NV);
+
+ /*
+ glEnable(GL_AUTO_NORMAL);
+ glEnable(GL_NORMALIZE);
+ */
+
+ /* vertex program init */
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1,
+ strlen(prog), (const GLubyte *) prog);
+ assert(glIsProgramNV(1));
+ glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1);
+
+ /* track matrices */
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV);
+ glEnable(GL_VERTEX_PROGRAM_NV);
+ }
+}
+
+void
+myReshape(int w, int h)
+{
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ if (w <= h)
+ glOrtho(-4.0, 4.0, -4.0 * (GLfloat) h / (GLfloat) w,
+ 4.0 * (GLfloat) h / (GLfloat) w, -4.0, 4.0);
+ else
+ glOrtho(-4.0 * (GLfloat) w / (GLfloat) h,
+ 4.0 * (GLfloat) w / (GLfloat) h, -4.0, 4.0, -4.0, 4.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
+int
+main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+ glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
+ glutInitWindowPosition(0, 0);
+ glutCreateWindow(argv[0]);
+ myinit(argc, argv);
+ glutReshapeFunc(myReshape);
+ glutDisplayFunc(display);
+ glutKeyboardFunc(key);
+ glutMainLoop();
+ return 0; /* ANSI C requires main to return int. */
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/vptest1.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/vptest1.c
new file mode 100644
index 000000000..560df2c3f
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/vptest1.c
@@ -0,0 +1,170 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+
+ glBegin(GL_POLYGON);
+ glVertexAttrib2fNV(0, -1, -1);
+ glVertexAttrib2fNV(0, 1, -1);
+ glVertexAttrib2fNV(0, 0, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ static const char *prog1 =
+ "!!VP1.0\n"
+ "MUL o[COL0].xyz, R0, c[35]; \n"
+ "END\n";
+ static const char *prog2 =
+ "!!VP1.0\n"
+ "#\n"
+ "# c[0-3] = modelview projection (composite) matrix\n"
+ "# c[32] = normalized light direction in object-space\n"
+ "# c[35] = yellow diffuse material, (1.0, 1.0, 0.0, 1.0)\n"
+ "# c[64].x = 0.0\n"
+ "# c[64].z = 0.125, a scaling factor\n"
+ "#\n"
+ "# outputs diffuse illumination for color and perturbed position\n"
+ "#\n"
+ "DP3 R0, c[32], v[NRML]; # light direction DOT normal\n"
+ "MUL o[COL0].xyz, R0, c[35]; \n"
+ "MAX R0, c[64].x, R0; \n"
+ "MUL R0, R0, v[NRML]; \n"
+ "MUL R0, R0, c[64].z; \n"
+ "ADD R1, v[OPOS], -R0; # perturb object space position\n"
+ "DP4 o[HPOS].x, c[0], R1; \n"
+ "DP4 o[HPOS].y, c[1], R1; \n"
+ "DP4 o[HPOS].z, c[2], R1; \n"
+ "DP4 o[HPOS].w, c[3], R1; \n"
+ "END\n";
+ static const char *prog3 =
+ "!!VP1.0\n"
+ "DP4 o[HPOS].x, c[0], v[OPOS];\n"
+ "DP4 o[HPOS].y, c[1], v[OPOS];\n"
+ "DP4 o[HPOS].z, c[2], v[OPOS];\n"
+ "DP4 o[HPOS].w, c[3], v[OPOS];\n"
+ "DP3 R0.x, c[4], v[NRML];\n"
+ "DP3 R0.y, c[5], v[NRML]; \n"
+ "DP3 R0.z, c[6], v[NRML]; # R0 = n' = transformed normal\n"
+ "DP3 R1.x, c[32], R0; # R1.x = Lpos DOT n'\n"
+ "DP3 R1.y, c[33], R0; # R1.y = hHat DOT n'\n"
+ "MOV R1.w, c[38].x; # R1.w = specular power\n"
+ "LIT R2, R1; # Compute lighting values\n"
+ "MAD R3, c[35].x, R2.y, c[35].y; # diffuse + emissive\n"
+ "MAD o[COL0].xyz, c[36], R2.z, R3; # + specular\n"
+ "END\n";
+ static const char *prog4 =
+ "!!VP1.0\n"
+ "DP4 R2, R3, c[A0.x];\n"
+ "DP4 R2, R3, c[A0.x + 5];\n"
+ "DP4 o[HPOS], R3, c[A0.x - 4];\n"
+ "END\n";
+ static const char *prog5 =
+ "!!VSP1.0\n"
+ "DP4 R2, R3, c[A0.x];\n"
+ "DP4 R2, R3, v[0];\n"
+ "DP4 c[3], R3, R2;\n"
+ "END\n";
+
+
+ GLuint progs[5];
+
+ glGenProgramsNV(2, progs);
+ assert(progs[0]);
+ assert(progs[1]);
+ assert(progs[0] != progs[1]);
+
+ glGenProgramsNV(3, progs + 2);
+ assert(progs[2]);
+ assert(progs[3]);
+ assert(progs[2] != progs[3]);
+ assert(progs[0] != progs[2]);
+
+
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1,
+ strlen(prog1),
+ (const GLubyte *) prog1);
+ assert(!glIsProgramNV(1));
+
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 2,
+ strlen(prog2),
+ (const GLubyte *) prog2);
+ assert(glIsProgramNV(2));
+
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 3,
+ strlen(prog3),
+ (const GLubyte *) prog3);
+ assert(glIsProgramNV(3));
+
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 4,
+ strlen(prog4),
+ (const GLubyte *) prog4);
+ assert(glIsProgramNV(4));
+
+ glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 5,
+ strlen(prog5),
+ (const GLubyte *) prog5);
+ assert(glIsProgramNV(5));
+
+ printf("glGetError = %d\n", (int) glGetError());
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/vptest2.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/vptest2.c
new file mode 100644
index 000000000..2158e07f0
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/vptest2.c
@@ -0,0 +1,151 @@
+/* Test vertex state program execution */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glPushMatrix();
+ glutSolidCube(2.0);
+ glPopMatrix();
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Test1( void )
+{
+ static const GLfloat p[4] = {9, 8, 7, 6};
+ GLfloat q[4];
+ /* test addition */
+ static const char *prog =
+ "!!VSP1.0\n"
+ "MOV R0, c[0];\n"
+ "MOV R1, c[1];\n"
+ "ADD c[2], R0, R1;\n"
+ "END\n";
+
+ glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1,
+ strlen(prog),
+ (const GLubyte *) prog);
+ assert(glIsProgramNV(1));
+
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 0, 1, 2, 3, 4);
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 1, 10, 20, 30, 40);
+
+ glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1, p);
+
+ glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV, 2, GL_PROGRAM_PARAMETER_NV, q);
+ printf("Result c[2] = %g %g %g %g (should be 11 22 33 44)\n",
+ q[0], q[1], q[2], q[3]);
+}
+
+
+static void Test2( void )
+{
+ static const GLfloat p[4] = {9, 8, 7, 6};
+ GLfloat q[4];
+ /* test swizzling */
+ static const char *prog =
+ "!!VSP1.0\n"
+ "MOV R0, c[0].wzyx;\n"
+ "MOV R1, c[1].wzyx;\n"
+ "ADD c[2], R0, R1;\n"
+ "END\n";
+
+ glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1,
+ strlen(prog),
+ (const GLubyte *) prog);
+ assert(glIsProgramNV(1));
+
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 0, 1, 2, 3, 4);
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 1, 10, 20, 30, 40);
+
+ glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1, p);
+
+ glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV, 2, GL_PROGRAM_PARAMETER_NV, q);
+ printf("Result c[2] = %g %g %g %g (should be 44 33 22 11)\n",
+ q[0], q[1], q[2], q[3]);
+}
+
+
+static void Test3( void )
+{
+ static const GLfloat p[4] = {0, 0, 0, 0};
+ GLfloat q[4];
+ /* normalize vector */
+ static const char *prog =
+ "!!VSP1.0\n"
+ "# c[0] = (nx,ny,nz)\n"
+ "# R0.xyz = normalize(R1)\n"
+ "# R0.w = 1/sqrt(nx*nx + ny*ny + nz*nz)\n"
+ "# c[2] = R0\n"
+ "DP3 R0.w, c[0], c[0];\n"
+ "RSQ R0.w, R0.w;\n"
+ "MUL R0.xyz, c[0], R0.w;\n"
+ "MOV c[2], R0;\n"
+ "END\n";
+
+ glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1,
+ strlen(prog),
+ (const GLubyte *) prog);
+ assert(glIsProgramNV(1));
+
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 0, 0, 10, 0, 0);
+
+ glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1, p);
+
+ glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV, 2, GL_PROGRAM_PARAMETER_NV, q);
+ printf("Result c[2] = %g %g %g %g (should be 0, 1, 0, 0.1)\n",
+ q[0], q[1], q[2], q[3]);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 50, 50 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Test1();
+ Test2();
+ Test3();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/vptest3.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/vptest3.c
new file mode 100644
index 000000000..2c5c80004
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/vptest3.c
@@ -0,0 +1,120 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static float Zrot = 0.0;
+
+
+static void Display( void )
+{
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+ glLoadIdentity();
+ glRotatef(Zrot, 0, 0, 1);
+
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW, GL_IDENTITY_NV);
+ glPushMatrix();
+
+ glVertexAttrib3fNV(3, 1, 0.5, 0.25);
+ glBegin(GL_TRIANGLES);
+#if 1
+ glVertexAttrib3fNV(3, 1.0, 0.0, 0.0);
+ glVertexAttrib2fNV(0, -0.5, -0.5);
+ glVertexAttrib3fNV(3, 0.0, 1.0, 0.0);
+ glVertexAttrib2fNV(0, 0.5, -0.5);
+ glVertexAttrib3fNV(3, 0.0, 0.0, 1.0);
+ glVertexAttrib2fNV(0, 0, 0.5);
+#else
+ glVertex2f( -1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 0, 1);
+#endif
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ /* glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/
+ glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ /*glTranslatef( 0.0, 0.0, -15.0 );*/
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'z':
+ Zrot -= 5.0;
+ break;
+ case 'Z':
+ Zrot += 5.0;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ static const char *prog1 =
+ "!!VP1.0\n"
+ "MOV o[COL0], v[COL0];\n"
+#if 0
+ "MOV o[HPOS], v[OPOS];\n"
+#else
+ "DP4 o[HPOS].x, v[OPOS], c[0];\n"
+ "DP4 o[HPOS].y, v[OPOS], c[1];\n"
+ "DP4 o[HPOS].z, v[OPOS], c[2];\n"
+ "DP4 o[HPOS].w, v[OPOS], c[3];\n"
+#endif
+ "END\n";
+
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1,
+ strlen(prog1),
+ (const GLubyte *) prog1);
+ assert(glIsProgramNV(1));
+
+ glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1);
+
+ printf("glGetError = %d\n", (int) glGetError());
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/vptorus.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/vptorus.c
new file mode 100644
index 000000000..764dea4ec
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/vptorus.c
@@ -0,0 +1,174 @@
+/*
+ * A lit, rotating torus via vertex program
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static float Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
+static GLboolean Anim = GL_TRUE;
+
+
+static void Idle( void )
+{
+ Xrot += .3;
+ Yrot += .4;
+ Zrot += .2;
+ glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+ glutSolidTorus(0.75, 2.0, 10, 20);
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -12.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case ' ':
+ Xrot = Yrot = Zrot = 0;
+ break;
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'z':
+ Zrot -= 5.0;
+ break;
+ case 'Z':
+ Zrot += 5.0;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ /* borrowed from an nvidia demo:
+ * c[0..3] = modelview matrix
+ * c[4..7] = inverse modelview matrix
+ * c[32] = light pos
+ * c[35] = diffuse color
+ */
+ static const char prog[] =
+ "!!VP1.0\n"
+ "#Simple transform and diffuse lighting\n"
+ "\n"
+ "DP4 o[HPOS].x, c[0], v[OPOS] ; # object x MVP -> clip\n"
+ "DP4 o[HPOS].y, c[1], v[OPOS] ;\n"
+ "DP4 o[HPOS].z, c[2], v[OPOS] ;\n"
+ "DP4 o[HPOS].w, c[3], v[OPOS] ;\n"
+
+ "DP3 R1.x, c[4], v[NRML] ; # normal x MV-1T -> lighting normal\n"
+ "DP3 R1.y, c[5], v[NRML] ;\n"
+ "DP3 R1.z, c[6], v[NRML] ;\n"
+
+ "DP3 R0, c[32], R1 ; # L.N\n"
+ "MUL o[COL0].xyz, R0, c[35] ; # col = L.N * diffuse\n"
+ "MOV o[TEX0], v[TEX0];\n"
+ "END";
+
+ if (!glutExtensionSupported("GL_NV_vertex_program")) {
+ printf("Sorry, this program requires GL_NV_vertex_program");
+ exit(1);
+ }
+
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1,
+ strlen(prog), (const GLubyte *) prog);
+ assert(glIsProgramNV(1));
+ glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1);
+
+ /* Load the program registers */
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV);
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV);
+
+ /* Light position */
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 32, 2, 2, 4, 1);
+ /* Diffuse material color */
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 35, 0.25, 0, 0.25, 1);
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+ glEnable(GL_DEPTH_TEST);
+ glClearColor(0.3, 0.3, 0.3, 1);
+
+ printf("glGetError = %d\n", (int) glGetError());
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/vpwarpmesh.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/vpwarpmesh.c
new file mode 100644
index 000000000..56aa8200e
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/vpwarpmesh.c
@@ -0,0 +1,236 @@
+/*
+ * Warp a triangle mesh with a vertex program.
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static float Xrot = -60.0, Yrot = 0.0, Zrot = 0.0;
+static GLboolean Anim = GL_TRUE;
+static GLfloat Phi = 0.0;
+
+
+static void Idle( void )
+{
+ Phi += 0.01;
+ glutPostRedisplay();
+}
+
+
+static void DrawMesh( int rows, int cols )
+{
+ static const GLfloat colorA[3] = { 0, 1, 0 };
+ static const GLfloat colorB[3] = { 0, 0, 1 };
+ const float dx = 2.0 / (cols - 1);
+ const float dy = 2.0 / (rows - 1);
+ float x, y;
+ int i, j;
+
+#if 1
+#define COLOR3FV(c) glVertexAttrib3fvNV(3, c)
+#define VERTEX2F(x, y) glVertexAttrib2fNV(0, x, y)
+#else
+#define COLOR3FV(c) glColor3fv(c)
+#define VERTEX2F(x, y) glVertex2f(x, y)
+#endif
+
+ y = -1.0;
+ for (i = 0; i < rows - 1; i++) {
+ glBegin(GL_QUAD_STRIP);
+ x = -1.0;
+ for (j = 0; j < cols; j++) {
+ if ((i + j) & 1)
+ COLOR3FV(colorA);
+ else
+ COLOR3FV(colorB);
+ VERTEX2F(x, y);
+ VERTEX2F(x, y + dy);
+ x += dx;
+ }
+ glEnd();
+ y += dy;
+ }
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+
+ /* Position the gravity source */
+ {
+ GLfloat x, y, z, r = 0.5;
+ x = r * cos(Phi);
+ y = r * sin(Phi);
+ z = 1.0;
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 30, x, y, z, 1);
+ glDisable(GL_VERTEX_PROGRAM_NV);
+ glBegin(GL_POINTS);
+ glColor3f(1,1,1);
+ glVertex3f(x, y, z);
+ glEnd();
+ }
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+ DrawMesh(8, 8);
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ float ar = (float) width / (float) height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0 * ar, 1.0 * ar, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -12.0 );
+ glScalef(2, 2, 2);
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'p':
+ Phi += 0.2;
+ break;
+ case 'z':
+ Zrot -= 5.0;
+ break;
+ case 'Z':
+ Zrot += 5.0;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ /*
+ * c[0..3] = modelview matrix
+ * c[4..7] = inverse modelview matrix
+ * c[30] = gravity source location
+ * c[31] = gravity source strength
+ * c[32] = light pos
+ * c[35] = diffuse color
+ */
+ static const char prog[] =
+ "!!VP1.0\n"
+
+ "# Compute distance from vertex to gravity source\n"
+ "ADD R1, c[30], -v[OPOS]; # vector from vertex to gravity\n"
+ "DP3 R2, R1, R1; # dot product\n"
+ "RSQ R2, R2.x; # square root = distance\n"
+ "MUL R2, R2, c[31].xxxx; # scale by the gravity factor\n"
+
+ "# Displace vertex by gravity factor along R1 vector\n"
+ "MAD R3, R1, R2, v[OPOS];\n"
+
+ "# Continue with typical modelview/projection\n"
+ "DP4 o[HPOS].x, c[0], R3 ; # object x MVP -> clip\n"
+ "DP4 o[HPOS].y, c[1], R3 ;\n"
+ "DP4 o[HPOS].z, c[2], R3 ;\n"
+ "DP4 o[HPOS].w, c[3], R3 ;\n"
+
+ "MOV o[COL0], v[COL0];\n # copy input color to output color\n"
+
+ "END";
+
+ if (!glutExtensionSupported("GL_NV_vertex_program")) {
+ printf("Sorry, this program requires GL_NV_vertex_program\n");
+ exit(1);
+ }
+
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1,
+ strlen(prog), (const GLubyte *) prog);
+ assert(glIsProgramNV(1));
+ glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1);
+
+ /* Load the program registers */
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV);
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV);
+
+ /* Light position */
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 32, 2, 2, 4, 1);
+ /* Diffuse material color */
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 35, 0.25, 0, 0.25, 1);
+
+ /* Gravity strength */
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 31, .5, 0, 0, 0);
+
+ glEnable(GL_DEPTH_TEST);
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glShadeModel(GL_FLAT);
+ glPointSize(3);
+ printf("glGetError = %d\n", (int) glGetError());
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/yuvrect.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/yuvrect.c
new file mode 100644
index 000000000..acef40609
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/yuvrect.c
@@ -0,0 +1,193 @@
+/*
+ * Test the GL_NV_texture_rectangle and GL_MESA_ycrcb_texture extensions.
+ *
+ * Brian Paul 13 September 2002
+ */
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#include "../util/readtex.c" /* I know, this is a hack. */
+
+#define TEXTURE_FILE "../images/girl.rgb"
+
+static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
+static GLint ImgWidth, ImgHeight;
+static GLushort *ImageYUV = NULL;
+
+
+static void DrawObject(void)
+{
+ glBegin(GL_QUADS);
+
+ glTexCoord2f(0, 0);
+ glVertex2f(-1.0, -1.0);
+
+ glTexCoord2f(ImgWidth, 0);
+ glVertex2f(1.0, -1.0);
+
+ glTexCoord2f(ImgWidth, ImgHeight);
+ glVertex2f(1.0, 1.0);
+
+ glTexCoord2f(0, ImgHeight);
+ glVertex2f(-1.0, 1.0);
+
+ glEnd();
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+ DrawObject();
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ float step = 3.0;
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot += step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot -= step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+
+static void Init( int argc, char *argv[] )
+{
+ GLuint texObj = 100;
+ const char *file;
+
+ if (!glutExtensionSupported("GL_NV_texture_rectangle")) {
+ printf("Sorry, GL_NV_texture_rectangle is required\n");
+ exit(0);
+ }
+
+ if (!glutExtensionSupported("GL_MESA_ycbcr_texture")) {
+ printf("Sorry, GL_MESA_ycbcr_texture is required\n");
+ exit(0);
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glBindTexture(GL_TEXTURE_RECTANGLE_NV, texObj);
+#ifdef LINEAR_FILTER
+ /* linear filtering looks much nicer but is much slower for Mesa */
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+#else
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+#endif
+
+ if (argc > 1)
+ file = argv[1];
+ else
+ file = TEXTURE_FILE;
+
+ ImageYUV = LoadYUVImage(file, &ImgWidth, &ImgHeight);
+ if (!ImageYUV) {
+ printf("Couldn't read %s\n", TEXTURE_FILE);
+ exit(0);
+ }
+
+ printf("Image: %dx%d\n", ImgWidth, ImgHeight);
+
+ glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0,
+ GL_YCBCR_MESA, ImgWidth, ImgHeight, 0,
+ GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, ImageYUV);
+
+ assert(glGetError() == GL_NO_ERROR);
+ glTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0,
+ 0, 0, ImgWidth, ImgHeight,
+ GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, ImageYUV);
+
+ assert(glGetError() == GL_NO_ERROR);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ glEnable(GL_TEXTURE_RECTANGLE_NV);
+
+ glShadeModel(GL_FLAT);
+ glClearColor(0.3, 0.3, 0.4, 1.0);
+
+ if (argc > 1 && strcmp(argv[1], "-info")==0) {
+ 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));
+ }
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowSize( 300, 300 );
+ glutInitWindowPosition( 0, 0 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0] );
+
+ Init( argc, argv );
+
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/yuvsquare.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/yuvsquare.c
new file mode 100644
index 000000000..3601e7a31
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/yuvsquare.c
@@ -0,0 +1,232 @@
+/*
+ * Test the GL_NV_texture_rectangle and GL_MESA_ycrcb_texture extensions.
+ *
+ * Brian Paul 13 September 2002
+ */
+
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#include "../util/readtex.c" /* I know, this is a hack. */
+
+#define TEXTURE_FILE "../images/tile.rgb"
+
+static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
+static GLint ImgWidth, ImgHeight;
+static GLushort *ImageYUV = NULL;
+static GLubyte *ImageRGB = NULL;
+static const GLuint yuvObj = 100;
+static const GLuint rgbObj = 101;
+
+
+static void DrawObject(void)
+{
+ glBegin(GL_QUADS);
+
+ glTexCoord2f(0, 0);
+ glVertex2f(-1.0, -1.0);
+
+ glTexCoord2f(1, 0);
+ glVertex2f(1.0, -1.0);
+
+ glTexCoord2f(1, 1);
+ glVertex2f(1.0, 1.0);
+
+ glTexCoord2f(0, 1);
+ glVertex2f(-1.0, 1.0);
+
+ glEnd();
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+ glTranslatef( -1.1, 0.0, -15.0 );
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+ glBindTexture(GL_TEXTURE_2D, yuvObj);
+ DrawObject();
+ glPopMatrix();
+
+ glPushMatrix();
+ glTranslatef( 1.1, 0.0, -15.0 );
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+ glBindTexture(GL_TEXTURE_2D, rgbObj);
+ DrawObject();
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.1, 1.1, -1.1, 1.1, 10.0, 100.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ float step = 3.0;
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot += step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot -= step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
+
+
+
+/* #define LINEAR_FILTER */
+
+static void Init( int argc, char *argv[] )
+{
+ const char *file;
+ GLenum format;
+
+ if (!glutExtensionSupported("GL_MESA_ycbcr_texture")) {
+ printf("Sorry, GL_MESA_ycbcr_texture is required\n");
+ exit(0);
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ if (argc > 1)
+ file = argv[1];
+ else
+ file = TEXTURE_FILE;
+
+ /* First load the texture as YCbCr.
+ */
+
+ glBindTexture(GL_TEXTURE_2D, yuvObj);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ ImageYUV = LoadYUVImage(file, &ImgWidth, &ImgHeight );
+ if (!ImageYUV) {
+ printf("Couldn't read %s\n", TEXTURE_FILE);
+ exit(0);
+ }
+
+ printf("Image: %dx%d\n", ImgWidth, ImgHeight);
+
+
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ GL_YCBCR_MESA,
+ ImgWidth, ImgHeight, 0,
+ GL_YCBCR_MESA,
+ GL_UNSIGNED_SHORT_8_8_MESA, ImageYUV);
+
+ glEnable(GL_TEXTURE_2D);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+
+
+ /* Now load the texture as RGB.
+ */
+
+ glBindTexture(GL_TEXTURE_2D, rgbObj);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ ImageRGB = LoadRGBImage(file, &ImgWidth, &ImgHeight, &format );
+ if (!ImageRGB) {
+ printf("Couldn't read %s\n", TEXTURE_FILE);
+ exit(0);
+ }
+
+ printf("Image: %dx%d\n", ImgWidth, ImgHeight);
+
+
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ format,
+ ImgWidth, ImgHeight, 0,
+ format,
+ GL_UNSIGNED_BYTE, ImageRGB);
+
+ glEnable(GL_TEXTURE_2D);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+
+
+ glShadeModel(GL_FLAT);
+ glClearColor(0.3, 0.3, 0.4, 1.0);
+
+ if (argc > 1 && strcmp(argv[1], "-info")==0) {
+ 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));
+ }
+
+ printf( "Both images should appear the same.\n" );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowSize( 300, 300 );
+ glutInitWindowPosition( 0, 0 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0] );
+
+ Init( argc, argv );
+
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutDisplayFunc( Display );
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa_6.4.2/progs/tests/zreaddraw.c b/nx-X11/extras/Mesa_6.4.2/progs/tests/zreaddraw.c
new file mode 100644
index 000000000..e2dacbf7f
--- /dev/null
+++ b/nx-X11/extras/Mesa_6.4.2/progs/tests/zreaddraw.c
@@ -0,0 +1,116 @@
+/*
+ * Test glRead/DrawPixels for GL_DEPTH_COMPONENT, with pixelzoom.
+ *
+ * Brian Paul
+ * 23 August 2003
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static GLint WinWidth = 500, WinHeight = 500;
+
+
+static void Display(void)
+{
+ GLfloat depth[100 * 100];
+ GLfloat depth2[400 * 400];
+ GLfloat min, max;
+ int i;
+
+ glClearColor(0.5, 0.5, 0.5, 0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ /* draw a sphere */
+ glViewport(0, 0, 100, 100);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1, 1, -1, 1, -1, 0); /* clip away back half of sphere */
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glutSolidSphere(1.0, 20, 10);
+
+ /* read the depth image */
+ glReadPixels(0, 0, 100, 100, GL_DEPTH_COMPONENT, GL_FLOAT, depth);
+ min = max = depth[0];
+ for (i = 1; i < 100 * 100; i++) {
+ if (depth[i] < min)
+ min = depth[i];
+ if (depth[i] > max)
+ max = depth[i];
+ }
+ printf("Depth value range: [%f, %f]\n", min, max);
+
+ /* draw depth image with scaling (into z buffer) */
+ glPixelZoom(4.0, 4.0);
+ glWindowPos2i(100, 0);
+ glDrawPixels(100, 100, GL_DEPTH_COMPONENT, GL_FLOAT, depth);
+
+ /* read back scaled depth image */
+ glReadPixels(100, 0, 400, 400, GL_DEPTH_COMPONENT, GL_FLOAT, depth2);
+ /* draw as luminance */
+ glPixelZoom(1.0, 1.0);
+ glDrawPixels(400, 400, GL_LUMINANCE, GL_FLOAT, depth2);
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape(int width, int height)
+{
+ WinWidth = width;
+ WinHeight = height;
+ glViewport(0, 0, width, height);
+}
+
+
+static void Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init(void)
+{
+ const GLfloat blue[4] = {.1, .1, 1.0, 0.0};
+ const GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0};
+ const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
+ const GLfloat pos[4] = {0, 0, 10, 0};
+
+ printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, blue);
+ glLightfv(GL_LIGHT0, GL_AMBIENT, gray);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
+ glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_DEPTH_TEST);
+}
+
+
+int main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(WinWidth, WinHeight);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Display);
+ Init();
+ glutMainLoop();
+ return 0;
+}