summaryrefslogtreecommitdiffstats
path: root/progs
diff options
context:
space:
mode:
Diffstat (limited to 'progs')
-rw-r--r--progs/beos/.gitignore3
-rw-r--r--progs/beos/demo.cpp1
-rw-r--r--progs/demos/drawpix.c4
-rw-r--r--progs/demos/lodbias.c5
-rw-r--r--progs/demos/streaming_rect.c25
-rw-r--r--progs/directfb/.gitignore4
-rw-r--r--progs/egl/.gitignore5
-rw-r--r--progs/egl/Makefile8
-rw-r--r--progs/egl/demo1.c5
-rw-r--r--progs/egl/demo2.c57
-rw-r--r--progs/egl/demo3.c3
-rw-r--r--progs/egl/eglgears.c7
-rw-r--r--progs/egl/eglinfo.c2
-rw-r--r--progs/fbdev/.gitignore1
-rw-r--r--progs/ggi/gears.c1
-rw-r--r--progs/glsl/.gitignore1
-rw-r--r--progs/glsl/Makefile9
-rw-r--r--progs/glsl/convolution.frag21
-rw-r--r--progs/glsl/convolution.vert5
-rw-r--r--progs/glsl/convolutions.c441
-rw-r--r--progs/miniglx/.gitignore6
-rw-r--r--progs/miniglx/glfbdevtest.c1
-rw-r--r--progs/miniglx/manytex.c1
-rw-r--r--progs/miniglx/sample_server.c1
-rw-r--r--progs/miniglx/sample_server2.c1
-rw-r--r--progs/miniglx/texline.c1
-rw-r--r--progs/osdemos/.gitignore8
-rw-r--r--progs/samples/.gitignore34
-rw-r--r--progs/slang/.gitignore3
-rw-r--r--progs/tests/.gitignore33
-rw-r--r--progs/tests/Makefile.win1
-rw-r--r--progs/tests/antialias.c1
-rw-r--r--progs/tests/cva.c1
-rw-r--r--progs/tests/fbotest2.c1
-rw-r--r--progs/tests/getprocaddress.py1
-rw-r--r--progs/tests/jkrahntest.c1
-rw-r--r--progs/tests/manytex.c1
-rw-r--r--progs/tests/multipal.c1
-rw-r--r--progs/tests/multiwindow.c2
-rw-r--r--progs/tests/sharedtex.c1
-rw-r--r--progs/tests/texline.c1
-rw-r--r--progs/tests/texrect.c1
-rw-r--r--progs/tests/texwrap.c1
-rw-r--r--progs/tools/trace/.gitignore1
-rw-r--r--progs/trivial/.gitignore4
-rw-r--r--progs/util/README1
-rw-r--r--progs/util/glstate.c2
-rw-r--r--progs/util/glstate.h2
-rw-r--r--progs/util/sampleMakefile2
-rw-r--r--progs/vp/.gitignore1
-rw-r--r--progs/windml/ugldrawpix.c1
-rw-r--r--progs/windml/ugltexcyl.c1
-rw-r--r--progs/xdemos/.gitignore1
-rw-r--r--progs/xdemos/glthreads.c306
-rw-r--r--progs/xdemos/vgears.c1
55 files changed, 877 insertions, 157 deletions
diff --git a/progs/beos/.gitignore b/progs/beos/.gitignore
new file mode 100644
index 00000000000..53011ca2e6c
--- /dev/null
+++ b/progs/beos/.gitignore
@@ -0,0 +1,3 @@
+demo
+GLInfo
+sample
diff --git a/progs/beos/demo.cpp b/progs/beos/demo.cpp
index 6b0b9576d66..ae29bb80b2f 100644
--- a/progs/beos/demo.cpp
+++ b/progs/beos/demo.cpp
@@ -1,4 +1,3 @@
-// $Id: demo.cpp,v 1.2 2004/08/14 09:59:16 phoudoin Exp $
// Simple BeOS GLView demo
// Written by Brian Paul
diff --git a/progs/demos/drawpix.c b/progs/demos/drawpix.c
index d2f57486744..5490bcc6355 100644
--- a/progs/demos/drawpix.c
+++ b/progs/demos/drawpix.c
@@ -28,6 +28,7 @@ static GLfloat Zpos = -1.0;
static float Xzoom, Yzoom;
static GLboolean DrawFront = GL_FALSE;
static GLboolean Dither = GL_TRUE;
+static int win = 0;
static void Reset( void )
@@ -215,6 +216,7 @@ static void Key( unsigned char key, int x, int y )
printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK");
break;
case 27:
+ glutDestroyWindow(win);
exit(0);
break;
}
@@ -343,7 +345,7 @@ int main( int argc, char *argv[] )
else
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE);
- glutCreateWindow(argv[0]);
+ win = glutCreateWindow(argv[0]);
Init(ciMode, filename);
Usage();
diff --git a/progs/demos/lodbias.c b/progs/demos/lodbias.c
index c5a2a1b4573..30b1ed13d5f 100644
--- a/progs/demos/lodbias.c
+++ b/progs/demos/lodbias.c
@@ -42,7 +42,7 @@ static GLfloat Xrot = 0, Yrot = -30, Zrot = 0;
static GLboolean Anim = GL_TRUE;
static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */
static GLint BiasMin = -400, BiasMax = 400;
-
+static int win = 0;
static void
@@ -172,6 +172,7 @@ static void Key( unsigned char key, int x, int y )
Bias = 100.0 * (key - '0');
break;
case 27:
+ glutDestroyWindow(win);
exit(0);
break;
}
@@ -281,7 +282,7 @@ int main( int argc, char *argv[] )
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 350, 350 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
- glutCreateWindow(argv[0]);
+ win = glutCreateWindow(argv[0]);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutSpecialFunc( SpecialKey );
diff --git a/progs/demos/streaming_rect.c b/progs/demos/streaming_rect.c
index 86e00803c01..4c1d8535fd7 100644
--- a/progs/demos/streaming_rect.c
+++ b/progs/demos/streaming_rect.c
@@ -1,13 +1,9 @@
-
/*
- * GL_ARB_multitexture demo
+ * GL_ARB_pixel_buffer_object test
*
* Command line options:
- * -info print GL implementation information
- *
+ * -w WIDTH -h HEIGHT sets window size
*
- * Brian Paul November 1998 This program is in the public domain.
- * Modified on 12 Feb 2002 for > 2 texture units.
*/
#define GL_GLEXT_PROTOTYPES
@@ -25,6 +21,8 @@
#define PBO 11
#define QUIT 100
+static GLuint DrawPBO;
+
static GLboolean Animate = GL_TRUE;
static GLboolean use_pbo = 1;
static GLboolean whole_rect = 1;
@@ -49,7 +47,7 @@ static void Idle( void )
}
}
-static int max( int a, int b ) { return a > b ? a : b; }
+/*static int max( int a, int b ) { return a > b ? a : b; }*/
static int min( int a, int b ) { return a < b ? a : b; }
static void DrawObject()
@@ -62,6 +60,7 @@ static void DrawObject()
* release the old copy of the texture and allocate a new one
* without waiting for outstanding rendering to complete.
*/
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, size, NULL, GL_STREAM_DRAW_ARB);
{
@@ -69,7 +68,7 @@ static void DrawObject()
printf("char %d\n", (unsigned char)(Drift * 255));
- memset(image, size, (unsigned char)(Drift * 255));
+ memset(image, (unsigned char)(Drift * 255), size);
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT);
}
@@ -86,7 +85,9 @@ static void DrawObject()
if (image == NULL)
image = malloc(size);
- memset(image, size, (unsigned char)(Drift * 255));
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
+
+ memset(image, (unsigned char)(Drift * 255), size);
/* BGRA should be the fast path for regular uploads as well.
*/
@@ -227,12 +228,12 @@ static void SpecialKey( int key, int x, int y )
static void Init( int argc, char *argv[] )
{
const char *exten = (const char *) glGetString(GL_EXTENSIONS);
- GLuint texObj, DrawPBO;
+ GLuint texObj;
GLint size;
- if (!strstr(exten, "GL_ARB_multitexture")) {
- printf("Sorry, GL_ARB_multitexture not supported by this renderer.\n");
+ if (!strstr(exten, "GL_ARB_pixel_buffer_object")) {
+ printf("Sorry, GL_ARB_pixel_buffer_object not supported by this renderer.\n");
exit(1);
}
diff --git a/progs/directfb/.gitignore b/progs/directfb/.gitignore
new file mode 100644
index 00000000000..55d65fb5b08
--- /dev/null
+++ b/progs/directfb/.gitignore
@@ -0,0 +1,4 @@
+df_gears
+df_morph3d
+df_reflect
+multi_window
diff --git a/progs/egl/.gitignore b/progs/egl/.gitignore
new file mode 100644
index 00000000000..1751108235a
--- /dev/null
+++ b/progs/egl/.gitignore
@@ -0,0 +1,5 @@
+demo1
+demo2
+demo3
+eglgears
+eglinfo
diff --git a/progs/egl/Makefile b/progs/egl/Makefile
index 33447a9d575..da710cbbbfc 100644
--- a/progs/egl/Makefile
+++ b/progs/egl/Makefile
@@ -46,7 +46,7 @@ demo3.o: demo3.c $(HEADERS)
eglinfo: eglinfo.o $(TOP)/$(LIB_DIR)/libEGL.so
- $(CC) $(CFLAGS) eglinfo.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
+ $(CC) $(CFLAGS) eglinfo.o -L$(TOP)/$(LIB_DIR) -lGL -lEGL $(LIBDRM_LIB) -o $@
eglinfo.o: eglinfo.c $(HEADERS)
$(CC) -c $(CFLAGS) -I$(TOP)/include eglinfo.c
@@ -63,3 +63,9 @@ clean:
rm -f *.o *~
rm -f *.so
rm -f $(PROGRAMS)
+
+run:
+ LD_LIBRARY_PATH=$(TOP)/lib ./eglgears
+
+debug:
+ LD_LIBRARY_PATH=$(TOP)/lib gdb ./eglgears
diff --git a/progs/egl/demo1.c b/progs/egl/demo1.c
index 9ef17e38b7d..52673187c4d 100644
--- a/progs/egl/demo1.c
+++ b/progs/egl/demo1.c
@@ -2,7 +2,10 @@
* Exercise EGL API functions
*/
+#define EGL_EGLEXT_PROTOTYPES
+
#include <GLES/egl.h>
+#include <GLES/eglext.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -102,7 +105,7 @@ main(int argc, char *argv[])
/*
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
*/
- EGLDisplay d = eglGetDisplay("!fb_dri");
+ EGLDisplay d = eglGetDisplay((EGLNativeDisplayType) "!EGL_i915");
assert(d);
if (!eglInitialize(d, &maj, &min)) {
diff --git a/progs/egl/demo2.c b/progs/egl/demo2.c
index 17bbca61587..c95aaafa13a 100644
--- a/progs/egl/demo2.c
+++ b/progs/egl/demo2.c
@@ -2,35 +2,54 @@
* Exercise EGL API functions
*/
+#define EGL_EGLEXT_PROTOTYPES
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <GLES/egl.h>
+#include <GLES/eglext.h>
+#include <GLES/gl.h>
/*#define FRONTBUFFER*/
-static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
+ GLfloat r, GLfloat g, GLfloat b)
{
- glBegin( GL_QUADS );
- glVertex2f( x1, y1 );
- glVertex2f( x2, y1 );
- glVertex2f( x2, y2 );
- glVertex2f( x1, y2 );
- glEnd();
+ GLfloat v[4][2], c[4][4];
+ int i;
+
+ v[0][0] = x1; v[0][1] = y1;
+ v[1][0] = x2; v[1][1] = y1;
+ v[2][0] = x2; v[2][1] = y2;
+ v[3][0] = x1; v[3][1] = y2;
+
+ for (i = 0; i < 4; i++) {
+ c[i][0] = r;
+ c[i][1] = g;
+ c[i][2] = b;
+ c[i][3] = 1.0;
+ }
+
+ glVertexPointer(2, GL_FLOAT, 0, v);
+ glColorPointer(4, GL_FLOAT, 0, v);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
}
static void redraw(EGLDisplay dpy, EGLSurface surf, int rot)
{
- printf("Redraw event\n");
+ GLfloat r, g, b;
-#ifdef FRONTBUFFER
- glDrawBuffer( GL_FRONT );
-#else
- glDrawBuffer( GL_BACK );
-#endif
+ printf("Redraw event\n");
glClearColor( rand()/(float)RAND_MAX,
rand()/(float)RAND_MAX,
@@ -39,13 +58,14 @@ static void redraw(EGLDisplay dpy, EGLSurface surf, int rot)
glClear( GL_COLOR_BUFFER_BIT );
- glColor3f( rand()/(float)RAND_MAX,
- rand()/(float)RAND_MAX,
- rand()/(float)RAND_MAX );
+ r = rand()/(float)RAND_MAX;
+ g = rand()/(float)RAND_MAX;
+ b = rand()/(float)RAND_MAX;
+
glPushMatrix();
glRotatef(rot, 0, 0, 1);
glScalef(.5, .5, .5);
- _subset_Rectf( -1, -1, 1, 1 );
+ _subset_Rectf( -1, -1, 1, 1, r, g, b );
glPopMatrix();
#ifdef FRONTBUFFER
@@ -102,7 +122,7 @@ main(int argc, char *argv[])
/*
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
*/
- EGLDisplay d = eglGetDisplay("!fb_dri");
+ EGLDisplay d = eglGetDisplay((EGLNativeDisplayType) "!EGL_i915");
assert(d);
if (!eglInitialize(d, &maj, &min)) {
@@ -161,7 +181,6 @@ main(int argc, char *argv[])
}
glViewport(0, 0, 1024, 768);
- glDrawBuffer( GL_FRONT );
glClearColor( 0,
1.0,
diff --git a/progs/egl/demo3.c b/progs/egl/demo3.c
index 9edf7c952b3..6ea75787931 100644
--- a/progs/egl/demo3.c
+++ b/progs/egl/demo3.c
@@ -3,6 +3,7 @@
*/
#include <GLES/egl.h>
+#include <GL/gl.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -576,7 +577,7 @@ main(int argc, char *argv[])
/*
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
*/
- EGLDisplay d = eglGetDisplay(":0");
+ EGLDisplay d = eglGetDisplay("!EGL_i915");
assert(d);
if (!eglInitialize(d, &maj, &min)) {
diff --git a/progs/egl/eglgears.c b/progs/egl/eglgears.c
index 9feee20d889..a004cb7e869 100644
--- a/progs/egl/eglgears.c
+++ b/progs/egl/eglgears.c
@@ -27,13 +27,16 @@
* Program runs for 5 seconds then exits, outputing framerate to console
*/
+#define EGL_EGLEXT_PROTOTYPES
+
+#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/gl.h>
#include <GLES/egl.h>
-#include <assert.h>
+#include <GLES/eglext.h>
#define MAX_CONFIGS 10
#define MAX_MODES 100
@@ -385,7 +388,7 @@ main(int argc, char *argv[])
}
/* DBR : Create EGL context/surface etc */
- d = eglGetDisplay(":0");
+ d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
assert(d);
if (!eglInitialize(d, &maj, &min)) {
diff --git a/progs/egl/eglinfo.c b/progs/egl/eglinfo.c
index f9c24754457..85de2173fc0 100644
--- a/progs/egl/eglinfo.c
+++ b/progs/egl/eglinfo.c
@@ -140,7 +140,7 @@ main(int argc, char *argv[])
{
int maj, min;
/*EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);*/
- EGLDisplay d = eglGetDisplay(":0");
+ EGLDisplay d = eglGetDisplay("!EGL_i915");
if (!eglInitialize(d, &maj, &min)) {
printf("eglinfo: eglInitialize failed\n");
diff --git a/progs/fbdev/.gitignore b/progs/fbdev/.gitignore
new file mode 100644
index 00000000000..b9ddf559fd5
--- /dev/null
+++ b/progs/fbdev/.gitignore
@@ -0,0 +1 @@
+glfbdevtest
diff --git a/progs/ggi/gears.c b/progs/ggi/gears.c
index ac2e9f2a6ea..2b3231d8ae6 100644
--- a/progs/ggi/gears.c
+++ b/progs/ggi/gears.c
@@ -1,4 +1,3 @@
-/* $Id: gears.c,v 1.3 1999/08/22 08:56:50 jtaylor Exp $ */
/*
* 3-D gear wheels. This program is in the public domain.
diff --git a/progs/glsl/.gitignore b/progs/glsl/.gitignore
index 622e0417a85..81ecf5bdd5e 100644
--- a/progs/glsl/.gitignore
+++ b/progs/glsl/.gitignore
@@ -1,5 +1,6 @@
brick
bump
+convolutions
deriv
extfuncs.h
mandelbrot
diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
index 37fa312c30c..b9cae668152 100644
--- a/progs/glsl/Makefile
+++ b/progs/glsl/Makefile
@@ -14,7 +14,8 @@ PROGS = \
mandelbrot \
noise \
toyball \
- texdemo1
+ texdemo1 \
+ convolutions
##### RULES #####
@@ -62,6 +63,12 @@ texdemo1: texdemo1.o readtex.o
texdemo1.o: texdemo1.c readtex.h extfuncs.h
$(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c
+convolutions: convolutions.o readtex.o
+ $(CC) -I$(INCDIR) $(CFLAGS) convolutions.o readtex.o $(APP_LIB_DEPS) -o $@
+
+convolutions.o: convolutions.c readtex.h
+ $(CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c
+
clean:
-rm -f $(PROGS)
diff --git a/progs/glsl/convolution.frag b/progs/glsl/convolution.frag
new file mode 100644
index 00000000000..e49b8acf545
--- /dev/null
+++ b/progs/glsl/convolution.frag
@@ -0,0 +1,21 @@
+
+const int KernelSize = 9;
+
+//texture offsets
+uniform vec2 Offset[KernelSize];
+//convolution kernel
+uniform vec4 KernelValue[KernelSize];
+uniform sampler2D srcTex;
+uniform vec4 ScaleFactor;
+uniform vec4 BaseColor;
+
+void main(void)
+{
+ int i;
+ vec4 sum = vec4(0.0);
+ for (i = 0; i < KernelSize; ++i) {
+ vec4 tmp = texture2D(srcTex, gl_TexCoord[0].st + Offset[i]);
+ sum += tmp * KernelValue[i];
+ }
+ gl_FragColor = sum * ScaleFactor + BaseColor;
+}
diff --git a/progs/glsl/convolution.vert b/progs/glsl/convolution.vert
new file mode 100644
index 00000000000..752c54671c3
--- /dev/null
+++ b/progs/glsl/convolution.vert
@@ -0,0 +1,5 @@
+void main() {
+ gl_FrontColor = gl_Color;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+}
diff --git a/progs/glsl/convolutions.c b/progs/glsl/convolutions.c
new file mode 100644
index 00000000000..be887714c4f
--- /dev/null
+++ b/progs/glsl/convolutions.c
@@ -0,0 +1,441 @@
+#define GL_GLEXT_PROTOTYPES
+#include "readtex.h"
+
+#include <GL/glut.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <math.h>
+
+enum Filter {
+ GAUSSIAN_BLUR,
+ SHARPEN,
+ MEAN_REMOVAL,
+ EMBOSS,
+ NO_FILTER,
+ LAST
+};
+#define QUIT LAST
+
+struct BoundingBox {
+ float minx, miny, minz;
+ float maxx, maxy, maxz;
+};
+struct Texture {
+ GLuint id;
+ GLfloat x;
+ GLfloat y;
+ GLint width;
+ GLint height;
+ GLenum format;
+};
+
+static const char *textureLocation = "../images/girl2.rgb";
+
+static GLfloat viewRotx = 0.0, viewRoty = 0.0, viewRotz = 0.0;
+static struct BoundingBox box;
+static struct Texture texture;
+static GLuint program;
+static GLint menuId;
+static enum Filter filter = GAUSSIAN_BLUR;
+
+
+static void checkError(int line)
+{
+ GLenum err = glGetError();
+ if (err) {
+ printf("GL Error %s (0x%x) at line %d\n",
+ gluErrorString(err), (int) err, line);
+ }
+}
+
+static void loadAndCompileShader(GLuint shader, const char *text)
+{
+ GLint stat;
+
+ glShaderSource(shader, 1, (const GLchar **) &text, NULL);
+
+ glCompileShader(shader);
+
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
+ if (!stat) {
+ GLchar log[1000];
+ GLsizei len;
+ glGetShaderInfoLog(shader, 1000, &len, log);
+ fprintf(stderr, "Problem compiling shader: %s\n", log);
+ exit(1);
+ }
+ else {
+ printf("Shader compiled OK\n");
+ }
+}
+
+static void readShader(GLuint shader, const char *filename)
+{
+ const int max = 100*1000;
+ int n;
+ char *buffer = (char*) malloc(max);
+ FILE *f = fopen(filename, "r");
+ if (!f) {
+ fprintf(stderr, "Unable to open shader file %s\n", filename);
+ exit(1);
+ }
+
+ n = fread(buffer, 1, max, f);
+ printf("Read %d bytes from shader file %s\n", n, filename);
+ if (n > 0) {
+ buffer[n] = 0;
+ loadAndCompileShader(shader, buffer);
+ }
+
+ fclose(f);
+ free(buffer);
+}
+
+
+static void
+checkLink(GLuint prog)
+{
+ GLint stat;
+ glGetProgramiv(prog, GL_LINK_STATUS, &stat);
+ if (!stat) {
+ GLchar log[1000];
+ GLsizei len;
+ glGetProgramInfoLog(prog, 1000, &len, log);
+ fprintf(stderr, "Linker error:\n%s\n", log);
+ }
+ else {
+ fprintf(stderr, "Link success!\n");
+ }
+}
+
+static void fillConvolution(GLint *k,
+ GLfloat *scale,
+ GLfloat *color)
+{
+ switch(filter) {
+ case GAUSSIAN_BLUR:
+ k[0] = 1; k[1] = 2; k[2] = 1;
+ k[3] = 2; k[4] = 4; k[5] = 2;
+ k[6] = 1; k[7] = 2; k[8] = 1;
+
+ *scale = 1./16.;
+ break;
+ case SHARPEN:
+ k[0] = 0; k[1] = -2; k[2] = 0;
+ k[3] = -2; k[4] = 11; k[5] = -2;
+ k[6] = 0; k[7] = -2; k[8] = 0;
+
+ *scale = 1./3.;
+ break;
+ case MEAN_REMOVAL:
+ k[0] = -1; k[1] = -1; k[2] = -1;
+ k[3] = -1; k[4] = 9; k[5] = -1;
+ k[6] = -1; k[7] = -1; k[8] = -1;
+
+ *scale = 1./1.;
+ break;
+ case EMBOSS:
+ k[0] = -1; k[1] = 0; k[2] = -1;
+ k[3] = 0; k[4] = 4; k[5] = 0;
+ k[6] = -1; k[7] = 0; k[8] = -1;
+
+ *scale = 1./1.;
+ color[0] = 0.5;
+ color[1] = 0.5;
+ color[2] = 0.5;
+ color[3] = 0.5;
+ break;
+ case NO_FILTER:
+ k[0] = 0; k[1] = 0; k[2] = 0;
+ k[3] = 0; k[4] = 1; k[5] = 0;
+ k[6] = 0; k[7] = 0; k[8] = 0;
+
+ *scale = 1.;
+ break;
+ default:
+ assert(!"Unhandled switch value");
+ }
+}
+
+static void setupConvolution()
+{
+ GLint *kernel = (GLint*)malloc(sizeof(GLint) * 9);
+ GLfloat scale;
+ GLfloat *vecKer = (GLfloat*)malloc(sizeof(GLfloat) * 9 * 4);
+ GLuint loc;
+ GLuint i;
+ GLfloat baseColor[4];
+ baseColor[0] = 0;
+ baseColor[1] = 0;
+ baseColor[2] = 0;
+ baseColor[3] = 0;
+
+ fillConvolution(kernel, &scale, baseColor);
+ /*vector of 4*/
+ for (i = 0; i < 9; ++i) {
+ vecKer[i*4 + 0] = kernel[i];
+ vecKer[i*4 + 1] = kernel[i];
+ vecKer[i*4 + 2] = kernel[i];
+ vecKer[i*4 + 3] = kernel[i];
+ }
+
+ loc = glGetUniformLocationARB(program, "KernelValue");
+ glUniform4fv(loc, 9, vecKer);
+ loc = glGetUniformLocationARB(program, "ScaleFactor");
+ glUniform4f(loc, scale, scale, scale, scale);
+ loc = glGetUniformLocationARB(program, "BaseColor");
+ glUniform4f(loc, baseColor[0], baseColor[1],
+ baseColor[2], baseColor[3]);
+
+ free(vecKer);
+ free(kernel);
+}
+
+static void createProgram(const char *vertProgFile,
+ const char *fragProgFile)
+{
+ GLuint fragShader = 0, vertShader = 0;
+
+ program = glCreateProgram();
+ if (vertProgFile) {
+ vertShader = glCreateShader(GL_VERTEX_SHADER);
+ readShader(vertShader, vertProgFile);
+ glAttachShader(program, vertShader);
+ }
+
+ if (fragProgFile) {
+ fragShader = glCreateShader(GL_FRAGMENT_SHADER);
+ readShader(fragShader, fragProgFile);
+ glAttachShader(program, fragShader);
+ }
+
+ glLinkProgram(program);
+ checkLink(program);
+
+ glUseProgram(program);
+
+ assert(glIsProgram(program));
+ assert(glIsShader(fragShader));
+ assert(glIsShader(vertShader));
+
+ checkError(__LINE__);
+ {/*texture*/
+ GLuint texLoc = glGetUniformLocationARB(program, "srcTex");
+ glUniform1iARB(texLoc, 0);
+ }
+ {/*setup offsets */
+ float offsets[] = { 1.0 / texture.width, 1.0 / texture.height,
+ 0.0 , 1.0 / texture.height,
+ -1.0 / texture.width, 1.0 / texture.height,
+ 1.0 / texture.width, 0.0,
+ 0.0 , 0.0,
+ -1.0 / texture.width, 0.0,
+ 1.0 / texture.width, -1.0 / texture.height,
+ 0.0 , -1.0 / texture.height,
+ -1.0 / texture.width, -1.0 / texture.height };
+ GLuint offsetLoc = glGetUniformLocationARB(program, "Offset");
+ glUniform2fv(offsetLoc, 9, offsets);
+ }
+ setupConvolution();
+
+ checkError(__LINE__);
+}
+
+
+static void readTexture(const char *filename)
+{
+ GLubyte *data;
+
+ texture.x = 0;
+ texture.y = 0;
+
+ glGenTextures(1, &texture.id);
+ glBindTexture(GL_TEXTURE_2D, texture.id);
+ 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);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ data = LoadRGBImage(filename, &texture.width, &texture.height,
+ &texture.format);
+ if (!data) {
+ printf("Error: couldn't load texture image '%s'\n", filename);
+ exit(1);
+ }
+ printf("Texture %s (%d x %d)\n",
+ filename, texture.width, texture.height);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+ texture.width, texture.height, 0, texture.format,
+ GL_UNSIGNED_BYTE, data);
+}
+
+static void menuSelected(int entry)
+{
+ switch (entry) {
+ case QUIT:
+ exit(0);
+ break;
+ default:
+ filter = (enum Filter)entry;
+ }
+ setupConvolution();
+
+ glutPostRedisplay();
+}
+
+static void menuInit()
+{
+ menuId = glutCreateMenu(menuSelected);
+
+ glutAddMenuEntry("Gaussian blur", GAUSSIAN_BLUR);
+ glutAddMenuEntry("Sharpen", SHARPEN);
+ glutAddMenuEntry("Mean removal", MEAN_REMOVAL);
+ glutAddMenuEntry("Emboss", EMBOSS);
+ glutAddMenuEntry("None", NO_FILTER);
+
+ glutAddMenuEntry("Quit", QUIT);
+
+ glutAttachMenu(GLUT_RIGHT_BUTTON);
+}
+
+static void init()
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ menuInit();
+ readTexture(textureLocation);
+ createProgram("convolution.vert", "convolution.frag");
+
+ glEnable(GL_TEXTURE_2D);
+ glClearColor(1.0, 1.0, 1.0, 1.0);
+ /*glShadeModel(GL_SMOOTH);*/
+ glShadeModel(GL_FLAT);
+}
+
+static void reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ box.minx = 0;
+ box.maxx = width;
+ box.miny = 0;
+ box.maxy = height;
+ box.minz = 0;
+ box.maxz = 1;
+ glOrtho(box.minx, box.maxx, box.miny, box.maxy, -999999, 999999);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void keyPress(unsigned char key, int x, int y)
+{
+ switch(key) {
+ case 27:
+ exit(0);
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
+static void
+special(int k, int x, int y)
+{
+ switch (k) {
+ case GLUT_KEY_UP:
+ viewRotx += 2.0;
+ break;
+ case GLUT_KEY_DOWN:
+ viewRotx -= 2.0;
+ break;
+ case GLUT_KEY_LEFT:
+ viewRoty += 2.0;
+ break;
+ case GLUT_KEY_RIGHT:
+ viewRoty -= 2.0;
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
+
+static void draw()
+{
+ GLfloat center[2];
+ GLfloat anchor[2];
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glLoadIdentity();
+ glPushMatrix();
+
+ center[0] = box.maxx/2;
+ center[1] = box.maxy/2;
+ anchor[0] = center[0] - texture.width/2;
+ anchor[1] = center[1] - texture.height/2;
+
+ glTranslatef(center[0], center[1], 0);
+ glRotatef(viewRotx, 1.0, 0.0, 0.0);
+ glRotatef(viewRoty, 0.0, 1.0, 0.0);
+ glRotatef(viewRotz, 0.0, 0.0, 1.0);
+ glTranslatef(-center[0], -center[1], 0);
+
+ glTranslatef(anchor[0], anchor[1], 0);
+ glBegin(GL_TRIANGLE_STRIP);
+ {
+ glColor3f(1., 0., 0.);
+ glTexCoord2f(0, 0);
+ glVertex3f(0, 0, 0);
+
+ glColor3f(0., 1., 0.);
+ glTexCoord2f(0, 1.0);
+ glVertex3f(0, texture.height, 0);
+
+ glColor3f(1., 0., 0.);
+ glTexCoord2f(1.0, 0);
+ glVertex3f(texture.width, 0, 0);
+
+ glColor3f(0., 1., 0.);
+ glTexCoord2f(1, 1);
+ glVertex3f(texture.width, texture.height, 0);
+ }
+ glEnd();
+
+ glPopMatrix();
+
+ glFlush();
+
+ glutSwapBuffers();
+}
+
+int main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(400, 400);
+ glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE);
+
+ if (!glutCreateWindow("Image Convolutions")) {
+ fprintf(stderr, "Couldn't create window!\n");
+ exit(1);
+ }
+
+ init();
+
+ glutReshapeFunc(reshape);
+ glutKeyboardFunc(keyPress);
+ glutSpecialFunc(special);
+ glutDisplayFunc(draw);
+
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/miniglx/.gitignore b/progs/miniglx/.gitignore
new file mode 100644
index 00000000000..f630f591f62
--- /dev/null
+++ b/progs/miniglx/.gitignore
@@ -0,0 +1,6 @@
+manytex
+miniglxsample
+miniglxtest
+sample_server
+sample_server2
+texline
diff --git a/progs/miniglx/glfbdevtest.c b/progs/miniglx/glfbdevtest.c
index c82ca6e5f63..d4efb96930b 100644
--- a/progs/miniglx/glfbdevtest.c
+++ b/progs/miniglx/glfbdevtest.c
@@ -1,4 +1,3 @@
-/* $Id: glfbdevtest.c,v 1.1 2003/08/06 17:47:15 keithw Exp $ */
/*
* Test the GLFBDev interface. Only tested with radeonfb driver!!!!
diff --git a/progs/miniglx/manytex.c b/progs/miniglx/manytex.c
index 36fa10d222b..74b06649f6e 100644
--- a/progs/miniglx/manytex.c
+++ b/progs/miniglx/manytex.c
@@ -1,4 +1,3 @@
-/* $Id: manytex.c,v 1.2 2003/08/23 01:28:59 jonsmirl Exp $ */
/*
* test handling of many texture maps
diff --git a/progs/miniglx/sample_server.c b/progs/miniglx/sample_server.c
index 039c04fa40a..62456eca259 100644
--- a/progs/miniglx/sample_server.c
+++ b/progs/miniglx/sample_server.c
@@ -1,4 +1,3 @@
-/* $Id: sample_server.c,v 1.1 2003/08/06 17:47:15 keithw Exp $ */
/*
* Sample server that just keeps first available window mapped.
diff --git a/progs/miniglx/sample_server2.c b/progs/miniglx/sample_server2.c
index 58effcf484d..efd382a6d93 100644
--- a/progs/miniglx/sample_server2.c
+++ b/progs/miniglx/sample_server2.c
@@ -1,4 +1,3 @@
-/* $Id: sample_server2.c,v 1.2 2003/08/23 01:28:59 jonsmirl Exp $ */
/*
* Sample server that just keeps first available window mapped.
diff --git a/progs/miniglx/texline.c b/progs/miniglx/texline.c
index d2a97d2876e..098077f2474 100644
--- a/progs/miniglx/texline.c
+++ b/progs/miniglx/texline.c
@@ -1,4 +1,3 @@
-/* $Id: texline.c,v 1.1 2003/08/06 17:47:15 keithw Exp $ */
/*
* Test textured lines.
diff --git a/progs/osdemos/.gitignore b/progs/osdemos/.gitignore
new file mode 100644
index 00000000000..5c78f124813
--- /dev/null
+++ b/progs/osdemos/.gitignore
@@ -0,0 +1,8 @@
+osdemo
+osdemo16
+osdemo32
+ostest1
+readtex.c
+readtex.h
+showbuffer.c
+showbuffer.h
diff --git a/progs/samples/.gitignore b/progs/samples/.gitignore
index 9635c7f4507..f60d6e94eac 100644
--- a/progs/samples/.gitignore
+++ b/progs/samples/.gitignore
@@ -1,24 +1,41 @@
.cvsignore
accum
+anywin
+bdemo
+binfo
bitmap1
bitmap2
blendeq
blendxor
+bugger
copy
cursor
+demo
depth
eval
+ffset
fog
font
+font
+incopy
line
logo
+lthreads
+lxdemo
+lxgears
+lxheads
+lxinfo
+lxpixmap
nurb
oglinfo
olympic
overlay
+pend
point
prim
quad
+readtex.c
+readtex.h
select
shape
sphere
@@ -28,20 +45,3 @@ stretch
texture
tri
wave
-bugger
-pend
-lthreads
-lxdemo
-lxgears
-lxheads
-lxinfo
-lxpixmap
-anywin
-ffset
-bdemo
-binfo
-incopy
-demo
-font
-readtex.c
-readtex.h
diff --git a/progs/slang/.gitignore b/progs/slang/.gitignore
new file mode 100644
index 00000000000..8a42b018e65
--- /dev/null
+++ b/progs/slang/.gitignore
@@ -0,0 +1,3 @@
+cltest
+sotest
+vstest
diff --git a/progs/tests/.gitignore b/progs/tests/.gitignore
index 2c0e16c35ec..a72f552f10b 100644
--- a/progs/tests/.gitignore
+++ b/progs/tests/.gitignore
@@ -1,48 +1,75 @@
.cvsignore
-getproclist.h
+afsmultiarb
antialias
arbfpspec
arbfptest1
arbfptexture
arbfptrig
+arbnpot
+arbnpot-mipmap
arbvptest1
arbvptest3
arbvptorus
arbvpwarpmesh
+arraytexture
blendminmax
blendsquare
bufferobj
+bug_3050
bug_3101
bug_3195
+calibrate_rast
+copypixrate
crossbar
cva
dinoshade
+drawbuffers
+extfuncs.h
fbotest1
+fbotest2
fbotexture
+fillrate
floattex
fog
fogcoord
fptest1
fptexture
getprocaddress
+getproclist.h
+interleave
invert
+jkrahntest
manytex
+minmag
+mipmap_limits
+mipmap_view
multipal
no_s3tc
packedpixels
pbo
+prog_parameter
projtex
+random
+readrate
+readtex.c
+readtex.h
seccolor
sharedtex
-stencil_wrap
stencilwrap
+stencil_wrap
+subtex
+subtexrate
tex1d
texcmp
+texcompress2
+texfilt
texgenmix
texline
texobjshare
texrect
texwrap
+vao-01
+vao-02
vparray
vptest1
vptest2
@@ -51,4 +78,6 @@ vptorus
vpwarpmesh
yuvrect
yuvsquare
+zcomp
+zdrawpix
zreaddraw
diff --git a/progs/tests/Makefile.win b/progs/tests/Makefile.win
index 0de6c42e398..d42e3cb6549 100644
--- a/progs/tests/Makefile.win
+++ b/progs/tests/Makefile.win
@@ -1,4 +1,3 @@
-# $Id: Makefile.win,v 1.1 2002/01/16 01:03:25 kschultz Exp $
# Mesa 3-D graphics library
# Version: 3.5
diff --git a/progs/tests/antialias.c b/progs/tests/antialias.c
index 79b5ab75c57..3a83c34b8d0 100644
--- a/progs/tests/antialias.c
+++ b/progs/tests/antialias.c
@@ -1,4 +1,3 @@
-/* $Id: antialias.c,v 1.2 2003/03/29 16:42:57 brianp Exp $ */
/*
* Test multisampling and polygon smoothing.
diff --git a/progs/tests/cva.c b/progs/tests/cva.c
index c7677990bff..a47b2a9319a 100644
--- a/progs/tests/cva.c
+++ b/progs/tests/cva.c
@@ -1,4 +1,3 @@
-/* $Id: cva.c,v 1.8 2006/11/22 19:37:21 sroland Exp $ */
/*
* Trivial CVA test, good for testing driver fastpaths (especially
diff --git a/progs/tests/fbotest2.c b/progs/tests/fbotest2.c
index 18f28972b6e..5283c7e1fd6 100644
--- a/progs/tests/fbotest2.c
+++ b/progs/tests/fbotest2.c
@@ -68,6 +68,7 @@ Display( void )
/* draw to window */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glDisable(GL_DEPTH_TEST); /* in case window has depth buffer */
glWindowPos2iARB(0, 0);
glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
diff --git a/progs/tests/getprocaddress.py b/progs/tests/getprocaddress.py
index d16b2d93d0e..8adfc51bd60 100644
--- a/progs/tests/getprocaddress.py
+++ b/progs/tests/getprocaddress.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
-# $Id: getprocaddress.py,v 1.7 2005/06/21 23:42:43 idr Exp $
# Helper for the getprocaddress.c test.
diff --git a/progs/tests/jkrahntest.c b/progs/tests/jkrahntest.c
index 85bda8d0152..08660b8932e 100644
--- a/progs/tests/jkrahntest.c
+++ b/progs/tests/jkrahntest.c
@@ -1,4 +1,3 @@
-/* $Id: jkrahntest.c,v 1.2 2006/01/30 17:12:10 brianp Exp $ */
/* This is a good test for glXSwapBuffers on non-current windows,
* and the glXCopyContext function. Fixed several Mesa/DRI bugs with
diff --git a/progs/tests/manytex.c b/progs/tests/manytex.c
index 900e5834fe8..83c86766571 100644
--- a/progs/tests/manytex.c
+++ b/progs/tests/manytex.c
@@ -1,4 +1,3 @@
-/* $Id: manytex.c,v 1.5 2005/09/15 01:58:39 brianp Exp $ */
/*
* test handling of many texture maps
diff --git a/progs/tests/multipal.c b/progs/tests/multipal.c
index c824b38703a..52818fca7ee 100644
--- a/progs/tests/multipal.c
+++ b/progs/tests/multipal.c
@@ -1,4 +1,3 @@
-/* $Id: multipal.c,v 1.6 2003/12/08 09:03:36 joukj Exp $ */
/*
* Test multitexture and paletted textures.
diff --git a/progs/tests/multiwindow.c b/progs/tests/multiwindow.c
index e004b0336ca..b069bea91cc 100644
--- a/progs/tests/multiwindow.c
+++ b/progs/tests/multiwindow.c
@@ -1,4 +1,3 @@
-/* $Id: multiwindow.c,v 1.1 2001/08/21 14:25:31 brianp Exp $ */
/*
* A skeleton/template GLUT program
@@ -8,7 +7,6 @@
/*
- * $Log: multiwindow.c,v $
* Revision 1.1 2001/08/21 14:25:31 brianp
* simple multi-window GLUT test prog
*
diff --git a/progs/tests/sharedtex.c b/progs/tests/sharedtex.c
index 7be90d67f55..c07ebd719c7 100644
--- a/progs/tests/sharedtex.c
+++ b/progs/tests/sharedtex.c
@@ -1,4 +1,3 @@
-/* $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.
diff --git a/progs/tests/texline.c b/progs/tests/texline.c
index 3d59d9ac264..ee16ed40df2 100644
--- a/progs/tests/texline.c
+++ b/progs/tests/texline.c
@@ -1,4 +1,3 @@
-/* $Id: texline.c,v 1.5 2004/01/28 10:07:48 keithw Exp $ */
/*
* Test textured lines.
diff --git a/progs/tests/texrect.c b/progs/tests/texrect.c
index 61c1fdd6b4f..43edc491801 100644
--- a/progs/tests/texrect.c
+++ b/progs/tests/texrect.c
@@ -1,4 +1,3 @@
-/* $Id: texrect.c,v 1.5 2004/05/06 20:27:32 brianp Exp $ */
/* GL_NV_texture_rectangle test
*
diff --git a/progs/tests/texwrap.c b/progs/tests/texwrap.c
index 6e9fbe0c70f..8143256f8ae 100644
--- a/progs/tests/texwrap.c
+++ b/progs/tests/texwrap.c
@@ -1,4 +1,3 @@
-/* $Id: texwrap.c,v 1.8 2005/08/25 03:09:12 brianp Exp $ */
/*
* Test texture wrap modes.
diff --git a/progs/tools/trace/.gitignore b/progs/tools/trace/.gitignore
new file mode 100644
index 00000000000..afe0c5829e4
--- /dev/null
+++ b/progs/tools/trace/.gitignore
@@ -0,0 +1 @@
+gltrace.cc
diff --git a/progs/trivial/.gitignore b/progs/trivial/.gitignore
index aafc4a72919..30f03e91032 100644
--- a/progs/trivial/.gitignore
+++ b/progs/trivial/.gitignore
@@ -14,6 +14,7 @@ fs-tri
line
line-clip
line-cull
+line-smooth
line-stipple-wide
line-userclip
line-userclip-clip
@@ -33,6 +34,7 @@ point-clip
point-param
point-sprite
point-wide
+point-wide-smooth
poly
poly-flat
poly-unfilled
@@ -77,6 +79,7 @@ tri-flat
tri-flat-clip
tri-fog
tri-mask-tri
+tri-orig
tri-query
tri-scissor-tri
tri-stencil
@@ -84,6 +87,7 @@ tri-tex-3d
tri-tri
tri-unfilled
tri-unfilled-clip
+tri-unfilled-edgeflag
tri-unfilled-smooth
tri-unfilled-userclip
tri-unfilled-userclip-stip
diff --git a/progs/util/README b/progs/util/README
index ca89d34bd3e..ea71ebd2b96 100644
--- a/progs/util/README
+++ b/progs/util/README
@@ -19,4 +19,3 @@ imagesgi.cpp,.h - read SGI image files
more to come...
----------------------------------------------------------------------
-$Id: README,v 1.1 1999/08/19 00:55:42 jtg Exp $
diff --git a/progs/util/glstate.c b/progs/util/glstate.c
index 4c5db13ec7c..21d7e4552d2 100644
--- a/progs/util/glstate.c
+++ b/progs/util/glstate.c
@@ -1,4 +1,3 @@
-/* $Id: glstate.c,v 1.1 1999/08/19 00:55:42 jtg Exp $ */
/*
* Print GL state information (for debugging)
@@ -21,7 +20,6 @@
/*
- * $Log: glstate.c,v $
* Revision 1.1 1999/08/19 00:55:42 jtg
* Initial revision
*
diff --git a/progs/util/glstate.h b/progs/util/glstate.h
index 1aa4d21d8e8..9216382b7be 100644
--- a/progs/util/glstate.h
+++ b/progs/util/glstate.h
@@ -1,4 +1,3 @@
-/* $Id: glstate.h,v 1.1 1999/08/19 00:55:42 jtg Exp $ */
/*
* Print GL state information (for debugging)
@@ -21,7 +20,6 @@
/*
- * $Log: glstate.h,v $
* Revision 1.1 1999/08/19 00:55:42 jtg
* Initial revision
*
diff --git a/progs/util/sampleMakefile b/progs/util/sampleMakefile
index ebb57ff3dd6..71ec150b889 100644
--- a/progs/util/sampleMakefile
+++ b/progs/util/sampleMakefile
@@ -1,11 +1,9 @@
-# $Id: sampleMakefile,v 1.1 1999/08/19 00:55:42 jtg Exp $
# Sample makefile for compiling OpenGL/Mesa applications on Unix.
# This example assumes Linux with gcc.
# This makefile is in the public domain
-# $Log: sampleMakefile,v $
# Revision 1.1 1999/08/19 00:55:42 jtg
# Initial revision
#
diff --git a/progs/vp/.gitignore b/progs/vp/.gitignore
new file mode 100644
index 00000000000..a5ff9935254
--- /dev/null
+++ b/progs/vp/.gitignore
@@ -0,0 +1 @@
+vp-tris
diff --git a/progs/windml/ugldrawpix.c b/progs/windml/ugldrawpix.c
index b33be2c6aee..154fe55970e 100644
--- a/progs/windml/ugldrawpix.c
+++ b/progs/windml/ugldrawpix.c
@@ -7,7 +7,6 @@
*/
/*
- * $Log: ugldrawpix.c,v $
* Revision 1.2 2001/09/10 19:21:13 brianp
* WindML updates (Stephane Raimbault)
*
diff --git a/progs/windml/ugltexcyl.c b/progs/windml/ugltexcyl.c
index d2fe687b926..db66d1ff67b 100644
--- a/progs/windml/ugltexcyl.c
+++ b/progs/windml/ugltexcyl.c
@@ -7,7 +7,6 @@
*/
/*
- * $Log: ugltexcyl.c,v $
* Revision 1.2 2001/09/10 19:21:13 brianp
* WindML updates (Stephane Raimbault)
*
diff --git a/progs/xdemos/.gitignore b/progs/xdemos/.gitignore
index 250bc17d984..34551101cb9 100644
--- a/progs/xdemos/.gitignore
+++ b/progs/xdemos/.gitignore
@@ -13,6 +13,7 @@ offset
overlay
pbdemo
pbinfo
+sharedtex
texture_from_pixmap
wincopy
xdemo
diff --git a/progs/xdemos/glthreads.c b/progs/xdemos/glthreads.c
index 989697fbcaa..b90e6b4f319 100644
--- a/progs/xdemos/glthreads.c
+++ b/progs/xdemos/glthreads.c
@@ -24,18 +24,33 @@
* This program tests GLX thread safety.
* Command line options:
* -p Open a display connection for each thread
+ * -l Enable application-side locking
* -n <num threads> Number of threads to create (default is 2)
* -display <display name> Specify X display (default is :0.0)
+ * -t Use texture mapping
*
* Brian Paul 20 July 2000
*/
+/*
+ * Notes:
+ * - Each thread gets its own GLX context.
+ *
+ * - The GLX contexts share texture objects.
+ *
+ * - When 't' is pressed to update the texture image, the window/thread which
+ * has input focus is signalled to change the texture. The other threads
+ * should see the updated texture the next time they call glBindTexture.
+ */
+
+
#if defined(PTHREADS) /* defined by Mesa on Linux and other platforms */
#include <assert.h>
#include <GL/gl.h>
#include <GL/glx.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -55,6 +70,8 @@ struct winthread {
float Angle;
int WinWidth, WinHeight;
GLboolean NewSize;
+ GLboolean Initialized;
+ GLboolean MakeNewTexture;
};
@@ -65,8 +82,13 @@ static volatile GLboolean ExitFlag = GL_FALSE;
static GLboolean MultiDisplays = 0;
static GLboolean Locking = 0;
+static GLboolean Texture = GL_FALSE;
+static GLuint TexObj = 12;
+static GLboolean Animate = GL_TRUE;
static pthread_mutex_t Mutex;
+static pthread_cond_t CondVar;
+static pthread_mutex_t CondMutex;
static void
@@ -77,6 +99,59 @@ Error(const char *msg)
}
+static void
+signal_redraw(void)
+{
+ pthread_mutex_lock(&CondMutex);
+ pthread_cond_broadcast(&CondVar);
+ pthread_mutex_unlock(&CondMutex);
+}
+
+
+static void
+MakeNewTexture(struct winthread *wt)
+{
+#define TEX_SIZE 128
+ static float step = 0.0;
+ GLfloat image[TEX_SIZE][TEX_SIZE][4];
+ GLint width;
+ int i, j;
+
+ for (j = 0; j < TEX_SIZE; j++) {
+ for (i = 0; i < TEX_SIZE; i++) {
+ float dt = 5.0 * (j - 0.5 * TEX_SIZE) / TEX_SIZE;
+ float ds = 5.0 * (i - 0.5 * TEX_SIZE) / TEX_SIZE;
+ float r = dt * dt + ds * ds + step;
+ image[j][i][0] =
+ image[j][i][1] =
+ image[j][i][2] = 0.75 + 0.25 * cos(r);
+ image[j][i][3] = 1.0;
+ }
+ }
+
+ step += 0.5;
+
+ glBindTexture(GL_TEXTURE_2D, TexObj);
+
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
+ if (width) {
+ assert(width == TEX_SIZE);
+ /* sub-tex replace */
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEX_SIZE, TEX_SIZE,
+ GL_RGBA, GL_FLOAT, image);
+ }
+ else {
+ /* create new */
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0,
+ GL_RGBA, GL_FLOAT, image);
+ }
+}
+
+
+
/* draw a colored cube */
static void
draw_object(void)
@@ -85,52 +160,61 @@ draw_object(void)
glScalef(0.75, 0.75, 0.75);
glColor3f(1, 0, 0);
- glBegin(GL_POLYGON);
- glVertex3f(1, -1, -1);
- glVertex3f(1, 1, -1);
- glVertex3f(1, 1, 1);
- glVertex3f(1, -1, 1);
- glEnd();
+ if (Texture) {
+ glBindTexture(GL_TEXTURE_2D, TexObj);
+ glEnable(GL_TEXTURE_2D);
+ }
+ else {
+ glDisable(GL_TEXTURE_2D);
+ }
+
+ glBegin(GL_QUADS);
+
+ /* -X */
glColor3f(0, 1, 1);
- glBegin(GL_POLYGON);
- glVertex3f(-1, -1, -1);
- glVertex3f(-1, 1, -1);
- glVertex3f(-1, 1, 1);
- glVertex3f(-1, -1, 1);
- glEnd();
+ 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);
- glColor3f(0, 1, 0);
- glBegin(GL_POLYGON);
- glVertex3f(-1, 1, -1);
- glVertex3f( 1, 1, -1);
- glVertex3f( 1, 1, 1);
- glVertex3f(-1, 1, 1);
- glEnd();
+ /* +X */
+ glColor3f(1, 0, 0);
+ 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);
+ /* -Y */
glColor3f(1, 0, 1);
- glBegin(GL_POLYGON);
- glVertex3f(-1, -1, -1);
- glVertex3f( 1, -1, -1);
- glVertex3f( 1, -1, 1);
- glVertex3f(-1, -1, 1);
- glEnd();
+ 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);
- glColor3f(0, 0, 1);
- glBegin(GL_POLYGON);
- glVertex3f(-1, -1, 1);
- glVertex3f( 1, -1, 1);
- glVertex3f( 1, 1, 1);
- glVertex3f(-1, 1, 1);
- glEnd();
+ /* +Y */
+ glColor3f(0, 1, 0);
+ 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);
+ /* -Z */
glColor3f(1, 1, 0);
- glBegin(GL_POLYGON);
- glVertex3f(-1, -1, -1);
- glVertex3f( 1, -1, -1);
- glVertex3f( 1, 1, -1);
- glVertex3f(-1, 1, -1);
+ 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);
+
+ /* +Y */
+ glColor3f(0, 0, 1);
+ 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();
+
glPopMatrix();
}
@@ -142,6 +226,8 @@ resize(struct winthread *wt, int w, int h)
wt->NewSize = GL_TRUE;
wt->WinWidth = w;
wt->WinHeight = h;
+ if (!Animate)
+ signal_redraw();
}
@@ -151,18 +237,19 @@ resize(struct winthread *wt, int w, int h)
static void
draw_loop(struct winthread *wt)
{
- GLboolean firstIter = GL_TRUE;
-
while (!ExitFlag) {
if (Locking)
pthread_mutex_lock(&Mutex);
glXMakeCurrent(wt->Dpy, wt->Win, wt->Context);
- if (firstIter) {
+ if (!wt->Initialized) {
printf("glthreads: %d: GL_RENDERER = %s\n", wt->Index,
(char *) glGetString(GL_RENDERER));
- firstIter = GL_FALSE;
+ if (Texture /*&& wt->Index == 0*/) {
+ MakeNewTexture(wt);
+ }
+ wt->Initialized = GL_TRUE;
}
if (Locking)
@@ -182,10 +269,15 @@ draw_loop(struct winthread *wt)
wt->NewSize = GL_FALSE;
}
+ if (wt->MakeNewTexture) {
+ MakeNewTexture(wt);
+ wt->MakeNewTexture = GL_FALSE;
+ }
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
- glRotatef(wt->Angle, 0, 0, 1);
+ glRotatef(wt->Angle, 0, 1, 0);
glRotatef(wt->Angle, 1, 0, 0);
glScalef(0.7, 0.7, 0.7);
draw_object();
@@ -199,12 +291,63 @@ draw_loop(struct winthread *wt)
if (Locking)
pthread_mutex_unlock(&Mutex);
- usleep(5000);
+ if (Animate) {
+ usleep(5000);
+ }
+ else {
+ /* wait for signal to draw */
+ pthread_mutex_lock(&CondMutex);
+ pthread_cond_wait(&CondVar, &CondMutex);
+ pthread_mutex_unlock(&CondMutex);
+ }
wt->Angle += 1.0;
}
}
+static void
+keypress(XEvent *event, struct winthread *wt)
+{
+ char buf[100];
+ KeySym keySym;
+ XComposeStatus stat;
+
+ XLookupString(&event->xkey, buf, sizeof(buf), &keySym, &stat);
+
+ switch (keySym) {
+ case XK_Escape:
+ /* tell all threads to exit */
+ if (!Animate) {
+ signal_redraw();
+ }
+ ExitFlag = GL_TRUE;
+ /*printf("exit draw_loop %d\n", wt->Index);*/
+ return;
+ case XK_t:
+ case XK_T:
+ if (Texture) {
+ wt->MakeNewTexture = GL_TRUE;
+ if (!Animate)
+ signal_redraw();
+ }
+ break;
+ case XK_a:
+ case XK_A:
+ Animate = !Animate;
+ if (Animate) /* yes, prev Animate state! */
+ signal_redraw();
+ break;
+ case XK_s:
+ case XK_S:
+ if (!Animate)
+ signal_redraw();
+ break;
+ default:
+ ; /* nop */
+ }
+}
+
+
/*
* The main process thread runs this loop.
* Single display connection for all threads.
@@ -250,10 +393,14 @@ event_loop(Display *dpy)
}
break;
case KeyPress:
- /* tell all threads to exit */
- ExitFlag = GL_TRUE;
- /*printf("exit draw_loop %d\n", wt->Index);*/
- return;
+ for (i = 0; i < NumWinThreads; i++) {
+ struct winthread *wt = &WinThreads[i];
+ if (event.xkey.window == wt->Win) {
+ keypress(&event, wt);
+ break;
+ }
+ }
+ break;
default:
/*no-op*/ ;
}
@@ -281,12 +428,10 @@ event_loop_multi(void)
resize(wt, event.xconfigure.width, event.xconfigure.height);
break;
case KeyPress:
- /* tell all threads to exit */
- ExitFlag = GL_TRUE;
- /*printf("exit draw_loop %d\n", wt->Index);*/
- return;
+ keypress(&event, wt);
+ break;
default:
- /*no-op*/ ;
+ ; /* nop */
}
}
w = (w + 1) % NumWinThreads;
@@ -300,7 +445,7 @@ event_loop_multi(void)
* we'll call this once for each thread, before the threads are created.
*/
static void
-create_window(struct winthread *wt)
+create_window(struct winthread *wt, GLXContext shareCtx)
{
Window win;
GLXContext ctx;
@@ -316,9 +461,9 @@ create_window(struct winthread *wt)
unsigned long mask;
Window root;
XVisualInfo *visinfo;
- int width = 80, height = 80;
- int xpos = (wt->Index % 10) * 90;
- int ypos = (wt->Index / 10) * 100;
+ int width = 160, height = 160;
+ int xpos = (wt->Index % 8) * (width + 10);
+ int ypos = (wt->Index / 8) * (width + 20);
scrnum = DefaultScreen(wt->Dpy);
root = RootWindow(wt->Dpy, scrnum);
@@ -355,7 +500,7 @@ create_window(struct winthread *wt)
}
- ctx = glXCreateContext(wt->Dpy, visinfo, NULL, True);
+ ctx = glXCreateContext(wt->Dpy, visinfo, shareCtx, True);
if (!ctx) {
Error("Couldn't create GLX context");
}
@@ -405,6 +550,25 @@ clean_up(void)
}
+static void
+usage(void)
+{
+ printf("glthreads: test of GL thread safety (any key = exit)\n");
+ printf("Usage:\n");
+ printf(" glthreads [options]\n");
+ printf("Options:\n");
+ printf(" -display DISPLAYNAME Specify display string\n");
+ printf(" -n NUMTHREADS Number of threads to create\n");
+ printf(" -p Use a separate display connection for each thread\n");
+ printf(" -l Use application-side locking\n");
+ printf(" -t Enable texturing\n");
+ printf("Keyboard:\n");
+ printf(" Esc Exit\n");
+ printf(" t Change texture image (requires -t option)\n");
+ printf(" a Toggle animation\n");
+ printf(" s Step rotation (when not animating)\n");
+}
+
int
main(int argc, char *argv[])
@@ -416,9 +580,7 @@ main(int argc, char *argv[])
Status threadStat;
if (argc == 1) {
- printf("glthreads: test of GL thread safety (any key = exit)\n");
- printf("Usage:\n");
- printf(" glthreads [-display dpyName] [-n numthreads]\n");
+ usage();
}
else {
int i;
@@ -433,6 +595,9 @@ main(int argc, char *argv[])
else if (strcmp(argv[i], "-l") == 0) {
Locking = 1;
}
+ else if (strcmp(argv[i], "-t") == 0) {
+ Texture = 1;
+ }
else if (strcmp(argv[i], "-n") == 0 && i + 1 < argc) {
numThreads = atoi(argv[i + 1]);
if (numThreads < 1)
@@ -442,13 +607,14 @@ main(int argc, char *argv[])
i++;
}
else {
- fprintf(stderr, "glthreads: unexpected flag: %s\n", argv[i]);
+ usage();
+ exit(1);
}
}
}
if (Locking)
- printf("glthreads: Using explict locks around Xlib calls.\n");
+ printf("glthreads: Using explicit locks around Xlib calls.\n");
else
printf("glthreads: No explict locking.\n");
@@ -478,9 +644,9 @@ main(int argc, char *argv[])
}
}
- if (Locking) {
- pthread_mutex_init(&Mutex, NULL);
- }
+ pthread_mutex_init(&Mutex, NULL);
+ pthread_mutex_init(&CondMutex, NULL);
+ pthread_cond_init(&CondVar, NULL);
printf("glthreads: creating windows\n");
@@ -488,6 +654,8 @@ main(int argc, char *argv[])
/* Create the GLX windows and contexts */
for (i = 0; i < numThreads; i++) {
+ GLXContext share;
+
if (MultiDisplays) {
WinThreads[i].Dpy = XOpenDisplay(displayName);
assert(WinThreads[i].Dpy);
@@ -496,7 +664,11 @@ main(int argc, char *argv[])
WinThreads[i].Dpy = dpy;
}
WinThreads[i].Index = i;
- create_window(&WinThreads[i]);
+ WinThreads[i].Initialized = GL_FALSE;
+
+ share = (Texture && i > 0) ? WinThreads[0].Context : 0;
+
+ create_window(&WinThreads[i], share);
}
printf("glthreads: creating threads\n");
@@ -505,7 +677,7 @@ main(int argc, char *argv[])
for (i = 0; i < numThreads; i++) {
pthread_create(&WinThreads[i].Thread, NULL, thread_function,
(void*) &WinThreads[i]);
- printf("glthreads: Created thread %u\n", (unsigned int) WinThreads[i].Thread);
+ printf("glthreads: Created thread %p\n", (void *) WinThreads[i].Thread);
}
if (MultiDisplays)
diff --git a/progs/xdemos/vgears.c b/progs/xdemos/vgears.c
index 13d030a8bef..f579e8b421d 100644
--- a/progs/xdemos/vgears.c
+++ b/progs/xdemos/vgears.c
@@ -1,4 +1,3 @@
-/* $ID$ */
/*
* Spinning gears demo for Linux SVGA/Mesa interface in 32K color mode.