summaryrefslogtreecommitdiffstats
path: root/progs
diff options
context:
space:
mode:
Diffstat (limited to 'progs')
-rw-r--r--progs/beos/.gitignore3
-rw-r--r--progs/demos/drawpix.c4
-rw-r--r--progs/demos/lodbias.c5
-rw-r--r--progs/demos/shadowtex.c1
-rw-r--r--progs/demos/streaming_rect.c25
-rw-r--r--progs/directfb/.gitignore4
-rw-r--r--progs/egl/.gitignore5
-rw-r--r--progs/fbdev/.gitignore1
-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/glsl/texdemo1.c4
-rw-r--r--progs/miniglx/.gitignore6
-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/Makefile2
-rw-r--r--progs/tests/manytex.c14
-rw-r--r--progs/tests/mipmap_limits.c32
-rw-r--r--progs/tests/zcomp.c223
-rw-r--r--progs/tests/zdrawpix.c192
-rw-r--r--progs/tools/trace/.gitignore1
-rw-r--r--progs/trivial/.gitignore4
-rw-r--r--progs/trivial/Makefile3
-rw-r--r--progs/trivial/point-wide-smooth.c145
-rw-r--r--progs/trivial/point-wide.c15
-rw-r--r--progs/trivial/quad-tex-2d.c6
-rw-r--r--progs/trivial/tri-orig.c136
-rw-r--r--progs/trivial/tri-unfilled-edgeflag.c141
-rw-r--r--progs/util/showbuffer.c6
-rw-r--r--progs/vp/.gitignore1
-rw-r--r--progs/xdemos/.gitignore1
-rw-r--r--progs/xdemos/Makefile1
-rw-r--r--progs/xdemos/sharedtex.c324
37 files changed, 1801 insertions, 59 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/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/shadowtex.c b/progs/demos/shadowtex.c
index 59253e8c1e3..05741759354 100644
--- a/progs/demos/shadowtex.c
+++ b/progs/demos/shadowtex.c
@@ -650,6 +650,7 @@ Display(void)
glDisable(GL_FRAGMENT_PROGRAM_ARB);
}
+ glDisable(GL_TEXTURE_1D);
glDisable(GL_TEXTURE_2D);
}
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/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/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/glsl/texdemo1.c b/progs/glsl/texdemo1.c
index d29ecf452b1..3ceae14b96b 100644
--- a/progs/glsl/texdemo1.c
+++ b/progs/glsl/texdemo1.c
@@ -48,6 +48,7 @@ static GLfloat TexXrot = 0, TexYrot = 0;
static GLfloat Xrot = 20.0, Yrot = 20.0, Zrot = 0.0;
static GLfloat EyeDist = 10;
static GLboolean Anim = GL_TRUE;
+static int win = 0;
struct uniform_info {
@@ -177,6 +178,7 @@ key(unsigned char k, int x, int y)
EyeDist = 90;
break;
case 27:
+ glutDestroyWindow(win);
exit(0);
}
glutPostRedisplay();
@@ -554,7 +556,7 @@ main(int argc, char *argv[])
glutInit(&argc, argv);
glutInitWindowSize(500, 400);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
- glutCreateWindow(Demo);
+ win = glutCreateWindow(Demo);
glutReshapeFunc(Reshape);
glutKeyboardFunc(key);
glutSpecialFunc(specialkey);
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/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 b/progs/tests/Makefile
index 27e2eafdfcb..75d1eca08ee 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -84,6 +84,8 @@ SOURCES = \
vpwarpmesh.c \
yuvrect.c \
yuvsquare.c \
+ zcomp.c \
+ zdrawpix.c \
zreaddraw.c
PROGS = $(SOURCES:%.c=%)
diff --git a/progs/tests/manytex.c b/progs/tests/manytex.c
index 61a1519ae6b..900e5834fe8 100644
--- a/progs/tests/manytex.c
+++ b/progs/tests/manytex.c
@@ -30,6 +30,7 @@ static GLboolean LinearFilter = GL_FALSE;
static GLboolean RandomSize = GL_FALSE;
static GLint Rows, Columns;
static GLint LowPriorityCount = 0;
+static GLint Win;
static void Idle( void )
@@ -128,6 +129,14 @@ static int RandomInt(int min, int max)
}
+static void DeleteTextures(void)
+{
+ glDeleteTextures(NumTextures, TextureID);
+ free(TextureID);
+ TextureID = NULL;
+}
+
+
static void Init( void )
{
@@ -306,9 +315,12 @@ static void Key( unsigned char key, int x, int y )
Zrot += step;
break;
case ' ':
+ DeleteTextures();
Init();
break;
case 27:
+ DeleteTextures();
+ glutDestroyWindow(Win);
exit(0);
break;
}
@@ -324,7 +336,7 @@ int main( int argc, char *argv[] )
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( WinWidth, WinHeight );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
- glutCreateWindow(argv[0]);
+ Win = glutCreateWindow(argv[0]);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutDisplayFunc( Display );
diff --git a/progs/tests/mipmap_limits.c b/progs/tests/mipmap_limits.c
index d6d6e467b0f..8bdad826f7c 100644
--- a/progs/tests/mipmap_limits.c
+++ b/progs/tests/mipmap_limits.c
@@ -59,6 +59,18 @@ static GLfloat LodBias = 0.0;
static GLboolean NearestFilter = GL_TRUE;
+static void
+InitValues(void)
+{
+ BaseLevel = 0;
+ MaxLevel = 8;
+ MinLod = -1;
+ MaxLod = 9;
+ LodBias = 0.0;
+ NearestFilter = GL_TRUE;
+}
+
+
static void MakeImage(int level, int width, int height, const GLubyte color[4])
{
const int makeStripes = 0;
@@ -108,6 +120,8 @@ static void makeImages(void)
static void myinit(void)
{
+ InitValues();
+
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glShadeModel(GL_FLAT);
@@ -125,7 +139,7 @@ static void myinit(void)
static void display(void)
{
GLfloat tcm = 4.0;
- printf("BASE_LEVEL = %d MAX_LEVEL = %d MIN_LOD = %f MAX_LOD = %f Bias = %.2g filter = %s\n",
+ printf("BASE_LEVEL=%d MAX_LEVEL=%d MIN_LOD=%.2g MAX_LOD=%.2g Bias=%.2g Filter=%s\n",
BaseLevel, MaxLevel, MinLod, MaxLod, LodBias,
NearestFilter ? "NEAREST" : "LINEAR");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);
@@ -214,6 +228,9 @@ key(unsigned char k, int x, int y)
case 'f':
NearestFilter = !NearestFilter;
break;
+ case ' ':
+ InitValues();
+ break;
case 27: /* Escape */
exit(0);
break;
@@ -227,12 +244,13 @@ key(unsigned char k, int x, int y)
static void usage(void)
{
printf("usage:\n");
- printf(" b/B decrease/increase GL_TEXTURE_BASE_LEVEL\n");
- printf(" m/M decrease/increase GL_TEXTURE_MAX_LEVEL\n");
- printf(" n/N decrease/increase GL_TEXTURE_MIN_LOD\n");
- printf(" x/X decrease/increase GL_TEXTURE_MAX_LOD\n");
- printf(" l/L decrease/increase GL_TEXTURE_LOD_BIAS\n");
- printf(" f toggle nearest/linear filtering\n");
+ printf(" b/B decrease/increase GL_TEXTURE_BASE_LEVEL\n");
+ printf(" m/M decrease/increase GL_TEXTURE_MAX_LEVEL\n");
+ printf(" n/N decrease/increase GL_TEXTURE_MIN_LOD\n");
+ printf(" x/X decrease/increase GL_TEXTURE_MAX_LOD\n");
+ printf(" l/L decrease/increase GL_TEXTURE_LOD_BIAS\n");
+ printf(" f toggle nearest/linear filtering\n");
+ printf(" SPACE reset values\n");
}
diff --git a/progs/tests/zcomp.c b/progs/tests/zcomp.c
new file mode 100644
index 00000000000..b53079d07fc
--- /dev/null
+++ b/progs/tests/zcomp.c
@@ -0,0 +1,223 @@
+/**
+ * Test Z compositing with glDrawPixels(GL_DEPTH_COMPONENT) and stencil test.
+ */
+
+#define GL_GLEXT_PROTOTYPES
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#include "../util/showbuffer.c"
+
+
+static int Win;
+static GLfloat Xrot = 0, Yrot = 0, Zpos = 6;
+static GLboolean Anim = GL_FALSE;
+
+static int Width = 400, Height = 200;
+static GLfloat *Zimg;
+static GLubyte *Cimg;
+static GLboolean showZ = 0;
+
+
+static void
+Idle(void)
+{
+ Xrot += 3.0;
+ Yrot += 4.0;
+ glutPostRedisplay();
+}
+
+
+/**
+ * Draw first object, save color+Z images
+ */
+static void
+DrawFirst(void)
+{
+ static const GLfloat red[4] = { 1.0, 0.0, 0.0, 0.0 };
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glPushMatrix();
+ glTranslatef(-1, 0, 0);
+ glRotatef(45 + Xrot, 1, 0, 0);
+
+ glutSolidTorus(0.75, 2.0, 10, 20);
+
+ glPopMatrix();
+
+ glReadPixels(0, 0, Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, Zimg);
+ glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, Cimg);
+}
+
+
+/**
+ * Draw second object.
+ */
+static void
+DrawSecond(void)
+{
+ static const GLfloat blue[4] = { 0.0, 0.0, 1.0, 0.0 };
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ glPushMatrix();
+ glTranslatef(+1, 0, 0);
+ glRotatef(-45 + Xrot, 1, 0, 0);
+
+ glutSolidTorus(0.75, 2.0, 10, 20);
+
+ glPopMatrix();
+}
+
+
+/**
+ * Composite first/saved image over second rendering.
+ */
+static void
+Composite(void)
+{
+ glWindowPos2i(0, 0);
+
+ /* Draw Z values, set stencil where Z test passes */
+ glEnable(GL_STENCIL_TEST);
+ glStencilFunc(GL_ALWAYS, 1, ~0);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+ glColorMask(0,0,0,0);
+ glDrawPixels(Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, Zimg);
+ glColorMask(1,1,1,1);
+
+ /* Draw color where stencil==1 */
+ glStencilFunc(GL_EQUAL, 1, ~0);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ glDisable(GL_DEPTH_TEST);
+ glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, Cimg);
+ glEnable(GL_DEPTH_TEST);
+
+ glDisable(GL_STENCIL_TEST);
+}
+
+
+static void
+Draw(void)
+{
+ DrawFirst();
+ DrawSecond();
+ Composite();
+ 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, 5.0, 30.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -15.0);
+
+ Width = width;
+ Height = height;
+
+ if (Zimg)
+ free(Zimg);
+ if (Cimg)
+ free(Cimg);
+ Zimg = (float *) malloc(width * height * 4);
+ Cimg = (GLubyte *) malloc(width * height * 4);
+}
+
+
+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 'd':
+ showZ = !showZ;
+ break;
+ case 'z':
+ Zpos -= step;
+ break;
+ case 'Z':
+ Zpos += step;
+ break;
+ case 27:
+ glutDestroyWindow(Win);
+ 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)
+{
+ /* setup lighting, etc */
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(Width, Height);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);
+ Win = glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Draw);
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/zdrawpix.c b/progs/tests/zdrawpix.c
new file mode 100644
index 00000000000..dd222e7dd0b
--- /dev/null
+++ b/progs/tests/zdrawpix.c
@@ -0,0 +1,192 @@
+/**
+ * Test glDrawPixels(GL_DEPTH_COMPONENT)
+ *
+ * We load a window-sized buffer of Z values so that Z=1 at the top and
+ * Z=0 at the bottom (and interpolate between).
+ * We draw that image into the Z buffer, then draw an ordinary cube.
+ * The bottom part of the cube should be "clipped" where the cube fails
+ * the Z test.
+ *
+ * Press 'd' to view the Z buffer as a grayscale image.
+ */
+
+#define GL_GLEXT_PROTOTYPES
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#include "../util/showbuffer.c"
+
+
+static int Win;
+static GLfloat Xrot = 50, Yrot = 40, Zpos = 6;
+static GLboolean Anim = GL_FALSE;
+
+static int Width = 200, Height = 200;
+static GLfloat *z;
+static GLboolean showZ = 0;
+
+
+static void
+Idle(void)
+{
+ Xrot += 3.0;
+ Yrot += 4.0;
+ glutPostRedisplay();
+}
+
+
+static void
+Draw(void)
+{
+ glClearColor(0, 0, 0.5, 0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+#if 1
+ glColor3f(1, 0, 0);
+ glWindowPos2i(0,0);
+ glColorMask(0,0,0,0);
+ glDrawPixels(Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, z);
+#elif 0
+ glPushMatrix();
+ glTranslatef(-0.75, 0, Zpos);
+ glutSolidSphere(1.0, 20, 10);
+ glPopMatrix();
+#endif
+ glColorMask(1,1,1,1);
+
+ /* draw cube */
+ glPushMatrix();
+ glTranslatef(0, 0, Zpos);
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glutSolidCube(2.0);
+ glPopMatrix();
+
+#if 0
+ /* drawpixels after cube */
+ glColor3f(1, 0, 0);
+ glWindowPos2i(0,0);
+ //glColorMask(0,0,0,0);
+ glDrawPixels(Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, z);
+#endif
+
+ if (showZ) {
+ ShowDepthBuffer(Width, Height, 0.0, 1.0);
+ }
+
+ 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, 30.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -15.0);
+
+ Width = width;
+ Height = height;
+
+ z = (float *) malloc(width * height * 4);
+ {
+ int i, j, k = 0;
+ for (i = 0; i < height; i++) {
+ float zval = (float) i / (height - 1);
+ for (j = 0; j < width; j++) {
+ z[k++] = zval;
+ }
+ }
+ }
+}
+
+
+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 'd':
+ showZ = !showZ;
+ break;
+ case 'z':
+ Zpos -= step;
+ break;
+ case 'Z':
+ Zpos += step;
+ break;
+ case 27:
+ glutDestroyWindow(Win);
+ 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)
+{
+ /* setup lighting, etc */
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(400, 400);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ Win = glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Draw);
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
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/trivial/Makefile b/progs/trivial/Makefile
index 8bc6ad4e387..1dbc4721e87 100644
--- a/progs/trivial/Makefile
+++ b/progs/trivial/Makefile
@@ -45,6 +45,7 @@ SOURCES = \
point-param.c \
point-sprite.c \
point-wide.c \
+ point-wide-smooth.c \
point.c \
poly-flat.c \
poly-unfilled.c \
@@ -69,6 +70,7 @@ SOURCES = \
quadstrip-cont.c \
quadstrip-flat.c \
quadstrip.c \
+ tri-orig.c \
tri-alpha.c \
tri-blend-color.c \
tri-blend-max.c \
@@ -92,6 +94,7 @@ SOURCES = \
tri-stencil.c \
tri-tex-3d.c \
tri-tri.c \
+ tri-unfilled-edgeflag.c \
tri-unfilled-clip.c \
tri-unfilled-smooth.c \
tri-unfilled-userclip-stip.c \
diff --git a/progs/trivial/point-wide-smooth.c b/progs/trivial/point-wide-smooth.c
new file mode 100644
index 00000000000..55cbcaec70b
--- /dev/null
+++ b/progs/trivial/point-wide-smooth.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+
+static void Init(void)
+{
+ 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));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glPointSize(8.0);
+
+ glEnable(GL_POINT_SMOOTH);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glBegin(GL_POINTS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ 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;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB | GLUT_ALPHA;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(type);
+
+ if (glutCreateWindow("First Tri") == GL_FALSE) {
+ exit(1);
+ }
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/point-wide.c b/progs/trivial/point-wide.c
index d1038ecfa15..265b20097b1 100644
--- a/progs/trivial/point-wide.c
+++ b/progs/trivial/point-wide.c
@@ -33,7 +33,6 @@
GLenum doubleBuffer;
-static GLboolean smooth = GL_FALSE;
static void Init(void)
@@ -60,9 +59,6 @@ static void Key(unsigned char key, int x, int y)
{
switch (key) {
- case 's':
- smooth = !smooth;
- break;
case 27:
exit(1);
default:
@@ -75,19 +71,10 @@ static void Key(unsigned char key, int x, int y)
static void Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT);
+ glDisable(GL_DEPTH_TEST);
glPointSize(8.0);
- if (smooth) {
- glEnable(GL_POINT_SMOOTH);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- else {
- glDisable(GL_POINT_SMOOTH);
- glDisable(GL_BLEND);
- }
-
glBegin(GL_POINTS);
glColor3f(1,0,0);
glVertex3f( 0.9, -0.9, -30.0);
diff --git a/progs/trivial/quad-tex-2d.c b/progs/trivial/quad-tex-2d.c
index 3a6e5237ed5..97c9fc54d86 100644
--- a/progs/trivial/quad-tex-2d.c
+++ b/progs/trivial/quad-tex-2d.c
@@ -31,6 +31,7 @@ static GLenum Target = GL_TEXTURE_2D;
static GLenum Filter = GL_NEAREST;
GLenum doubleBuffer;
static float Rot = 0;
+static int win = 0;
static void Init(void)
{
@@ -88,6 +89,7 @@ static void Reshape(int width, int height)
glFrustum(-1, 1, -1, 1, 10, 20);
#endif
glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
glTranslatef(0, 0, -15);
}
@@ -101,6 +103,7 @@ static void Key(unsigned char key, int x, int y)
Rot -= 10.0;
break;
case 27:
+ glutDestroyWindow(win);
exit(0);
default:
return;
@@ -170,7 +173,8 @@ int main(int argc, char **argv)
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
glutInitDisplayMode(type);
- if (glutCreateWindow("First Tri") == GL_FALSE) {
+ win = glutCreateWindow("First Tri");
+ if (!win) {
exit(1);
}
diff --git a/progs/trivial/tri-orig.c b/progs/trivial/tri-orig.c
new file mode 100644
index 00000000000..d5e6742ce1a
--- /dev/null
+++ b/progs/trivial/tri-orig.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ 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));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ 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;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB | GLUT_ALPHA;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(type);
+
+ if (glutCreateWindow("First Tri") == GL_FALSE) {
+ exit(1);
+ }
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/tri-unfilled-edgeflag.c b/progs/trivial/tri-unfilled-edgeflag.c
new file mode 100644
index 00000000000..31f41f6220b
--- /dev/null
+++ b/progs/trivial/tri-unfilled-edgeflag.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ 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));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLES);
+ glEdgeFlag(1);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glEdgeFlag(0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glEdgeFlag(1);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ 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;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB | GLUT_ALPHA;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(type);
+
+ if (glutCreateWindow("First Tri") == GL_FALSE) {
+ exit(1);
+ }
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/util/showbuffer.c b/progs/util/showbuffer.c
index 17f84dc62bd..b0cedea217c 100644
--- a/progs/util/showbuffer.c
+++ b/progs/util/showbuffer.c
@@ -71,6 +71,8 @@ ShowDepthBuffer( GLsizei winWidth, GLsizei winHeight,
glPushMatrix();
glLoadIdentity();
+ glViewport(0, 0, winWidth, winHeight);
+
glDisable(GL_STENCIL_TEST);
glDisable(GL_DEPTH_TEST);
glRasterPos2f(0, 0);
@@ -120,6 +122,8 @@ ShowAlphaBuffer( GLsizei winWidth, GLsizei winHeight )
glPushMatrix();
glLoadIdentity();
+ glViewport(0, 0, winWidth, winHeight);
+
glDisable(GL_STENCIL_TEST);
glDisable(GL_DEPTH_TEST);
glRasterPos2f(0, 0);
@@ -170,6 +174,8 @@ ShowStencilBuffer( GLsizei winWidth, GLsizei winHeight,
glPushMatrix();
glLoadIdentity();
+ glViewport(0, 0, winWidth, winHeight);
+
glDisable(GL_STENCIL_TEST);
glDisable(GL_DEPTH_TEST);
glRasterPos2f(0, 0);
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/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/Makefile b/progs/xdemos/Makefile
index d1d7fecea1c..896b1608780 100644
--- a/progs/xdemos/Makefile
+++ b/progs/xdemos/Makefile
@@ -23,6 +23,7 @@ PROGS = glthreads \
overlay \
pbinfo \
pbdemo \
+ sharedtex \
texture_from_pixmap \
wincopy \
xfont \
diff --git a/progs/xdemos/sharedtex.c b/progs/xdemos/sharedtex.c
new file mode 100644
index 00000000000..81703fe0e7d
--- /dev/null
+++ b/progs/xdemos/sharedtex.c
@@ -0,0 +1,324 @@
+/*
+ * Test sharing of texture objects by two rendering contexts.
+ * In particular, test that changing a texture object in one context
+ * effects the texture in the second context.
+ *
+ * Brian Paul
+ * 30 Apr 2008
+ *
+ * Copyright (C) 2008 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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <X11/keysym.h>
+
+
+#define MAX_CONTEXTS 2
+
+#define TEX_SIZE 32
+
+static const char *DisplayName = NULL;
+static Display *Dpy;
+static XVisualInfo *VisInfo;
+static Window Win;
+static GLXContext Contexts[MAX_CONTEXTS];
+static int WinWidth = 300, WinHeight = 300;
+
+static int DrawContext = 0, TexContext = 1;
+
+static GLuint TexObj = 0;
+static GLboolean NewTexture = GL_FALSE;
+
+
+static void
+Error(const char *msg)
+{
+ fprintf(stderr, "sharedtex error: %s\n", msg);
+ exit(1);
+}
+
+
+static void
+CreateWindow(const char *name)
+{
+ 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;
+ int xpos = 0, ypos = 0;
+ static int n = 0;
+
+ scrnum = DefaultScreen(Dpy);
+ root = RootWindow(Dpy, scrnum);
+
+ VisInfo = glXChooseVisual(Dpy, scrnum, attrib);
+ if (!VisInfo) {
+ Error("Unable to find RGB, double-buffered visual");
+ }
+
+ /* window attributes */
+ xpos = (n % 10) * 100;
+ ypos = (n / 10) * 100;
+ n++;
+
+ 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, WinWidth, WinHeight,
+ 0, VisInfo->depth, InputOutput,
+ VisInfo->visual, mask, &attr);
+ if (!Win) {
+ Error("Couldn't create window");
+ }
+
+ {
+ XSizeHints sizehints;
+ sizehints.x = xpos;
+ sizehints.y = ypos;
+ sizehints.width = WinWidth;
+ sizehints.height = WinHeight;
+ sizehints.flags = USSize | USPosition;
+ XSetNormalHints(Dpy, Win, &sizehints);
+ XSetStandardProperties(Dpy, Win, name, name,
+ None, (char **)NULL, 0, &sizehints);
+ }
+
+ XMapWindow(Dpy, Win);
+}
+
+
+/**
+ * Change texture image, using TexContext
+ */
+static void
+ModifyTexture(void)
+{
+ GLuint tex[TEX_SIZE][TEX_SIZE];
+ GLuint c0, c1;
+ int i, j;
+
+ if (Win && !glXMakeCurrent(Dpy, Win, Contexts[TexContext])) {
+ Error("glXMakeCurrent failed");
+ }
+
+ /* choose two random colors */
+ c0 = rand() & 0xffffffff;
+ c1 = rand() & 0xffffffff;
+
+ for (i = 0; i < TEX_SIZE; i++) {
+ for (j = 0; j < TEX_SIZE; j++) {
+ if (((i / 4) ^ (j / 4)) & 1) {
+ tex[i][j] = c0;
+ }
+ else {
+ tex[i][j] = c1;
+ }
+ }
+ }
+
+ glBindTexture(GL_TEXTURE_2D, TexObj);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, tex);
+
+ NewTexture = GL_TRUE;
+}
+
+
+static void
+InitContext(void)
+{
+ glGenTextures(1, &TexObj);
+ assert(TexObj);
+ glBindTexture(GL_TEXTURE_2D, TexObj);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glEnable(GL_TEXTURE_2D);
+
+ printf("GL_RENDERER = %s\n", (char*) glGetString(GL_RENDERER));
+}
+
+
+static void
+Setup(void)
+{
+ int i;
+
+ Dpy = XOpenDisplay(DisplayName);
+ if (!Dpy) {
+ Error("Unable to open display");
+ }
+
+ CreateWindow("sharedtex");
+
+ for (i = 0; i < MAX_CONTEXTS; i++) {
+ GLXContext share = i > 0 ? Contexts[0] : 0;
+
+ Contexts[i] = glXCreateContext(Dpy, VisInfo, share, True);
+ if (!Contexts[i]) {
+ Error("Unable to create GLX context");
+ }
+
+ if (!glXMakeCurrent(Dpy, Win, Contexts[i])) {
+ Error("glXMakeCurrent failed");
+ }
+
+ InitContext();
+ }
+
+ ModifyTexture();
+}
+
+
+/**
+ * Redraw window, using DrawContext
+ */
+static void
+Redraw(void)
+{
+ static float rot = 0.0;
+ float ar;
+
+ rot += 1.0;
+
+ if (Win && !glXMakeCurrent(Dpy, Win, Contexts[DrawContext])) {
+ Error("glXMakeCurrent failed");
+ }
+
+ glViewport(0, 0, WinWidth, WinHeight);
+ ar = (float) WinWidth / (float) WinHeight;
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-ar, ar, -1.0, 1.0, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+
+ glShadeModel(GL_FLAT);
+ glClearColor(0.5, 0.5, 0.5, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glPushMatrix();
+ glRotatef(rot, 0, 0, 1);
+ glScalef(0.7, 0.7, 0.7);
+
+ if (NewTexture) {
+ /* rebind to get new contents */
+ glBindTexture(GL_TEXTURE_2D, TexObj);
+ NewTexture = GL_FALSE;
+ }
+
+ /* draw textured quad */
+ glBegin(GL_POLYGON);
+ 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 );
+ glEnd();
+
+ glPopMatrix();
+
+ if (Win)
+ glXSwapBuffers(Dpy, Win);
+}
+
+
+static void
+EventLoop(void)
+{
+ while (1) {
+ while (XPending(Dpy) > 0) {
+ XEvent event;
+ XNextEvent(Dpy, &event);
+
+ switch (event.type) {
+ case Expose:
+ Redraw();
+ break;
+ case ConfigureNotify:
+ WinWidth = event.xconfigure.width;
+ WinHeight = event.xconfigure.height;
+ break;
+ case KeyPress:
+ {
+ char buf[100];
+ KeySym keySym;
+ XComposeStatus stat;
+ XLookupString(&event.xkey, buf, sizeof(buf), &keySym, &stat);
+ switch (keySym) {
+ case XK_Escape:
+ exit(0);
+ break;
+ case XK_t:
+ case XK_T:
+ ModifyTexture();
+ break;
+ default:
+ ;
+ }
+ }
+ Redraw();
+ break;
+ default:
+ /*no-op*/ ;
+ }
+ }
+
+ Redraw();
+ usleep(10000);
+ }
+}
+
+
+
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-display") == 0 && i < argc) {
+ DisplayName = argv[i+1];
+ i++;
+ }
+ }
+
+ Setup();
+
+ printf("Press 't' to change texture image/colors\n");
+
+ EventLoop();
+
+ return 0;
+}