diff options
author | Keith Packard <keithp@keithp.com> | 2008-06-03 22:56:25 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2008-06-03 22:56:25 -0700 |
commit | dbf3c5247c90bd35c0b2002e3b972a2dd4c8b130 (patch) | |
tree | dd986e993f20f78999fc15c304289656878ffcae /progs | |
parent | 4b5b008d54e86ac4f0a2176429d062100978ca8c (diff) | |
parent | 0b734bd7cf921592eee441f759687e10f48a2cbc (diff) |
Merge commit 'origin/master' into drm-gem
Conflicts:
src/mesa/drivers/dri/common/dri_bufmgr.h
src/mesa/drivers/dri/intel/intel_bufmgr_ttm.c
src/mesa/drivers/dri/intel/intel_bufmgr_ttm.h
src/mesa/drivers/dri/intel/intel_ioctl.c
Diffstat (limited to 'progs')
-rw-r--r-- | progs/Makefile | 2 | ||||
-rw-r--r-- | progs/beos/Makefile | 4 | ||||
-rw-r--r-- | progs/demos/Makefile | 6 | ||||
-rw-r--r-- | progs/egl/Makefile | 6 | ||||
-rw-r--r-- | progs/fbdev/Makefile | 4 | ||||
-rw-r--r-- | progs/fp/Makefile | 6 | ||||
-rw-r--r-- | progs/glsl/Makefile | 8 | ||||
-rw-r--r-- | progs/glsl/multitex.c | 285 | ||||
-rw-r--r-- | progs/glsl/multitex.frag.txt | 15 | ||||
-rw-r--r-- | progs/glsl/multitex.vert.txt | 10 | ||||
-rw-r--r-- | progs/miniglx/Makefile | 4 | ||||
-rw-r--r-- | progs/slang/Makefile | 2 | ||||
-rw-r--r-- | progs/tests/Makefile | 6 | ||||
-rw-r--r-- | progs/tests/fbotest2.c | 1 | ||||
-rw-r--r-- | progs/tests/mipmap_limits.c | 32 | ||||
-rw-r--r-- | progs/trivial/Makefile | 6 | ||||
-rw-r--r-- | progs/trivial/tri.c | 7 | ||||
-rw-r--r-- | progs/vp/Makefile | 6 | ||||
-rw-r--r-- | progs/xdemos/.gitignore | 1 | ||||
-rw-r--r-- | progs/xdemos/glthreads.c | 23 |
20 files changed, 395 insertions, 39 deletions
diff --git a/progs/Makefile b/progs/Makefile index 5e705efa7e..c99f4eebcc 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -25,7 +25,7 @@ subdirs: install: clean: - @for dir in $(SUBDIRS) tests ; do \ + -@for dir in $(SUBDIRS) tests ; do \ if [ -d $$dir ] ; then \ (cd $$dir && $(MAKE) clean) ; \ fi \ diff --git a/progs/beos/Makefile b/progs/beos/Makefile index 491e8e442d..0dc4cdce63 100644 --- a/progs/beos/Makefile +++ b/progs/beos/Makefile @@ -19,8 +19,8 @@ INCLUDES = -I. -I- -I../../include default: demo sample GLInfo clean: - rm -f demo sample GLInfo - rm -f *.o + -rm -f demo sample GLInfo + -rm -f *.o demo: demo.o $(LD) demo.o $(LDFLAGS) $(LIBS) -o $@ diff --git a/progs/demos/Makefile b/progs/demos/Makefile index 01b76ad105..7fde77f0b4 100644 --- a/progs/demos/Makefile +++ b/progs/demos/Makefile @@ -11,9 +11,11 @@ OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS) OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS) -LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) +LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \ + $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) -LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) -lX11 -lXi -lXmu +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \ + $(APP_LIB_DEPS) PROGS = \ arbfplight \ diff --git a/progs/egl/Makefile b/progs/egl/Makefile index 07215604d3..416d2c04b2 100644 --- a/progs/egl/Makefile +++ b/progs/egl/Makefile @@ -60,6 +60,6 @@ eglgears.o: eglgears.c $(HEADERS) clean: - rm -f *.o *~ - rm -f *.so - rm -f $(PROGRAMS) + -rm -f *.o *~ + -rm -f *.so + -rm -f $(PROGRAMS) diff --git a/progs/fbdev/Makefile b/progs/fbdev/Makefile index 56daf56f8a..39401243e5 100644 --- a/progs/fbdev/Makefile +++ b/progs/fbdev/Makefile @@ -37,8 +37,8 @@ LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) default: depend $(PROGS) clean: - rm -f $(PROGS) - rm -f *.o + -rm -f $(PROGS) + -rm -f *.o depend: $(SOURCES) diff --git a/progs/fp/Makefile b/progs/fp/Makefile index a395b734ef..09f22d1a7b 100644 --- a/progs/fp/Makefile +++ b/progs/fp/Makefile @@ -86,9 +86,9 @@ UTIL_FILES = readtex.h readtex.c default: $(UTIL_FILES) $(PROGS) clean: - rm -f $(PROGS) - rm -f *.o - rm -f getproclist.h + -rm -f $(PROGS) + -rm -f *.o + -rm -f getproclist.h # auto code generation diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index ff8fbeb99b..e3f205cdb9 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -15,6 +15,7 @@ PROGS = \ bump \ deriv \ mandelbrot \ + multitex \ noise \ points \ texdemo1 \ @@ -102,6 +103,13 @@ mandelbrot: mandelbrot.o shaderutil.o $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) mandelbrot.o shaderutil.o $(LIBS) -o $@ +multitex.o: multitex.c extfuncs.h readtex.h shaderutil.h + $(CC) -c -I$(INCDIR) $(CFLAGS) multitex.c + +multitex: multitex.o readtex.o shaderutil.o + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) multitex.o readtex.o shaderutil.o $(LIBS) -o $@ + + noise.o: noise.c extfuncs.h shaderutil.h $(CC) -c -I$(INCDIR) $(CFLAGS) noise.c diff --git a/progs/glsl/multitex.c b/progs/glsl/multitex.c new file mode 100644 index 0000000000..5574ed4139 --- /dev/null +++ b/progs/glsl/multitex.c @@ -0,0 +1,285 @@ +/** + * Test multi-texturing with GL shading language. + * + * 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 <assert.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "GL/glut.h" +#include "readtex.h" +#include "extfuncs.h" +#include "shaderutil.h" + +static const char *Demo = "multitex"; + +static const char *VertFile = "multitex.vert.txt"; +static const char *FragFile = "multitex.frag.txt"; + +static const char *TexFiles[2] = + { + "../images/tile.rgb", + "../images/tree2.rgba" + }; + + +static GLuint Program; + +static GLfloat Xrot = -90.0, Yrot = .0, Zrot = 0.0; +static GLfloat EyeDist = 10; +static GLboolean Anim = GL_TRUE; + + +/* value[0] = tex unit */ +static struct uniform_info Uniforms[] = { + { "tex1", 1, GL_INT, { 0, 0, 0, 0 }, -1 }, + { "tex2", 1, GL_INT, { 1, 0, 0, 0 }, -1 }, + END_OF_UNIFORMS +}; + + +static void +DrawPolygon(GLfloat size) +{ + glPushMatrix(); + glRotatef(90, 1, 0, 0); + glNormal3f(0, 0, 1); + glBegin(GL_POLYGON); + + glMultiTexCoord2f(GL_TEXTURE0, 0, 0); + glMultiTexCoord2f(GL_TEXTURE1, 0, 0); + glVertex2f(-size, -size); + + glMultiTexCoord2f(GL_TEXTURE0, 2, 0); + glMultiTexCoord2f(GL_TEXTURE1, 1, 0); + glVertex2f( size, -size); + + glMultiTexCoord2f(GL_TEXTURE0, 2, 2); + glMultiTexCoord2f(GL_TEXTURE1, 1, 1); + glVertex2f( size, size); + + glMultiTexCoord2f(GL_TEXTURE0, 0, 2); + glMultiTexCoord2f(GL_TEXTURE1, 0, 1); + glVertex2f(-size, size); + + glEnd(); + glPopMatrix(); +} + + +static void +draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); /* modelview matrix */ + glTranslatef(0.0, 0.0, -EyeDist); + glRotatef(Zrot, 0, 0, 1); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Xrot, 1, 0, 0); + + DrawPolygon(3.0); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +idle(void) +{ + GLfloat t = 0.05 * glutGet(GLUT_ELAPSED_TIME); + Yrot = t; + glutPostRedisplay(); +} + + +static void +key(unsigned char k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case ' ': + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(idle); + else + glutIdleFunc(NULL); + break; + case 'z': + EyeDist -= 0.5; + if (EyeDist < 3.0) + EyeDist = 3.0; + break; + case 'Z': + EyeDist += 0.5; + if (EyeDist > 90.0) + EyeDist = 90; + break; + case 27: + exit(0); + } + glutPostRedisplay(); +} + + +static void +specialkey(int key, int x, int y) +{ + GLfloat step = 2.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(); +} + + +/* new window size or exposure */ +static void +Reshape(int width, int height) +{ + GLfloat ar = (float) width / (float) height; + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-2.0*ar, 2.0*ar, -2.0, 2.0, 4.0, 100.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void +InitTextures(void) +{ + GLenum filter = GL_LINEAR; + int i; + + for (i = 0; i < 2; i++) { + GLint imgWidth, imgHeight; + GLenum imgFormat; + GLubyte *image = NULL; + + image = LoadRGBImage(TexFiles[i], &imgWidth, &imgHeight, &imgFormat); + if (!image) { + printf("Couldn't read %s\n", TexFiles[i]); + exit(0); + } + + glActiveTexture(GL_TEXTURE0 + i); + glBindTexture(GL_TEXTURE_2D, 42 + i); + gluBuild2DMipmaps(GL_TEXTURE_2D, 4, imgWidth, imgHeight, + imgFormat, GL_UNSIGNED_BYTE, image); + free(image); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); + } +} + + +static GLuint +CreateProgram(const char *vertProgFile, const char *fragProgFile, + struct uniform_info *uniforms) +{ + GLuint fragShader, vertShader, program; + + vertShader = CompileShaderFile(GL_VERTEX_SHADER, vertProgFile); + fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, fragProgFile); + assert(vertShader); + program = LinkShaders(vertShader, fragShader); + + glUseProgram_func(program); + + InitUniforms(program, uniforms); + + return program; +} + + +static void +InitPrograms(void) +{ + Program = CreateProgram(VertFile, FragFile, Uniforms); +} + + +static void +InitGL(void) +{ + const char *version = (const char *) glGetString(GL_VERSION); + + if (version[0] != '2' || version[1] != '.') { + printf("Warning: this program expects OpenGL 2.0\n"); + /*exit(1);*/ + } + printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); + + GetExtensionFuncs(); + + InitTextures(); + InitPrograms(); + + glEnable(GL_DEPTH_TEST); + + glClearColor(.6, .6, .9, 0); + glColor3f(1.0, 1.0, 1.0); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowSize(500, 400); + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); + glutCreateWindow(Demo); + glutReshapeFunc(Reshape); + glutKeyboardFunc(key); + glutSpecialFunc(specialkey); + glutDisplayFunc(draw); + if (Anim) + glutIdleFunc(idle); + InitGL(); + glutMainLoop(); + return 0; +} diff --git a/progs/glsl/multitex.frag.txt b/progs/glsl/multitex.frag.txt new file mode 100644 index 0000000000..86045306af --- /dev/null +++ b/progs/glsl/multitex.frag.txt @@ -0,0 +1,15 @@ +// Multi-texture fragment shader +// Brian Paul + +// Composite second texture over first. +// We're assuming the 2nd texture has a meaningful alpha channel. + +uniform sampler2D tex1; +uniform sampler2D tex2; + +void main() +{ + vec4 t1 = texture2D(tex1, gl_TexCoord[0].xy, 0.0); + vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy, 0.0); + gl_FragColor = mix(t1, t2, t2.w); +} diff --git a/progs/glsl/multitex.vert.txt b/progs/glsl/multitex.vert.txt new file mode 100644 index 0000000000..5518ca1ddd --- /dev/null +++ b/progs/glsl/multitex.vert.txt @@ -0,0 +1,10 @@ +// Multi-texture vertex shader +// Brian Paul + + +void main() +{ + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[1] = gl_MultiTexCoord1; + gl_Position = ftransform(); +} diff --git a/progs/miniglx/Makefile b/progs/miniglx/Makefile index 5d0c8eae64..d5258b0a96 100644 --- a/progs/miniglx/Makefile +++ b/progs/miniglx/Makefile @@ -43,8 +43,8 @@ LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS default: depend $(PROGS) clean: - rm -f $(PROGS) - rm -f *.o + -rm -f $(PROGS) + -rm -f *.o depend: $(SOURCES) diff --git a/progs/slang/Makefile b/progs/slang/Makefile index ea1e9b6afd..c93caeab61 100644 --- a/progs/slang/Makefile +++ b/progs/slang/Makefile @@ -24,7 +24,7 @@ tests: default ! ./cltest 2> /dev/null | (grep -e ^[*][*][*]) clean: - rm -f cltest.o sotest.o vstest.o framework.o cltest sotest vstest + -rm -f cltest.o sotest.o vstest.o framework.o cltest sotest vstest # # executables diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 116a19b1f5..cf8e0bfc1e 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -99,9 +99,9 @@ UTIL_FILES = readtex.h readtex.c default: $(UTIL_FILES) $(PROGS) clean: - rm -f $(PROGS) - rm -f *.o - rm -f getproclist.h + -rm -f $(PROGS) + -rm -f *.o + -rm -f getproclist.h ##### RULES ##### diff --git a/progs/tests/fbotest2.c b/progs/tests/fbotest2.c index 18f28972b6..5283c7e1fd 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/mipmap_limits.c b/progs/tests/mipmap_limits.c index d6d6e467b0..8bdad826f7 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/trivial/Makefile b/progs/trivial/Makefile index 7610a5df08..6fa51ce2cf 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -102,9 +102,9 @@ UTIL_FILES = readtex.h readtex.c default: $(UTIL_FILES) $(PROGS) clean: - rm -f $(PROGS) - rm -f *.o - rm -f getproclist.h + -rm -f $(PROGS) + -rm -f *.o + -rm -f getproclist.h # auto code generation diff --git a/progs/trivial/tri.c b/progs/trivial/tri.c index 58a650b559..d4a7f08ae3 100644 --- a/progs/trivial/tri.c +++ b/progs/trivial/tri.c @@ -33,6 +33,7 @@ GLenum doubleBuffer; +int win; static void Init(void) { @@ -59,7 +60,8 @@ static void Key(unsigned char key, int x, int y) switch (key) { case 27: - exit(1); + glutDestroyWindow(win); + exit(0); default: return; } @@ -122,7 +124,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/vp/Makefile b/progs/vp/Makefile index 3349fd5342..28d63237a4 100644 --- a/progs/vp/Makefile +++ b/progs/vp/Makefile @@ -40,9 +40,9 @@ INCLUDES = -I. -I$(TOP)/include -I../samples default: $(PROGS) clean: - rm -f $(PROGS) - rm -f *.o - rm -f getproclist.h + -rm -f $(PROGS) + -rm -f *.o + -rm -f getproclist.h diff --git a/progs/xdemos/.gitignore b/progs/xdemos/.gitignore index 23e7c3ea18..868249db88 100644 --- a/progs/xdemos/.gitignore +++ b/progs/xdemos/.gitignore @@ -16,6 +16,7 @@ offset overlay pbdemo pbinfo +sharedtex texture_from_pixmap wincopy xdemo diff --git a/progs/xdemos/glthreads.c b/progs/xdemos/glthreads.c index e9c654c649..4f87ee75d4 100644 --- a/progs/xdemos/glthreads.c +++ b/progs/xdemos/glthreads.c @@ -24,6 +24,7 @@ * 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) * @@ -405,6 +406,19 @@ 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"); +} + int main(int argc, char *argv[]) @@ -416,9 +430,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; @@ -442,13 +454,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"); |