diff options
author | Ben Skeggs <[email protected]> | 2008-11-10 15:53:51 +1100 |
---|---|---|
committer | Ben Skeggs <[email protected]> | 2008-11-10 15:53:51 +1100 |
commit | 32e6be6362e44609d36c2fb20a4c858f57c908fb (patch) | |
tree | 4ed99e93ef5f4a8bb51653917c911e04e42f5235 /progs | |
parent | 92674bc8889e10e580c630cf85c106fa6eb34d7b (diff) | |
parent | 399da3a337932c6074a69ac73e711138271308eb (diff) |
Merge remote branch 'origin/gallium-0.2' into gallium-0.2
Diffstat (limited to 'progs')
-rw-r--r-- | progs/glsl/Makefile | 8 | ||||
-rw-r--r-- | progs/glsl/bump.c | 3 | ||||
-rw-r--r-- | progs/glsl/convolutions.c | 2 | ||||
-rw-r--r-- | progs/glsl/identity.c | 2 | ||||
-rw-r--r-- | progs/glsl/mandelbrot.c | 2 | ||||
-rw-r--r-- | progs/glsl/multitex.frag | 24 | ||||
-rw-r--r-- | progs/glsl/skinning.c | 280 | ||||
-rw-r--r-- | progs/glsl/skinning.frag | 6 | ||||
-rw-r--r-- | progs/glsl/skinning.vert | 24 | ||||
-rw-r--r-- | progs/glsl/toyball.c | 2 | ||||
-rw-r--r-- | progs/trivial/tri-stencil.c | 13 | ||||
-rw-r--r-- | progs/util/shaderutil.c | 1 | ||||
-rw-r--r-- | progs/vp/Makefile | 6 | ||||
-rw-r--r-- | progs/vp/exp.txt | 9 | ||||
-rw-r--r-- | progs/vp/log.txt | 9 | ||||
-rw-r--r-- | progs/vp/vp-tris.c | 3 | ||||
-rw-r--r-- | progs/xdemos/glxgears.c | 52 | ||||
-rw-r--r-- | progs/xdemos/glxswapcontrol.c | 91 |
18 files changed, 495 insertions, 42 deletions
diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 04c1d25ed7f..c5d62d2370d 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -21,6 +21,7 @@ PROGS = \ noise \ points \ pointcoord \ + skinning \ texdemo1 \ toyball \ twoside \ @@ -148,6 +149,13 @@ pointcoord: pointcoord.o readtex.o shaderutil.o $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) pointcoord.o readtex.o shaderutil.o $(LIBS) -o $@ +skinning.o: skinning.c readtex.h extfuncs.h shaderutil.h + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) skinning.c + +skinning: skinning.o readtex.o shaderutil.o + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) skinning.o readtex.o shaderutil.o $(LIBS) -o $@ + + texdemo1.o: texdemo1.c readtex.h extfuncs.h shaderutil.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c index a2e0916861c..b93ab44b5b9 100644 --- a/progs/glsl/bump.c +++ b/progs/glsl/bump.c @@ -141,9 +141,6 @@ Redisplay(void) glPopMatrix(); - glFinish(); - glFlush(); - CheckError(__LINE__); glutSwapBuffers(); diff --git a/progs/glsl/convolutions.c b/progs/glsl/convolutions.c index a25dad5ba92..ac71c68235e 100644 --- a/progs/glsl/convolutions.c +++ b/progs/glsl/convolutions.c @@ -439,8 +439,6 @@ static void draw() glPopMatrix(); - glFlush(); - glutSwapBuffers(); } diff --git a/progs/glsl/identity.c b/progs/glsl/identity.c index dce140fc640..37579eb3469 100644 --- a/progs/glsl/identity.c +++ b/progs/glsl/identity.c @@ -22,7 +22,7 @@ static GLuint fragShader; static GLuint vertShader; static GLuint program; static GLint win = 0; -static GLboolean anim = GL_TRUE; +static GLboolean anim = GL_FALSE; static GLfloat xRot = 0.0f, yRot = 0.0f; static int w,h; diff --git a/progs/glsl/mandelbrot.c b/progs/glsl/mandelbrot.c index e6361b429b3..24e19926655 100644 --- a/progs/glsl/mandelbrot.c +++ b/progs/glsl/mandelbrot.c @@ -74,8 +74,6 @@ Redisplay(void) glPopMatrix(); - glFinish(); - glFlush(); glutSwapBuffers(); } diff --git a/progs/glsl/multitex.frag b/progs/glsl/multitex.frag index a2633ceba75..61ef95f3fee 100644 --- a/progs/glsl/multitex.frag +++ b/progs/glsl/multitex.frag @@ -7,9 +7,29 @@ uniform sampler2D tex1; uniform sampler2D tex2; -void main() +vec4 sample(sampler2D t, vec2 coord) +{ + return texture2D(t, coord); +} + +void main0() { vec4 t1 = texture2D(tex1, gl_TexCoord[0].xy); - vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy); + //vec4 t1 = sample(tex1, gl_TexCoord[0].xy); + //vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy); + vec4 t2 = sample(tex2, gl_TexCoord[0].xy); gl_FragColor = mix(t1, t2, t2.w); } + +void main() +{ + vec4 t1 = sample(tex1, gl_TexCoord[0].xy); + vec4 t2 = sample(tex2, gl_TexCoord[0].xy); + gl_FragColor = t1 + t2; +} +/* + 0: MOV SAMPLER[0].x, SAMPLER[0]; + 1: MOV TEMP[1], INPUT[4]; + 2: TEX OUTPUT[0], TEMP[1], texture[0], 2D; + 3: END +*/ diff --git a/progs/glsl/skinning.c b/progs/glsl/skinning.c new file mode 100644 index 00000000000..8a65d0667ce --- /dev/null +++ b/progs/glsl/skinning.c @@ -0,0 +1,280 @@ +/** + * Vertex "skinning" example. + * The idea is there are multiple modeling matrices applied to every + * vertex. Weighting values in [0,1] control the influence of each + * matrix on each vertex. + * + * 4 Nov 2008 + */ + +#include <assert.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <GL/gl.h> +#include <GL/glut.h> +#include <GL/glext.h> +#include "extfuncs.h" +#include "shaderutil.h" + + +static char *FragProgFile = "skinning.frag"; +static char *VertProgFile = "skinning.vert"; + +/* program/shader objects */ +static GLuint fragShader; +static GLuint vertShader; +static GLuint program; + + +static GLint win = 0; +static GLboolean Anim = GL_TRUE; +static GLboolean WireFrame = GL_TRUE; +static GLfloat xRot = 0.0f, yRot = 90.0f, zRot = 0.0f; + +#define NUM_MATS 2 + +static GLfloat Matrices[NUM_MATS][16]; +static GLint uMat0, uMat1; +static GLint WeightAttr; + + +static void +Idle(void) +{ + yRot = 90 + glutGet(GLUT_ELAPSED_TIME) * 0.005; + glutPostRedisplay(); +} + + +static void +Cylinder(GLfloat length, GLfloat radius, GLint slices, GLint stacks) +{ + float dw = 1.0 / (stacks - 1); + float dz = length / stacks; + int i, j; + + for (j = 0; j < stacks; j++) { + float w0 = j * dw; + float z0 = j * dz; + + glBegin(GL_TRIANGLE_STRIP); + for (i = 0; i < slices; i++) { + float a = (float) i / (slices - 1) * M_PI * 2.0; + float x = radius * cos(a); + float y = radius * sin(a); + glVertexAttrib1f_func(WeightAttr, w0); + glNormal3f(x, y, 0.0); + glVertex3f(x, y, z0); + + glVertexAttrib1f_func(WeightAttr, w0 + dw); + glNormal3f(x, y, 0.0); + glVertex3f(x, y, z0 + dz); + } + glEnd(); + } +} + + +/** + * Update/animate the two matrices. One rotates, the other scales. + */ +static void +UpdateMatrices(void) +{ + GLfloat t = glutGet(GLUT_ELAPSED_TIME) * 0.0025; + GLfloat scale = 0.5 * (1.1 + sin(0.5 * t)); + GLfloat rot = cos(t) * 90.0; + + glPushMatrix(); + glLoadIdentity(); + glScalef(1.0, scale, 1.0); + glGetFloatv(GL_MODELVIEW_MATRIX, Matrices[0]); + glPopMatrix(); + + glPushMatrix(); + glLoadIdentity(); + glRotatef(rot, 0, 0, 1); + glGetFloatv(GL_MODELVIEW_MATRIX, Matrices[1]); + glPopMatrix(); +} + + +static void +Redisplay(void) +{ + UpdateMatrices(); + + glUniformMatrix4fv_func(uMat0, 1, GL_FALSE, Matrices[0]); + glUniformMatrix4fv_func(uMat1, 1, GL_FALSE, Matrices[1]); + + if (WireFrame) + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(xRot, 1.0f, 0.0f, 0.0f); + glRotatef(yRot, 0.0f, 1.0f, 0.0f); + glRotatef(zRot, 0.0f, 0.0f, 1.0f); + + glPushMatrix(); + glTranslatef(0, 0, -2.5); + Cylinder(5.0, 1.0, 10, 20); + glPopMatrix(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -15.0f); +} + + +static void +CleanUp(void) +{ + glDeleteShader_func(fragShader); + glDeleteShader_func(vertShader); + glDeleteProgram_func(program); + glutDestroyWindow(win); +} + + +static void +Key(unsigned char key, int x, int y) +{ + const GLfloat step = 2.0; + (void) x; + (void) y; + + switch(key) { + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'w': + WireFrame = !WireFrame; + break; + case 'z': + zRot += step; + break; + case 'Z': + zRot -= step; + break; + case 27: + CleanUp(); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +SpecialKey(int key, int x, int y) +{ + const 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(); +} + + + +static void +Init(void) +{ + if (!ShadersSupported()) + exit(1); + + GetExtensionFuncs(); + + vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile); + fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile); + program = LinkShaders(vertShader, fragShader); + + glUseProgram_func(program); + + uMat0 = glGetUniformLocation_func(program, "mat0"); + uMat1 = glGetUniformLocation_func(program, "mat1"); + + WeightAttr = glGetAttribLocation_func(program, "weight"); + + assert(glGetError() == 0); + + glClearColor(0.4f, 0.4f, 0.8f, 0.0f); + + glEnable(GL_DEPTH_TEST); + + glColor3f(1, 0, 0); +} + + +static void +ParseOptions(int argc, char *argv[]) +{ + int i; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-fs") == 0) { + FragProgFile = argv[i+1]; + } + else if (strcmp(argv[i], "-vs") == 0) { + VertProgFile = argv[i+1]; + } + } +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowSize(500, 500); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + win = glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Redisplay); + ParseOptions(argc, argv); + Init(); + if (Anim) + glutIdleFunc(Idle); + glutMainLoop(); + return 0; +} + diff --git a/progs/glsl/skinning.frag b/progs/glsl/skinning.frag new file mode 100644 index 00000000000..9053755a830 --- /dev/null +++ b/progs/glsl/skinning.frag @@ -0,0 +1,6 @@ +// color pass-through + +void main() +{ + gl_FragColor = gl_Color; +} diff --git a/progs/glsl/skinning.vert b/progs/glsl/skinning.vert new file mode 100644 index 00000000000..28970eee584 --- /dev/null +++ b/progs/glsl/skinning.vert @@ -0,0 +1,24 @@ +// Vertex weighting/blendin shader +// Brian Paul +// 4 Nov 2008 + +uniform mat4 mat0, mat1; +attribute float weight; + +void main() +{ + // simple diffuse shading + // Note that we should really transform the normal vector along with + // the postion below... someday. + vec3 lightVec = vec3(0, 0, 1); + vec3 norm = gl_NormalMatrix * gl_Normal; + float dot = 0.2 + max(0.0, dot(norm, lightVec)); + gl_FrontColor = vec4(dot); + + // compute sum of weighted transformations + vec4 pos0 = mat0 * gl_Vertex; + vec4 pos1 = mat1 * gl_Vertex; + vec4 pos = mix(pos0, pos1, weight); + + gl_Position = gl_ModelViewProjectionMatrix * pos; +} diff --git a/progs/glsl/toyball.c b/progs/glsl/toyball.c index 2daaedd6df8..37ad6bf2914 100644 --- a/progs/glsl/toyball.c +++ b/progs/glsl/toyball.c @@ -79,8 +79,6 @@ Redisplay(void) glPopMatrix(); - glFinish(); - glFlush(); glutSwapBuffers(); } diff --git a/progs/trivial/tri-stencil.c b/progs/trivial/tri-stencil.c index 5edbef26ced..7686e16aef1 100644 --- a/progs/trivial/tri-stencil.c +++ b/progs/trivial/tri-stencil.c @@ -49,7 +49,15 @@ static void Key(unsigned char key, int x, int y) switch (key) { case 27: + printf("Exiting...\n"); exit(1); + case 'r': + printf("Redisplaying...\n"); + glutPostRedisplay(); + break; + default: + printf("No such key '%c'...\n", key); + break; } } @@ -89,7 +97,7 @@ static void Draw(void) glEnd(); #endif -#if 0 +#if 1 glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); @@ -130,7 +138,8 @@ int main(int argc, char **argv) exit(1); } - glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + glutInitWindowPosition(0, 0); + glutInitWindowSize( 300, 300); type = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH | GLUT_STENCIL; glutInitDisplayMode(type); diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c index 4f17dd7efa1..745851395a7 100644 --- a/progs/util/shaderutil.c +++ b/progs/util/shaderutil.c @@ -80,6 +80,7 @@ CompileShaderFile(GLenum shaderType, const char *filename) FILE *f = fopen(filename, "r"); if (!f) { + fprintf(stderr, "Unable to open shader file %s\n", filename); return 0; } diff --git a/progs/vp/Makefile b/progs/vp/Makefile index 28d63237a45..41d025c5746 100644 --- a/progs/vp/Makefile +++ b/progs/vp/Makefile @@ -26,13 +26,13 @@ INCLUDES = -I. -I$(TOP)/include -I../samples .SUFFIXES: .c .c: - $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ + $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ .c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ .S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ ##### TARGETS ##### diff --git a/progs/vp/exp.txt b/progs/vp/exp.txt index 601aae7d715..53ce71db965 100644 --- a/progs/vp/exp.txt +++ b/progs/vp/exp.txt @@ -1,5 +1,6 @@ -!!VP1.0 -EXP R0, v[COL0].x; -ADD o[COL0], R0.z, -R0.w; -MOV o[HPOS], v[OPOS]; +!!ARBvp1.0 +TEMP R0; +EXP R0, vertex.color.x; +SUB result.color, R0.z, R0.w; +MOV result.position, vertex.position; END diff --git a/progs/vp/log.txt b/progs/vp/log.txt index 9b042684335..6b4e94ed0ed 100644 --- a/progs/vp/log.txt +++ b/progs/vp/log.txt @@ -1,6 +1,7 @@ -!!VP1.0 -ADD R0, v[COL0], v[COL0]; +!!ARBvp1.0 +TEMP R0; +ADD R0, vertex.color, vertex.color; ADD R0, R0, R0; -LOG o[COL0], R0.x; -MOV o[HPOS], v[OPOS]; +LOG result.color, R0.x; +MOV result.position, vertex.position; END diff --git a/progs/vp/vp-tris.c b/progs/vp/vp-tris.c index 58014dd48de..e1ddb2e14d2 100644 --- a/progs/vp/vp-tris.c +++ b/progs/vp/vp-tris.c @@ -5,7 +5,6 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#include <GL/glut.h> #ifndef WIN32 #include <unistd.h> @@ -15,6 +14,8 @@ #include <GL/glext.h> #endif +#include <GL/glut.h> + #ifdef WIN32 static PFNGLBINDPROGRAMARBPROC glBindProgramARB = NULL; static PFNGLGENPROGRAMSARBPROC glGenProgramsARB = NULL; diff --git a/progs/xdemos/glxgears.c b/progs/xdemos/glxgears.c index c98c3157b5d..8db717f1aa3 100644 --- a/progs/xdemos/glxgears.c +++ b/progs/xdemos/glxgears.c @@ -419,6 +419,52 @@ init(void) } +/** + * Remove window border/decorations. + */ +static void +no_border( Display *dpy, Window w) +{ + static const unsigned MWM_HINTS_DECORATIONS = (1 << 1); + static const int PROP_MOTIF_WM_HINTS_ELEMENTS = 5; + + typedef struct + { + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long inputMode; + unsigned long status; + } PropMotifWmHints; + + PropMotifWmHints motif_hints; + Atom prop, proptype; + unsigned long flags = 0; + + /* setup the property */ + motif_hints.flags = MWM_HINTS_DECORATIONS; + motif_hints.decorations = flags; + + /* get the atom for the property */ + prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True ); + if (!prop) { + /* something went wrong! */ + return; + } + + /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */ + proptype = prop; + + XChangeProperty( dpy, w, /* display, window */ + prop, proptype, /* property, type */ + 32, /* format: 32-bit datums */ + PropModeReplace, /* mode */ + (unsigned char *) &motif_hints, /* data */ + PROP_MOTIF_WM_HINTS_ELEMENTS /* nelements */ + ); +} + + /* * Create an RGB, double-buffered window. * Return the window and context handles. @@ -479,13 +525,15 @@ make_window( Display *dpy, const char *name, attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; /* XXX this is a bad way to get a borderless window! */ - attr.override_redirect = fullscreen; - mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow( dpy, root, x, y, width, height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr ); + if (fullscreen) + no_border(dpy, win); + /* set hints and properties */ { XSizeHints sizehints; diff --git a/progs/xdemos/glxswapcontrol.c b/progs/xdemos/glxswapcontrol.c index e429d58ecc4..2c518019896 100644 --- a/progs/xdemos/glxswapcontrol.c +++ b/progs/xdemos/glxswapcontrol.c @@ -121,7 +121,7 @@ static char ** extension_table = NULL; static unsigned num_extensions; static GLboolean use_ztrick = GL_FALSE; -static GLfloat aspect; +static GLfloat aspectX = 1.0f, aspectY = 1.0f; /* * @@ -313,13 +313,13 @@ draw(void) glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 60.0); + glFrustum(-aspectX, aspectX, -aspectY, aspectY, 5.0, 60.0); glEnable(GL_LIGHTING); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef(0.0, 0.0, -40.0); + glTranslatef(0.0, 0.0, -45.0); } else { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -356,17 +356,23 @@ draw(void) static void reshape(int width, int height) { - aspect = (GLfloat) height / (GLfloat) width; + if (width > height) { + aspectX = (GLfloat) width / (GLfloat) height; + aspectY = 1.0; + } + else { + aspectX = 1.0; + aspectY = (GLfloat) height / (GLfloat) width; + } - glViewport(0, 0, (GLint) width, (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 60.0); + glFrustum(-aspectX, aspectX, -aspectY, aspectY, 5.0, 60.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef(0.0, 0.0, -40.0); + glTranslatef(0.0, 0.0, -45.0); } @@ -407,13 +413,59 @@ init(void) } +/** + * Remove window border/decorations. + */ +static void +no_border( Display *dpy, Window w) +{ + static const unsigned MWM_HINTS_DECORATIONS = (1 << 1); + static const int PROP_MOTIF_WM_HINTS_ELEMENTS = 5; + + typedef struct + { + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long inputMode; + unsigned long status; + } PropMotifWmHints; + + PropMotifWmHints motif_hints; + Atom prop, proptype; + unsigned long flags = 0; + + /* setup the property */ + motif_hints.flags = MWM_HINTS_DECORATIONS; + motif_hints.decorations = flags; + + /* get the atom for the property */ + prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True ); + if (!prop) { + /* something went wrong! */ + return; + } + + /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */ + proptype = prop; + + XChangeProperty( dpy, w, /* display, window */ + prop, proptype, /* property, type */ + 32, /* format: 32-bit datums */ + PropModeReplace, /* mode */ + (unsigned char *) &motif_hints, /* data */ + PROP_MOTIF_WM_HINTS_ELEMENTS /* nelements */ + ); +} + + /* * Create an RGB, double-buffered window. * Return the window and context handles. */ static void make_window( Display *dpy, const char *name, - int x, int y, int width, int height, + int x, int y, int width, int height, GLboolean fullscreen, Window *winRet, GLXContext *ctxRet) { int attrib[] = { GLX_RGBA, @@ -434,6 +486,12 @@ make_window( Display *dpy, const char *name, scrnum = DefaultScreen( dpy ); root = RootWindow( dpy, scrnum ); + if (fullscreen) { + x = y = 0; + width = DisplayWidth( dpy, scrnum ); + height = DisplayHeight( dpy, scrnum ); + } + visinfo = glXChooseVisual( dpy, scrnum, attrib ); if (!visinfo) { printf("Error: couldn't get an RGB, Double-buffered visual\n"); @@ -464,6 +522,9 @@ make_window( Display *dpy, const char *name, None, (char **)NULL, 0, &sizehints); } + if (fullscreen) + no_border(dpy, win); + ctx = glXCreateContext( dpy, visinfo, NULL, True ); if (!ctx) { printf("Error: glXCreateContext failed\n"); @@ -572,7 +633,6 @@ event_loop(Display *dpy, Window win) * Display the refresh rate of the display using the GLX_OML_sync_control * extension. */ - static void show_refresh_rate( Display * dpy ) { @@ -599,7 +659,6 @@ show_refresh_rate( Display * dpy ) * \param string String of GLX extensions. * \sa is_extension_supported */ - static void make_extension_table( const char * string ) { @@ -679,7 +738,6 @@ make_extension_table( const char * string ) * \return GL_TRUE of the extension is supported, GL_FALSE otherwise. * \sa make_extension_table */ - static GLboolean is_extension_supported( const char * ext ) { @@ -705,11 +763,12 @@ main(int argc, char *argv[]) int swap_interval = 1; GLboolean do_swap_interval = GL_FALSE; GLboolean force_get_rate = GL_FALSE; + GLboolean fullscreen = GL_FALSE; GLboolean printInfo = GL_FALSE; int i; PFNGLXSWAPINTERVALMESAPROC set_swap_interval = NULL; PFNGLXGETSWAPINTERVALMESAPROC get_swap_interval = NULL; - + int width = 300, height = 300; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) { @@ -731,6 +790,9 @@ main(int argc, char *argv[]) */ force_get_rate = GL_TRUE; } + else if (strcmp(argv[i], "-fullscreen") == 0) { + fullscreen = GL_TRUE; + } else if (strcmp(argv[i], "-ztrick") == 0) { use_ztrick = GL_TRUE; } @@ -743,6 +805,7 @@ main(int argc, char *argv[]) printf(" -info Display GL information\n"); printf(" -swap N Swap no more than once per N vertical refreshes\n"); printf(" -forcegetrate Try to use glXGetMscRateOML function\n"); + printf(" -fullscreen Full-screen window\n"); return 0; } } @@ -753,7 +816,7 @@ main(int argc, char *argv[]) return -1; } - make_window(dpy, "glxgears", 0, 0, 300, 300, &win, &ctx); + make_window(dpy, "glxgears", 0, 0, width, height, fullscreen, &win, &ctx); XMapWindow(dpy, win); glXMakeCurrent(dpy, win, ctx); @@ -817,7 +880,7 @@ main(int argc, char *argv[]) /* Set initial projection/viewing transformation. * same as glxgears.c */ - reshape(300, 300); + reshape(width, height); event_loop(dpy, win); |