From d19d0596daf004b56d80f78fa1a329b43c2ebf94 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Thu, 21 Jun 2007 10:22:28 +0800 Subject: support branch and loop in pixel shader most of the sample working with some small modification --- progs/glsl/CH06-brick.frag.txt | 6 +++++- progs/glsl/CH11-bumpmap.frag.txt | 2 +- progs/glsl/CH11-bumpmap.vert.txt | 9 +++++---- progs/glsl/CH11-toyball.frag.txt | 7 ++++--- progs/glsl/CH11-toyball.vert.txt | 7 ++++--- 5 files changed, 19 insertions(+), 12 deletions(-) (limited to 'progs') diff --git a/progs/glsl/CH06-brick.frag.txt b/progs/glsl/CH06-brick.frag.txt index 06ef04e3af..388c5f9e66 100644 --- a/progs/glsl/CH06-brick.frag.txt +++ b/progs/glsl/CH06-brick.frag.txt @@ -23,7 +23,11 @@ void main() position = MCposition / BrickSize; - if (fract(position.y * 0.5) > 0.5) +// if (fract(position.y * 0.5) > 0.5) +// position.x += 0.5; + float tmp; + tmp = fract(position.y * 0.5); + if (tmp > 0.5) position.x += 0.5; position = fract(position); diff --git a/progs/glsl/CH11-bumpmap.frag.txt b/progs/glsl/CH11-bumpmap.frag.txt index 063576f5a3..1467f767ec 100644 --- a/progs/glsl/CH11-bumpmap.frag.txt +++ b/progs/glsl/CH11-bumpmap.frag.txt @@ -33,7 +33,7 @@ void main() litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0); vec3 reflectDir = reflect(LightDir, normDelta); - float spec = max(dot(EyeDir, reflectDir), 0.0); + float spec = max(dot(normalize(EyeDir), reflectDir), 0.0); spec *= SpecularFactor; litColor = min(litColor + spec, vec3(1.0)); diff --git a/progs/glsl/CH11-bumpmap.vert.txt b/progs/glsl/CH11-bumpmap.vert.txt index d3d19f62ac..55cf43ba7d 100644 --- a/progs/glsl/CH11-bumpmap.vert.txt +++ b/progs/glsl/CH11-bumpmap.vert.txt @@ -31,8 +31,9 @@ void main() v.z = dot(LightPosition, n); LightDir = normalize(v); - v.x = dot(EyeDir, t); - v.y = dot(EyeDir, b); - v.z = dot(EyeDir, n); - EyeDir = normalize(v); +/* v.x = dot(EyeDir, t); + v.y = dot(EyeDir, b); + v.z = dot(EyeDir, n); + EyeDir = normalize(EyeDir); +*/ } diff --git a/progs/glsl/CH11-toyball.frag.txt b/progs/glsl/CH11-toyball.frag.txt index 90ec1c27fc..f3cac62fb3 100644 --- a/progs/glsl/CH11-toyball.frag.txt +++ b/progs/glsl/CH11-toyball.frag.txt @@ -49,14 +49,15 @@ void main() inorout += dot(distance, vec4(1.0)); distance.x = dot(p, HalfSpace4); - distance.y = StripeWidth - abs(p.z); +// distance.y = StripeWidth - abs(p.z); + distance.y = StripeWidth - abs(p.y); distance = smoothstep(-FWidth, FWidth, distance); inorout += distance.x; inorout = clamp(inorout, 0.0, 1.0); - surfColor = mix(Yellow, Red, inorout); - surfColor = mix(surfColor, Blue, distance.y); + surfColor = mix(Yellow, Blue, distance.y); + surfColor = mix(surfColor, Red, inorout); // normal = point on surface for sphere at (0,0,0) normal = p; diff --git a/progs/glsl/CH11-toyball.vert.txt b/progs/glsl/CH11-toyball.vert.txt index b7da3ac839..a3ee1b0377 100644 --- a/progs/glsl/CH11-toyball.vert.txt +++ b/progs/glsl/CH11-toyball.vert.txt @@ -14,10 +14,11 @@ uniform vec4 BallCenter; // ball center in modelling coordinates void main() { -//orig: ECposition = gl_ModelViewMatrix * gl_Vertex; + ECposition = gl_ModelViewMatrix * gl_Vertex; - ECposition = gl_TextureMatrix[0] * gl_Vertex; - ECposition = gl_ModelViewMatrix * ECposition; +// ECposition = gl_TextureMatrix[0] * gl_Vertex; +// ECposition = gl_MultiTexCoord0 * gl_Vertex; +// ECposition = gl_ModelViewMatrix * ECposition; ECballCenter = gl_ModelViewMatrix * BallCenter; gl_Position = ftransform(); -- cgit v1.2.3 From 24e7acd5e4f1e7e71909f94fd1f075abd268d086 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Tue, 17 Jul 2007 11:25:37 +0800 Subject: bumpmap sample is correct now --- progs/glsl/CH11-bumpmap.frag.txt | 2 +- progs/glsl/CH11-bumpmap.vert.txt | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'progs') diff --git a/progs/glsl/CH11-bumpmap.frag.txt b/progs/glsl/CH11-bumpmap.frag.txt index 1467f767ec..063576f5a3 100644 --- a/progs/glsl/CH11-bumpmap.frag.txt +++ b/progs/glsl/CH11-bumpmap.frag.txt @@ -33,7 +33,7 @@ void main() litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0); vec3 reflectDir = reflect(LightDir, normDelta); - float spec = max(dot(normalize(EyeDir), reflectDir), 0.0); + float spec = max(dot(EyeDir, reflectDir), 0.0); spec *= SpecularFactor; litColor = min(litColor + spec, vec3(1.0)); diff --git a/progs/glsl/CH11-bumpmap.vert.txt b/progs/glsl/CH11-bumpmap.vert.txt index 55cf43ba7d..d3d19f62ac 100644 --- a/progs/glsl/CH11-bumpmap.vert.txt +++ b/progs/glsl/CH11-bumpmap.vert.txt @@ -31,9 +31,8 @@ void main() v.z = dot(LightPosition, n); LightDir = normalize(v); -/* v.x = dot(EyeDir, t); - v.y = dot(EyeDir, b); - v.z = dot(EyeDir, n); - EyeDir = normalize(EyeDir); -*/ + v.x = dot(EyeDir, t); + v.y = dot(EyeDir, b); + v.z = dot(EyeDir, n); + EyeDir = normalize(v); } -- cgit v1.2.3 From c6d042acc94411b63f922ef68f24aa5426c0a69e Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Tue, 17 Jul 2007 16:52:03 +0800 Subject: Fix SOP in fragment shader, brick is ok now. --- progs/glsl/CH06-brick.frag.txt | 6 +----- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 6 ++++-- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'progs') diff --git a/progs/glsl/CH06-brick.frag.txt b/progs/glsl/CH06-brick.frag.txt index 388c5f9e66..06ef04e3af 100644 --- a/progs/glsl/CH06-brick.frag.txt +++ b/progs/glsl/CH06-brick.frag.txt @@ -23,11 +23,7 @@ void main() position = MCposition / BrickSize; -// if (fract(position.y * 0.5) > 0.5) -// position.x += 0.5; - float tmp; - tmp = fract(position.y * 0.5); - if (tmp > 0.5) + if (fract(position.y * 0.5) > 0.5) position.x += 0.5; position = fract(position); diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 4988df2b0e..09e7590367 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -811,18 +811,20 @@ static void emit_sop(struct brw_wm_compile *c, struct brw_reg dst, src0, src1; int i; + brw_push_insn_state(p); for (i = 0; i < 4; i++) { if (mask & (1<SrcReg[0], i, 1); src1 = get_src_reg(c, &inst->SrcReg[1], i, 1); - brw_MOV(p, dst, brw_imm_f(0)); brw_CMP(p, brw_null_reg(), cond, src0, src1); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_MOV(p, dst, brw_imm_f(0.0)); brw_set_predicate_control(p, BRW_PREDICATE_NORMAL); brw_MOV(p, dst, brw_imm_f(1.0)); - brw_set_predicate_control_flag_value(p, 0xff); } } + brw_pop_insn_state(p); } static void emit_slt(struct brw_wm_compile *c, -- cgit v1.2.3 From b182613f2f537e4425190ab942bb057eeed3ac16 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Sat, 29 Sep 2007 11:23:22 -0700 Subject: Ignore more generated files in progs/ Many of the directories in progs/ were missing .gitignore files or were tracking generated files. This patch is basically the process of running `make' in each directory and then finding the untracked files with `git-ls-files -o --exclude-per-directory=.gitignore'. The existing files were also sorted. --- progs/beos/.gitignore | 3 ++ progs/demos/.gitignore | 2 +- progs/directfb/.gitignore | 4 +++ progs/egl/.gitignore | 5 ++++ progs/fbdev/.gitignore | 1 + progs/fp/.gitignore | 42 ++++++++++++++++++++++++++++ progs/glsl/.gitignore | 10 +++++++ progs/miniglx/.gitignore | 6 ++++ progs/osdemos/.gitignore | 8 ++++++ progs/samples/.gitignore | 32 ++++++++++++---------- progs/slang/.gitignore | 3 ++ progs/tests/.gitignore | 6 ++-- progs/tools/trace/.gitignore | 1 + progs/trivial/.gitignore | 65 ++++++++++++++++++++++++++++++++++++++++++++ progs/vp/.gitignore | 1 + progs/xdemos/.gitignore | 4 +-- 16 files changed, 172 insertions(+), 21 deletions(-) create mode 100644 progs/beos/.gitignore create mode 100644 progs/directfb/.gitignore create mode 100644 progs/egl/.gitignore create mode 100644 progs/fbdev/.gitignore create mode 100644 progs/fp/.gitignore create mode 100644 progs/glsl/.gitignore create mode 100644 progs/miniglx/.gitignore create mode 100644 progs/osdemos/.gitignore create mode 100644 progs/slang/.gitignore create mode 100644 progs/tools/trace/.gitignore create mode 100644 progs/trivial/.gitignore create mode 100644 progs/vp/.gitignore (limited to 'progs') diff --git a/progs/beos/.gitignore b/progs/beos/.gitignore new file mode 100644 index 0000000000..53011ca2e6 --- /dev/null +++ b/progs/beos/.gitignore @@ -0,0 +1,3 @@ +demo +GLInfo +sample diff --git a/progs/demos/.gitignore b/progs/demos/.gitignore index 508b8a56f4..9c5957602c 100644 --- a/progs/demos/.gitignore +++ b/progs/demos/.gitignore @@ -41,8 +41,8 @@ shadowtex showbuffer.c showbuffer.h singlebuffer -spriteblast spectex +spriteblast stex3d streaming_rect teapot diff --git a/progs/directfb/.gitignore b/progs/directfb/.gitignore new file mode 100644 index 0000000000..55d65fb5b0 --- /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 0000000000..1751108235 --- /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 0000000000..b9ddf559fd --- /dev/null +++ b/progs/fbdev/.gitignore @@ -0,0 +1 @@ +glfbdevtest diff --git a/progs/fp/.gitignore b/progs/fp/.gitignore new file mode 100644 index 0000000000..b265f1fed7 --- /dev/null +++ b/progs/fp/.gitignore @@ -0,0 +1,42 @@ +point-position +readtex.c +readtex.h +tri-abs +tri-add +tri-cmp +tri-cos +tri-depth +tri-depth2 +tri-depthwrite +tri-depthwrite2 +tri-dp3 +tri-dp4 +tri-dph +tri-dst +tri-ex2 +tri-flr +tri-frc +tri-kil +tri-lg2 +tri-lit +tri-lrp +tri-mad +tri-max +tri-min +tri-mov +tri-mul +tri-param +tri-position +tri-pow +tri-rcp +tri-rsq +tri-scs +tri-sge +tri-sge2 +tri-sin +tri-slt +tri-sub +tri-swz +tri-swz2 +tri-tex +tri-xpd diff --git a/progs/glsl/.gitignore b/progs/glsl/.gitignore new file mode 100644 index 0000000000..622e0417a8 --- /dev/null +++ b/progs/glsl/.gitignore @@ -0,0 +1,10 @@ +brick +bump +deriv +extfuncs.h +mandelbrot +noise +readtex.c +readtex.h +texdemo1 +toyball diff --git a/progs/miniglx/.gitignore b/progs/miniglx/.gitignore new file mode 100644 index 0000000000..f630f591f6 --- /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 0000000000..5c78f12481 --- /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 12b0650567..f60d6e94ea 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,18 +45,3 @@ stretch texture tri wave -bugger -pend -lthreads -lxdemo -lxgears -lxheads -lxinfo -lxpixmap -anywin -ffset -bdemo -binfo -incopy -demo -font diff --git a/progs/slang/.gitignore b/progs/slang/.gitignore new file mode 100644 index 0000000000..8a42b018e6 --- /dev/null +++ b/progs/slang/.gitignore @@ -0,0 +1,3 @@ +cltest +sotest +vstest diff --git a/progs/tests/.gitignore b/progs/tests/.gitignore index cb3e09d5d5..eaa67c3a5d 100644 --- a/progs/tests/.gitignore +++ b/progs/tests/.gitignore @@ -1,5 +1,4 @@ .cvsignore -getproclist.h afsmultiarb antialias arbfpspec @@ -34,17 +33,18 @@ fogcoord fptest1 fptexture getprocaddress -jkrahntest +getproclist.h interleave invert +jkrahntest manytex mipmap_limits multipal no_s3tc packedpixels pbo -projtex prog_parameter +projtex random readrate readtex.c diff --git a/progs/tools/trace/.gitignore b/progs/tools/trace/.gitignore new file mode 100644 index 0000000000..afe0c5829e --- /dev/null +++ b/progs/tools/trace/.gitignore @@ -0,0 +1 @@ +gltrace.cc diff --git a/progs/trivial/.gitignore b/progs/trivial/.gitignore new file mode 100644 index 0000000000..1c49fdd55f --- /dev/null +++ b/progs/trivial/.gitignore @@ -0,0 +1,65 @@ +clear +dlist-dangling +dlist-edgeflag +dlist-edgeflag-dangling +drawarrays +drawelements +drawrange +line +line-clip +line-cull +line-userclip +line-userclip-clip +line-userclip-nop +line-userclip-nop-clip +lineloop +lineloop-clip +point +point-clip +point-param +point-wide +poly +poly-flat +poly-unfilled +quad +quad-clip +quad-clip-all-vertices +quad-clip-nearplane +quad-degenerate +quad-flat +quad-offset-factor +quad-offset-unfilled +quad-offset-units +quad-tex-2d +quad-tex-3d +quad-tex-pbo +quad-unfilled +quads +quadstrip +quadstrip-flat +readtex.c +readtex.h +tri +tri-blend +tri-clip +tri-cull +tri-dlist +tri-edgeflag +tri-flat +tri-flat-clip +tri-tex-3d +tri-unfilled +tri-unfilled-clip +tri-unfilled-smooth +tri-unfilled-userclip +tri-userclip +tristrip +tristrip-clip +vbo-drawarrays +vbo-drawelements +vbo-drawrange +vp-array +vp-clip +vp-line-clip +vp-tri +vp-unfilled diff --git a/progs/vp/.gitignore b/progs/vp/.gitignore new file mode 100644 index 0000000000..a5ff993525 --- /dev/null +++ b/progs/vp/.gitignore @@ -0,0 +1 @@ +vp-tris diff --git a/progs/xdemos/.gitignore b/progs/xdemos/.gitignore index f959ef26ec..250bc17d98 100644 --- a/progs/xdemos/.gitignore +++ b/progs/xdemos/.gitignore @@ -5,14 +5,14 @@ glxgears glxgears_fbconfig glxheads glxinfo -glxpixmap glxpbdemo +glxpixmap glxswapcontrol manywin offset overlay -pbinfo pbdemo +pbinfo texture_from_pixmap wincopy xdemo -- cgit v1.2.3 From 03ff9c96bf73b53c6c95f2db0aa79cfb1ff9eb3b Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 10 Oct 2007 10:56:48 -0600 Subject: replace 'brick' with correct program name in printfs --- progs/glsl/bump.c | 6 +++--- progs/glsl/mandelbrot.c | 6 +++--- progs/glsl/noise.c | 2 +- progs/glsl/toyball.c | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'progs') diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c index a6846acf7e..11f87ab127 100644 --- a/progs/glsl/bump.c +++ b/progs/glsl/bump.c @@ -247,7 +247,7 @@ LoadAndCompileShader(GLuint shader, const char *text) GLchar log[1000]; GLsizei len; glGetShaderInfoLog_func(shader, 1000, &len, log); - fprintf(stderr, "brick: problem compiling shader: %s\n", log); + fprintf(stderr, "bump: problem compiling shader: %s\n", log); exit(1); } else { @@ -267,12 +267,12 @@ ReadShader(GLuint shader, const char *filename) char *buffer = (char*) malloc(max); FILE *f = fopen(filename, "r"); if (!f) { - fprintf(stderr, "brick: Unable to open shader file %s\n", filename); + fprintf(stderr, "bump: Unable to open shader file %s\n", filename); exit(1); } n = fread(buffer, 1, max, f); - printf("brick: read %d bytes from shader file %s\n", n, filename); + printf("bump: read %d bytes from shader file %s\n", n, filename); if (n > 0) { buffer[n] = 0; LoadAndCompileShader(shader, buffer); diff --git a/progs/glsl/mandelbrot.c b/progs/glsl/mandelbrot.c index 7a2bad6dde..e7b2b04b0d 100644 --- a/progs/glsl/mandelbrot.c +++ b/progs/glsl/mandelbrot.c @@ -172,7 +172,7 @@ LoadAndCompileShader(GLuint shader, const char *text) GLchar log[1000]; GLsizei len; glGetShaderInfoLog_func(shader, 1000, &len, log); - fprintf(stderr, "brick: problem compiling shader: %s\n", log); + fprintf(stderr, "mandelbrot: problem compiling shader: %s\n", log); exit(1); } else { @@ -192,12 +192,12 @@ ReadShader(GLuint shader, const char *filename) char *buffer = (char*) malloc(max); FILE *f = fopen(filename, "r"); if (!f) { - fprintf(stderr, "brick: Unable to open shader file %s\n", filename); + fprintf(stderr, "mandelbrot: Unable to open shader file %s\n", filename); exit(1); } n = fread(buffer, 1, max, f); - printf("brick: read %d bytes from shader file %s\n", n, filename); + printf("mandelbrot: read %d bytes from shader file %s\n", n, filename); if (n > 0) { buffer[n] = 0; LoadAndCompileShader(shader, buffer); diff --git a/progs/glsl/noise.c b/progs/glsl/noise.c index a26a805944..adccd1a7c8 100644 --- a/progs/glsl/noise.c +++ b/progs/glsl/noise.c @@ -188,7 +188,7 @@ LoadAndCompileShader(GLuint shader, const char *text) GLchar log[1000]; GLsizei len; glGetShaderInfoLog_func(shader, 1000, &len, log); - fprintf(stderr, "brick: problem compiling shader: %s\n", log); + fprintf(stderr, "noise: problem compiling shader: %s\n", log); exit(1); } else { diff --git a/progs/glsl/toyball.c b/progs/glsl/toyball.c index cef52c04a6..3aa096161a 100644 --- a/progs/glsl/toyball.c +++ b/progs/glsl/toyball.c @@ -185,7 +185,7 @@ LoadAndCompileShader(GLuint shader, const char *text) GLchar log[1000]; GLsizei len; glGetShaderInfoLog_func(shader, 1000, &len, log); - fprintf(stderr, "brick: problem compiling shader: %s\n", log); + fprintf(stderr, "toyball: problem compiling shader: %s\n", log); exit(1); } else { @@ -205,12 +205,12 @@ ReadShader(GLuint shader, const char *filename) char *buffer = (char*) malloc(max); FILE *f = fopen(filename, "r"); if (!f) { - fprintf(stderr, "brick: Unable to open shader file %s\n", filename); + fprintf(stderr, "toyball: Unable to open shader file %s\n", filename); exit(1); } n = fread(buffer, 1, max, f); - printf("brick: read %d bytes from shader file %s\n", n, filename); + printf("toyball: read %d bytes from shader file %s\n", n, filename); if (n > 0) { buffer[n] = 0; LoadAndCompileShader(shader, buffer); -- cgit v1.2.3 From f1104b079f7992f60925fc6c08544cb8ab3cade4 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 11 Oct 2007 16:39:02 -0600 Subject: New glxsnoop demo to display another window's z/stencil/back buffer. --- progs/xdemos/Makefile | 1 + progs/xdemos/glxsnoop.c | 377 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 378 insertions(+) create mode 100644 progs/xdemos/glxsnoop.c (limited to 'progs') diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile index c585026ad3..4c4ecac38a 100644 --- a/progs/xdemos/Makefile +++ b/progs/xdemos/Makefile @@ -17,6 +17,7 @@ PROGS = glthreads \ glxinfo \ glxpixmap \ glxpbdemo \ + glxsnoop \ glxswapcontrol \ manywin \ offset \ diff --git a/progs/xdemos/glxsnoop.c b/progs/xdemos/glxsnoop.c new file mode 100644 index 0000000000..2e951345b5 --- /dev/null +++ b/progs/xdemos/glxsnoop.c @@ -0,0 +1,377 @@ +/** + * Display/snoop the z/stencil/back/front buffers of another app's window. + * Also, an example of the need for shared ancillary renderbuffers. + * + * Hint: use 'xwininfo' to get a window's ID. + * + * Brian Paul + * 11 Oct 2007 + */ + +#define GL_GLEXT_PROTOTYPES + +#include +#include +#include +#include +#include +#include + + +#define Z_BUFFER 1 +#define STENCIL_BUFFER 2 +#define BACK_BUFFER 3 +#define FRONT_BUFFER 4 + + +static int Buffer = BACK_BUFFER; +static int WindowID = 0; +static const char *DisplayName = NULL; +static GLXContext Context = 0; +static int Width, Height; + + +/** + * Grab the z/stencil/back/front image from the srcWin and display it + * (possibly converted to grayscale) in the dstWin. + */ +static void +redraw(Display *dpy, Window srcWin, Window dstWin ) +{ + GLubyte *image = malloc(Width * Height * 4); + + glXMakeCurrent(dpy, srcWin, Context); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + if (Buffer == BACK_BUFFER) { + glReadBuffer(GL_BACK); + glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, image); + } + else if (Buffer == FRONT_BUFFER) { + glReadBuffer(GL_FRONT); + glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, image); + } + else if (Buffer == Z_BUFFER) { + GLfloat *z = malloc(Width * Height * sizeof(GLfloat)); + int i; + glReadPixels(0, 0, Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, z); + for (i = 0; i < Width * Height; i++) { + image[i*4+0] = + image[i*4+1] = + image[i*4+2] = (GLint) (255.0 * z[i]); + image[i*4+3] = 255; + } + free(z); + } + else if (Buffer == STENCIL_BUFFER) { + GLubyte *sten = malloc(Width * Height * sizeof(GLubyte)); + int i, min = 100, max = -1; + float step; + int sz; + glGetIntegerv(GL_STENCIL_BITS, &sz); + glReadPixels(0, 0, Width, Height, + GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, sten); + /* find min/max for converting stencil to grayscale */ + for (i = 0; i < Width * Height; i++) { + if (sten[i] < min) + min = sten[i]; + if (sten[i] > max) + max = sten[i]; + } + if (min == max) + step = 0; + else + step = 255.0 / (float) (max - min); + for (i = 0; i < Width * Height; i++) { + image[i*4+0] = + image[i*4+1] = + image[i*4+2] = (GLint) ((sten[i] - min) * step); + image[i*4+3] = 255; + } + free(sten); + } + + glXMakeCurrent(dpy, dstWin, Context); + glWindowPos2iARB(0, 0); + glDrawBuffer(GL_FRONT); + glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, image); + glFlush(); + + free(image); +} + + +static void +set_window_title(Display *dpy, Window win, const char *title) +{ + XSizeHints sizehints; + sizehints.flags = 0; + XSetStandardProperties(dpy, win, title, title, + None, (char **)NULL, 0, &sizehints); +} + + +static Window +make_gl_window(Display *dpy, XVisualInfo *visinfo, int width, int height) +{ + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + int x = 0, y = 0; + char *name = NULL; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( dpy, root, x, y, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(dpy, win, &sizehints); + XSetStandardProperties(dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + return win; +} + + +static void +update_window_title(Display *dpy, Window win) +{ + char title[1000], *buf; + + switch (Buffer) { + case Z_BUFFER: + buf = "Z"; + break; + case STENCIL_BUFFER: + buf = "Stencil"; + break; + case BACK_BUFFER: + buf = "Back"; + break; + case FRONT_BUFFER: + buf = "Front"; + break; + default: + buf = ""; + } + + sprintf(title, "glxsnoop window 0x%x (%s buffer)", (int) WindowID, buf); + + set_window_title(dpy, win, title); +} + + +static void +keypress(Display *dpy, Window win, char key) +{ + switch (key) { + case 27: + /* escape */ + exit(0); + break; + case 's': + Buffer = STENCIL_BUFFER; + break; + case 'z': + Buffer = Z_BUFFER; + break; + case 'f': + Buffer = FRONT_BUFFER; + break; + case 'b': + Buffer = BACK_BUFFER; + break; + default: + return; + } + + update_window_title(dpy, win); + redraw(dpy, WindowID, win); +} + + +static void +event_loop(Display *dpy, Window win) +{ + XEvent event; + + while (1) { + XNextEvent( dpy, &event ); + + switch (event.type) { + case Expose: + redraw(dpy, WindowID, win); + break; + case ConfigureNotify: + /*resize( event.xconfigure.width, event.xconfigure.height );*/ + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + keypress(dpy, win, buffer[0]); + } + } + default: + /* nothing */ + ; + } + } +} + + +static VisualID +get_window_visualid(Display *dpy, Window win) +{ + XWindowAttributes attr; + + if (XGetWindowAttributes(dpy, win, &attr)) { + return attr.visual->visualid; + } + else { + return 0; + } +} + + +static void +get_window_size(Display *dpy, Window win, int *w, int *h) +{ + XWindowAttributes attr; + + if (XGetWindowAttributes(dpy, win, &attr)) { + *w = attr.width; + *h = attr.height; + } + else { + *w = *h = 0; + } +} + + +static XVisualInfo * +visualid_to_visualinfo(Display *dpy, VisualID vid) +{ + XVisualInfo *vinfo, templ; + long mask; + int n; + + templ.visualid = vid; + mask = VisualIDMask; + + vinfo = XGetVisualInfo(dpy, mask, &templ, &n); + return vinfo; +} + + +static void +key_usage(void) +{ + printf("Keyboard:\n"); + printf(" z - display Z buffer\n"); + printf(" s - display stencil buffer\n"); + printf(" f - display front color buffer\n"); + printf(" b - display back buffer\n"); +} + + +static void +usage(void) +{ + printf("Usage: glxsnoop [-display dpy] windowID\n"); + key_usage(); +} + + +static void +parse_opts(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0) { + usage(); + exit(0); + } + else if (strcmp(argv[i], "-display") == 0) { + DisplayName = argv[i + 1]; + i++; + } + else { + if (argv[i][0] == '0' && argv[i][1] == 'x') { + /* hex */ + WindowID = strtol(argv[i], NULL, 16); + } + else { + WindowID = atoi(argv[i]); + } + break; + } + } + + if (!WindowID) { + usage(); + exit(0); + } +} + + +int +main( int argc, char *argv[] ) +{ + Display *dpy; + VisualID vid; + XVisualInfo *visinfo; + Window win; + + parse_opts(argc, argv); + + key_usage(); + + dpy = XOpenDisplay(DisplayName); + + /* find the VisualID for the named window */ + vid = get_window_visualid(dpy, WindowID); + get_window_size(dpy, WindowID, &Width, &Height); + + visinfo = visualid_to_visualinfo(dpy, vid); + + Context = glXCreateContext( dpy, visinfo, NULL, True ); + if (!Context) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + win = make_gl_window(dpy, visinfo, Width, Height); + XMapWindow(dpy, win); + update_window_title(dpy, win); + + event_loop( dpy, win ); + + return 0; +} -- cgit v1.2.3 From 72c888869f4e5074e57c349ec356798959be791e Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 11 Oct 2007 18:25:12 -0600 Subject: Example of cooperative rendering into one window by two processes --- progs/xdemos/Makefile | 12 +- progs/xdemos/corender.c | 396 ++++++++++++++++++++++++++++++++++++++++++++++++ progs/xdemos/ipc.c | 264 ++++++++++++++++++++++++++++++++ progs/xdemos/ipc.h | 16 ++ 4 files changed, 687 insertions(+), 1 deletion(-) create mode 100644 progs/xdemos/corender.c create mode 100644 progs/xdemos/ipc.c create mode 100644 progs/xdemos/ipc.h (limited to 'progs') diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile index 4c4ecac38a..a7ba9afcac 100644 --- a/progs/xdemos/Makefile +++ b/progs/xdemos/Makefile @@ -8,7 +8,9 @@ INCDIR = $(TOP)/include LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) -PROGS = glthreads \ +PROGS = \ + corender \ + glthreads \ glxdemo \ glxgears \ glxgears_fbconfig \ @@ -83,3 +85,11 @@ xuserotfont.o: xuserotfont.c xuserotfont.h xrotfontdemo.o: xrotfontdemo.c xuserotfont.h $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xrotfontdemo.c +corender: corender.o ipc.o + $(CC) $(CFLAGS) corender.o ipc.o $(APP_LIB_DEPS) -o $@ + +corender.o: corender.c ipc.h + $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) corender.c + +ipc.o: ipc.c ipc.h + $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) ipc.c \ No newline at end of file diff --git a/progs/xdemos/corender.c b/progs/xdemos/corender.c new file mode 100644 index 0000000000..02e4ac0216 --- /dev/null +++ b/progs/xdemos/corender.c @@ -0,0 +1,396 @@ +/** + * Example of cooperative rendering into one window by two processes. + * The first instance of the program creates the GLX window. + * The second instance of the program gets the window ID from the first + * and draws into it. + * Socket IPC is used for synchronization. + * + * Usage: + * 1. run 'corender &' + * 2. run 'corender 2' (any arg will do) + * + * Brian Paul + * 11 Oct 2007 + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ipc.h" + + +static int MyID = 0; /* 0 or 1 */ +static int WindowID = 0; +static GLXContext Context = 0; +static int Width = 700, Height = 350; +static int Rot = 0; +static int Sock = 0; + +static GLfloat Red[4] = {1.0, 0.2, 0.2, 1.0}; +static GLfloat Blue[4] = {0.2, 0.2, 1.0, 1.0}; + +static int Sync = 1; /** synchronized rendering? */ + + +static void +setup_ipc(void) +{ + int k, port = 10001; + + if (MyID == 0) { + /* I'm the first one, wait for connection from second */ + k = CreatePort(&port); + assert(k != -1); + + printf("Waiting for connection from another 'corender'\n"); + Sock = AcceptConnection(k); + + printf("Got connection, sending windowID\n"); + + /* send windowID */ + SendData(Sock, &WindowID, sizeof(WindowID)); + } + else { + /* I'm the second one, connect to first */ + char hostname[1000]; + + MyHostName(hostname, 1000); + Sock = Connect(hostname, port); + assert(Sock != -1); + + /* get windowID */ + ReceiveData(Sock, &WindowID, sizeof(WindowID)); + printf("Contacted first 'corender', getting WindowID\n"); + } +} + + + +/** from GLUT */ +static void +doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings) +{ + int i, j; + GLfloat theta, phi, theta1; + GLfloat cosTheta, sinTheta; + GLfloat cosTheta1, sinTheta1; + GLfloat ringDelta, sideDelta; + + ringDelta = 2.0 * M_PI / rings; + sideDelta = 2.0 * M_PI / nsides; + + theta = 0.0; + cosTheta = 1.0; + sinTheta = 0.0; + for (i = rings - 1; i >= 0; i--) { + theta1 = theta + ringDelta; + cosTheta1 = cos(theta1); + sinTheta1 = sin(theta1); + glBegin(GL_QUAD_STRIP); + phi = 0.0; + for (j = nsides; j >= 0; j--) { + GLfloat cosPhi, sinPhi, dist; + + phi += sideDelta; + cosPhi = cos(phi); + sinPhi = sin(phi); + dist = R + r * cosPhi; + + glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); + glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); + glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); + glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi); + } + glEnd(); + theta = theta1; + cosTheta = cosTheta1; + sinTheta = sinTheta1; + } +} + + +static void +redraw(Display *dpy) +{ + int dbg = 0; + + glXMakeCurrent(dpy, WindowID, Context); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + glClearColor(0.5, 0.5, 0.5, 0.0); + + if (MyID == 0) { + /* First process */ + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glTranslatef(-1, 0, 0); + glRotatef(Rot, 1, 0, 0); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Red); + doughnut(0.5, 2.0, 20, 30); + glPopMatrix(); + + glFinish(); + if (!Sync) { + usleep(1000*10); + } + + /* signal second process to render */ + if (Sync) { + int code = 1; + if (dbg) printf("0: send signal\n"); + SendData(Sock, &code, sizeof(code)); + SendData(Sock, &Rot, sizeof(Rot)); + } + + /* wait for second process to finish rendering */ + if (Sync) { + int code = 0; + if (dbg) printf("0: wait signal\n"); + ReceiveData(Sock, &code, sizeof(code)); + if (dbg) printf("0: got signal\n"); + assert(code == 2); + } + + } + else { + /* Second process */ + + /* wait for first process's signal for me to render */ + if (Sync) { + int code = 0; + if (dbg) printf("1: wait signal\n"); + ReceiveData(Sock, &code, sizeof(code)); + ReceiveData(Sock, &Rot, sizeof(Rot)); + + if (dbg) printf("1: got signal\n"); + assert(code == 1); + } + + /* XXX this clear should not be here, but for some reason, it + * makes things _mostly_ work correctly w/ NVIDIA's driver. + * There's only occasional glitches. + * Without this glClear(), depth buffer for the second process + * is pretty much broken. + */ + //glClear(GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glTranslatef(1, 0, 0); + glRotatef(Rot + 90 , 1, 0, 0); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Blue); + doughnut(0.5, 2.0, 20, 30); + glPopMatrix(); + glFinish(); + + glXSwapBuffers(dpy, WindowID); + usleep(1000*10); + + /* signal first process that I'm done rendering */ + if (Sync) { + int code = 2; + if (dbg) printf("1: send signal\n"); + SendData(Sock, &code, sizeof(code)); + } + } +} + + +static void +resize(Display *dpy, int width, int height) +{ + float ar = (float) width / height; + + glXMakeCurrent(dpy, WindowID, Context); + + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ar, ar, 1.0, -1.0, 5.0, 200.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -15); + + Width = width; + Height = height; +} + + + +static void +set_window_title(Display *dpy, Window win, const char *title) +{ + XSizeHints sizehints; + sizehints.flags = 0; + XSetStandardProperties(dpy, win, title, title, + None, (char **)NULL, 0, &sizehints); +} + + +static Window +make_gl_window(Display *dpy, XVisualInfo *visinfo, int width, int height) +{ + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + int x = 0, y = 0; + char *name = NULL; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( dpy, root, x, y, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(dpy, win, &sizehints); + XSetStandardProperties(dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + return win; +} + + +static void +set_event_mask(Display *dpy, Window win) +{ + XSetWindowAttributes attr; + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + XChangeWindowAttributes(dpy, win, CWEventMask, &attr); +} + + +static void +event_loop(Display *dpy) +{ + while (1) { + while (XPending(dpy) > 0) { + XEvent event; + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + redraw(dpy); + break; + case ConfigureNotify: + resize(dpy, event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + exit(0); + } + } + } + default: + /* nothing */ + ; + } + } + + if (MyID == 0 || !Sync) + Rot += 1; + redraw(dpy); + } +} + + +static XVisualInfo * +choose_visual(Display *dpy) +{ + int attribs[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_DEPTH_SIZE, 1, + None }; + int scrnum = DefaultScreen( dpy ); + return glXChooseVisual(dpy, scrnum, attribs); +} + + +static void +parse_opts(int argc, char *argv[]) +{ + if (argc > 1) { + MyID = 1; + } +} + + +int +main( int argc, char *argv[] ) +{ + Display *dpy; + XVisualInfo *visinfo; + + parse_opts(argc, argv); + + dpy = XOpenDisplay(NULL); + + visinfo = choose_visual(dpy); + + Context = glXCreateContext( dpy, visinfo, NULL, True ); + if (!Context) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + if (MyID == 0) { + WindowID = make_gl_window(dpy, visinfo, Width, Height); + set_window_title(dpy, WindowID, "corender"); + XMapWindow(dpy, WindowID); + /*printf("WindowID 0x%x\n", (int) WindowID);*/ + } + + /* do ipc hand-shake here */ + setup_ipc(); + assert(Sock); + assert(WindowID); + + if (MyID == 1) { + set_event_mask(dpy, WindowID); + } + + resize(dpy, Width, Height); + + event_loop(dpy); + + return 0; +} diff --git a/progs/xdemos/ipc.c b/progs/xdemos/ipc.c new file mode 100644 index 0000000000..fa52b09076 --- /dev/null +++ b/progs/xdemos/ipc.c @@ -0,0 +1,264 @@ +/* Copyright (c) 2003 Tungsten Graphics, Inc. + * + * 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, the Tungsten + * Graphics splash screen, 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 THE AUTHORS OR COPYRIGHT HOLDERS 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. + */ + +/* + * Simple IPC API + * Brian Paul + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ipc.h" + +#if defined(IRIX) || defined(irix) +typedef int socklen_t; +#endif + +#define NO_DELAY 1 + +#define DEFAULT_MASTER_PORT 7011 + + +/* + * Return my hostname in . + * Return 1 for success, 0 for error. + */ +int +MyHostName(char *nameOut, int maxNameLength) +{ + int k = gethostname(nameOut, maxNameLength); + return k==0; +} + + +/* + * Create a socket attached to a port. Later, we can call AcceptConnection + * on the socket returned from this function. + * Return the new socket number or -1 if error. + */ +int +CreatePort(int *port) +{ + char hostname[1000]; + struct sockaddr_in servaddr; + struct hostent *hp; + int so_reuseaddr = 1; + int tcp_nodelay = 1; + int sock, k; + + /* create socket */ + sock = socket(AF_INET, SOCK_STREAM, 0); + assert(sock > 2); + + /* get my host name */ + k = gethostname(hostname, 1000); + assert(k == 0); + + /* get hostent info */ + hp = gethostbyname(hostname); + assert(hp); + + /* initialize the servaddr struct */ + memset(&servaddr, 0, sizeof(servaddr) ); + servaddr.sin_family = AF_INET; + servaddr.sin_port = htons((unsigned short) (*port)); + memcpy((char *) &servaddr.sin_addr, hp->h_addr, + sizeof(servaddr.sin_addr)); + + /* deallocate when we exit */ + k = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (char *) &so_reuseaddr, sizeof(so_reuseaddr)); + assert(k==0); + + /* send packets immediately */ +#if NO_DELAY + k = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, + (char *) &tcp_nodelay, sizeof(tcp_nodelay)); + assert(k==0); +#endif + + if (*port == 0) + *port = DEFAULT_MASTER_PORT; + + k = 1; + while (k && (*port < 65534)) { + /* bind our address to the socket */ + servaddr.sin_port = htons((unsigned short) (*port)); + k = bind(sock, (struct sockaddr *) &servaddr, sizeof(servaddr)); + if (k) + *port = *port + 1; + } + +#if 0 + printf("###### Real Port: %d\n", *port); +#endif + + /* listen for connections */ + k = listen(sock, 100); + assert(k == 0); + + return sock; +} + + +/* + * Accept a connection on the named socket. + * Return a new socket for the new connection, or -1 if error. + */ +int +AcceptConnection(int socket) +{ + struct sockaddr addr; + socklen_t addrLen; + int newSock; + + addrLen = sizeof(addr); + newSock = accept(socket, &addr, &addrLen); + if (newSock == 1) + return -1; + else + return newSock; +} + + +/* + * Contact the server running on the given host on the named port. + * Return socket number or -1 if error. + */ +int +Connect(const char *hostname, int port) +{ + struct sockaddr_in servaddr; + struct hostent *hp; + int sock, k; + int tcp_nodelay = 1; + + assert(port); + + sock = socket(AF_INET, SOCK_STREAM, 0); + assert(sock >= 0); + + hp = gethostbyname(hostname); + assert(hp); + + memset(&servaddr, 0, sizeof(servaddr)); + servaddr.sin_family = AF_INET; + servaddr.sin_port = htons((unsigned short) port); + memcpy((char *) &servaddr.sin_addr, hp->h_addr, sizeof(servaddr.sin_addr)); + + k = connect(sock, (struct sockaddr *) &servaddr, sizeof(servaddr)); + if (k != 0) { + perror("Connect:"); + return -1; + } + +#if NO_DELAY + /* send packets immediately */ + k = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, + (char *) &tcp_nodelay, sizeof(tcp_nodelay)); + assert(k==0); +#endif + + return sock; +} + + +void +CloseSocket(int socket) +{ + close(socket); +} + + +int +SendData(int socket, const void *data, int bytes) +{ + int sent = 0; + int b; + + while (sent < bytes) { + b = write(socket, (char *) data + sent, bytes - sent); + if (b <= 0) + return -1; /* something broke */ + sent += b; + } + return sent; +} + + +int +ReceiveData(int socket, void *data, int bytes) +{ + int received = 0, b; + + while (received < bytes) { + b = read(socket, (char *) data + received, bytes - received); + if (b <= 0) + return -1; + received += b; + } + return received; +} + + +int +SendString(int socket, const char *str) +{ + const int len = strlen(str); + int sent, b; + + /* first, send a 4-byte length indicator */ + b = write(socket, &len, sizeof(len)); + if (b <= 0) + return -1; + + sent = SendData(socket, str, len); + assert(sent == len); + return sent; +} + + +int +ReceiveString(int socket, char *str, int maxLen) +{ + int len, received, b; + + /* first, read 4 bytes to see how long of string to receive */ + b = read(socket, &len, sizeof(len)); + if (b <= 0) + return -1; + + assert(len <= maxLen); /* XXX fix someday */ + assert(len >= 0); + received = ReceiveData(socket, str, len); + assert(received != -1); + assert(received == len); + str[len] = 0; + return received; +} diff --git a/progs/xdemos/ipc.h b/progs/xdemos/ipc.h new file mode 100644 index 0000000000..3f434457c6 --- /dev/null +++ b/progs/xdemos/ipc.h @@ -0,0 +1,16 @@ +#ifndef IPC_H +#define IPC_H + + +extern int MyHostName(char *nameOut, int maxNameLength); +extern int CreatePort(int *port); +extern int AcceptConnection(int socket); +extern int Connect(const char *hostname, int port); +extern void CloseSocket(int socket); +extern int SendData(int socket, const void *data, int bytes); +extern int ReceiveData(int socket, void *data, int bytes); +extern int SendString(int socket, const char *str); +extern int ReceiveString(int socket, char *str, int maxLen); + + +#endif /* IPC_H */ -- cgit v1.2.3 From c095f7e46adccdc65dc6623c1f73e87c5be782ad Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 30 Aug 2007 13:00:20 -0400 Subject: Do XSync() before resetting error handler. --- progs/xdemos/pbutil.c | 1 + 1 file changed, 1 insertion(+) (limited to 'progs') diff --git a/progs/xdemos/pbutil.c b/progs/xdemos/pbutil.c index d0bbd1b0fc..6c340fd7f9 100644 --- a/progs/xdemos/pbutil.c +++ b/progs/xdemos/pbutil.c @@ -393,6 +393,7 @@ CreatePbuffer(Display *dpy, int screen, FBCONFIG config, pBuffer = None; } + XSync(dpy, False); /* Restore original X error handler */ (void) XSetErrorHandler(oldHandler); -- cgit v1.2.3 From f7d1d554b12995b09dae79193bbf0d40478a19fd Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Mon, 15 Oct 2007 20:12:01 -0400 Subject: glxinfo: Only print visuals that actually support GLX. --- progs/xdemos/glxinfo.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'progs') diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c index 3e8e0be520..07d76143b5 100644 --- a/progs/xdemos/glxinfo.c +++ b/progs/xdemos/glxinfo.c @@ -542,7 +542,7 @@ visual_class_abbrev(int cls) } -static void +static GLboolean get_visual_attribs(Display *dpy, XVisualInfo *vInfo, struct visual_attribs *attribs) { @@ -564,7 +564,7 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo, attribs->bitsPerRGB = vInfo->bits_per_rgb; if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0) - return; + return GL_FALSE; glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize); glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level); glXGetConfig(dpy, vInfo, GLX_RGBA, &attribs->rgba); @@ -616,6 +616,8 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo, #else attribs->visualCaveat = 0; #endif + + return GL_TRUE; } @@ -763,7 +765,8 @@ print_visual_info(Display *dpy, int scrnum, InfoMode mode) if (mode == Verbose) { for (i = 0; i < numVisuals; i++) { struct visual_attribs attribs; - get_visual_attribs(dpy, &visuals[i], &attribs); + if (!get_visual_attribs(dpy, &visuals[i], &attribs)) + continue; print_visual_attribs_verbose(&attribs); } } @@ -771,7 +774,8 @@ print_visual_info(Display *dpy, int scrnum, InfoMode mode) print_visual_attribs_short_header(); for (i = 0; i < numVisuals; i++) { struct visual_attribs attribs; - get_visual_attribs(dpy, &visuals[i], &attribs); + if (!get_visual_attribs(dpy, &visuals[i], &attribs)) + continue; print_visual_attribs_short(&attribs); } } @@ -779,7 +783,8 @@ print_visual_info(Display *dpy, int scrnum, InfoMode mode) print_visual_attribs_long_header(); for (i = 0; i < numVisuals; i++) { struct visual_attribs attribs; - get_visual_attribs(dpy, &visuals[i], &attribs); + if (!get_visual_attribs(dpy, &visuals[i], &attribs)) + continue; print_visual_attribs_long(&attribs); } } -- cgit v1.2.3 From 791ad0e77f48cd17f7c893bfbf63f21e62caee40 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 16 Oct 2007 16:01:34 -0400 Subject: Implement support for printing glx fbconfigs in glxinfo. --- progs/xdemos/glxinfo.c | 226 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 195 insertions(+), 31 deletions(-) (limited to 'progs') diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c index 07d76143b5..a6bfaa2520 100644 --- a/progs/xdemos/glxinfo.c +++ b/progs/xdemos/glxinfo.c @@ -52,6 +52,13 @@ #define GLX_TRANSPARENT_RGB 0x8008 #endif +#ifndef GLX_RGBA_BIT +#define GLX_RGBA_BIT 0x00000001 +#endif + +#ifndef GLX_COLOR_INDEX_BIT +#define GLX_COLOR_INDEX_BIT 0x00000002 +#endif typedef enum { @@ -81,7 +88,7 @@ struct visual_attribs int transparentIndexValue; int bufferSize; int level; - int rgba; + int render_type; int doubleBuffer; int stereo; int auxBuffers; @@ -541,12 +548,27 @@ visual_class_abbrev(int cls) } } +static const char * +visual_render_type_name(int type) +{ + switch (type) { + case GLX_RGBA_BIT: + return "rgba"; + case GLX_COLOR_INDEX_BIT: + return "ci"; + case GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT: + return "rgba|ci"; + default: + return ""; + } +} static GLboolean get_visual_attribs(Display *dpy, XVisualInfo *vInfo, struct visual_attribs *attribs) { const char *ext = glXQueryExtensionsString(dpy, vInfo->screen); + int rgba; memset(attribs, 0, sizeof(struct visual_attribs)); @@ -563,11 +585,17 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo, attribs->colormapSize = vInfo->colormap_size; attribs->bitsPerRGB = vInfo->bits_per_rgb; - if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0) + if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0 || + !attribs->supportsGL) return GL_FALSE; glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize); glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level); - glXGetConfig(dpy, vInfo, GLX_RGBA, &attribs->rgba); + glXGetConfig(dpy, vInfo, GLX_RGBA, &rgba); + if (rgba) + attribs->render_type = GLX_RGBA_BIT; + else + attribs->render_type = GLX_COLOR_INDEX_BIT; + glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer); glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo); glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers); @@ -620,6 +648,96 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo, return GL_TRUE; } +#ifdef GLX_VERSION_1_3 + +static int +glx_token_to_visual_class(int visual_type) +{ + switch (visual_type) { + case GLX_TRUE_COLOR: + return TrueColor; + case GLX_DIRECT_COLOR: + return DirectColor; + case GLX_PSEUDO_COLOR: + return PseudoColor; + case GLX_STATIC_COLOR: + return StaticColor; + case GLX_GRAY_SCALE: + return GrayScale; + case GLX_STATIC_GRAY: + return StaticGray; + case GLX_NONE: + default: + return None; + } +} + +static GLboolean +get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, + struct visual_attribs *attribs) +{ + int visual_type; + + memset(attribs, 0, sizeof(struct visual_attribs)); + + glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &attribs->id); + + /* FIXME: convert from GL enum to visual class. */ + glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &attribs->klass); + +#if 0 + attribs->depth = vInfo->depth; + attribs->redMask = vInfo->red_mask; + attribs->greenMask = vInfo->green_mask; + attribs->blueMask = vInfo->blue_mask; + attribs->colormapSize = vInfo->colormap_size; + attribs->bitsPerRGB = vInfo->bits_per_rgb; +#endif + + glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type); + attribs->klass = glx_token_to_visual_class(visual_type); + + glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers); + + glXGetFBConfigAttrib(dpy, fbconfig, GLX_RED_SIZE, &attribs->redSize); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_GREEN_SIZE, &attribs->greenSize); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_BLUE_SIZE, &attribs->blueSize); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ALPHA_SIZE, &attribs->alphaSize); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_DEPTH_SIZE, &attribs->depthSize); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_STENCIL_SIZE, &attribs->stencilSize); + + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize); + + /* get transparent pixel stuff */ + glXGetFBConfigAttrib(dpy, fbconfig,GLX_TRANSPARENT_TYPE, &attribs->transparentType); + if (attribs->transparentType == GLX_TRANSPARENT_RGB) { + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue); + } + else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue); + } + + glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLE_BUFFERS, &attribs->numMultisample); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat); + + return GL_TRUE; +} + +#endif + + static void print_visual_attribs_verbose(const struct visual_attribs *attribs) @@ -627,7 +745,8 @@ print_visual_attribs_verbose(const struct visual_attribs *attribs) printf("Visual ID: %x depth=%d class=%s\n", attribs->id, attribs->depth, visual_class_name(attribs->klass)); printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n", - attribs->bufferSize, attribs->level, attribs->rgba ? "rgba" : "ci", + attribs->bufferSize, attribs->level, + visual_render_type_name(attribs->render_type), attribs->doubleBuffer, attribs->stereo); printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", attribs->redSize, attribs->greenSize, @@ -685,16 +804,17 @@ print_visual_attribs_short(const struct visual_attribs *attribs) caveat = "None"; #endif - printf("0x%2x %2d %2s %2d %2d %2d %1s %2s %2s %2d %2d %2d %2d %2d %2d %2d", + printf("0x%02x %2d %2s %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d", attribs->id, attribs->depth, visual_class_abbrev(attribs->klass), attribs->transparentType != GLX_NONE, attribs->bufferSize, attribs->level, - attribs->rgba ? "r" : "c", - attribs->doubleBuffer ? "y" : ".", - attribs->stereo ? "y" : ".", + (attribs->render_type & GLX_RGBA_BIT) ? 'r' : ' ', + (attribs->render_type & GLX_COLOR_INDEX_BIT) ? 'c' : ' ', + attribs->doubleBuffer ? 'y' : '.', + attribs->stereo ? 'y' : '.', attribs->redSize, attribs->greenSize, attribs->blueSize, attribs->alphaSize, attribs->auxBuffers, @@ -730,7 +850,7 @@ print_visual_attribs_long(const struct visual_attribs *attribs) attribs->transparentType != GLX_NONE, attribs->bufferSize, attribs->level, - attribs->rgba ? "rgba" : "ci ", + visual_render_type_name(attribs->render_type), attribs->doubleBuffer, attribs->stereo, attribs->redSize, attribs->greenSize, @@ -753,45 +873,86 @@ print_visual_info(Display *dpy, int scrnum, InfoMode mode) { XVisualInfo theTemplate; XVisualInfo *visuals; - int numVisuals; + int numVisuals, numGlxVisuals; long mask; int i; + struct visual_attribs attribs; /* get list of all visuals on this screen */ theTemplate.screen = scrnum; mask = VisualScreenMask; visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals); - if (mode == Verbose) { - for (i = 0; i < numVisuals; i++) { - struct visual_attribs attribs; - if (!get_visual_attribs(dpy, &visuals[i], &attribs)) - continue; - print_visual_attribs_verbose(&attribs); - } + numGlxVisuals = 0; + for (i = 0; i < numVisuals; i++) { + if (get_visual_attribs(dpy, &visuals[i], &attribs)) + numGlxVisuals++; } - else if (mode == Normal) { + + if (numGlxVisuals == 0) + return; + + printf("%d GLX Visuals\n", numGlxVisuals); + + if (mode == Normal) print_visual_attribs_short_header(); - for (i = 0; i < numVisuals; i++) { - struct visual_attribs attribs; - if (!get_visual_attribs(dpy, &visuals[i], &attribs)) - continue; + else if (mode == Wide) + print_visual_attribs_long_header(); + + for (i = 0; i < numVisuals; i++) { + if (!get_visual_attribs(dpy, &visuals[i], &attribs)) + continue; + + if (mode == Verbose) + print_visual_attribs_verbose(&attribs); + else if (mode == Normal) print_visual_attribs_short(&attribs); - } + else if (mode == Wide) + print_visual_attribs_long(&attribs); } - else if (mode == Wide) { + printf("\n"); + + XFree(visuals); +} + +#ifdef GLX_VERSION_1_3 + +static void +print_fbconfig_info(Display *dpy, int scrnum, InfoMode mode) +{ + int numFBConfigs; + struct visual_attribs attribs; + GLXFBConfig *fbconfigs; + int i; + + /* get list of all fbconfigs on this screen */ + fbconfigs = glXGetFBConfigs(dpy, scrnum, &numFBConfigs); + + if (numFBConfigs == 0) + return; + + printf("GLXFBConfigs:\n"); + if (mode == Normal) + print_visual_attribs_short_header(); + else if (mode == Wide) print_visual_attribs_long_header(); - for (i = 0; i < numVisuals; i++) { - struct visual_attribs attribs; - if (!get_visual_attribs(dpy, &visuals[i], &attribs)) - continue; + + for (i = 0; i < numFBConfigs; i++) { + get_fbconfig_attribs(dpy, fbconfigs[i], &attribs); + + if (mode == Verbose) + print_visual_attribs_verbose(&attribs); + else if (mode == Normal) + print_visual_attribs_short(&attribs); + else if (mode == Wide) print_visual_attribs_long(&attribs); - } } + printf("\n"); - XFree(visuals); + XFree(fbconfigs); } +#endif /* * Stand-alone Mesa doesn't really implement the GLX protocol so it @@ -865,7 +1026,7 @@ find_best_visual(Display *dpy, int scrnum) /* see if this vis is better than bestVis */ if ((!bestVis.supportsGL && vis.supportsGL) || (bestVis.visualCaveat != GLX_NONE_EXT) || - (!bestVis.rgba && vis.rgba) || + (!(bestVis.render_type & GLX_RGBA_BIT) && (vis.render_type & GLX_RGBA_BIT)) || (!bestVis.doubleBuffer && vis.doubleBuffer) || (bestVis.redSize < vis.redSize) || (bestVis.greenSize < vis.greenSize) || @@ -961,7 +1122,10 @@ main(int argc, char *argv[]) mesa_hack(dpy, scrnum); print_screen_info(dpy, scrnum, allowDirect, limits); printf("\n"); +#ifdef GLX_VERSION_1_3 print_visual_info(dpy, scrnum, mode); +#endif + print_fbconfig_info(dpy, scrnum, mode); if (scrnum + 1 < numScreens) printf("\n\n"); } -- cgit v1.2.3 From 87966baa8d15ff58cd63da23627a4285bb7fb7e7 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 17 Oct 2007 10:14:55 -0400 Subject: Fixup a couple of thinkos in glxinfo changes. --- progs/xdemos/glxinfo.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'progs') diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c index a6bfaa2520..dfad1d3919 100644 --- a/progs/xdemos/glxinfo.c +++ b/progs/xdemos/glxinfo.c @@ -682,9 +682,6 @@ get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &attribs->id); - /* FIXME: convert from GL enum to visual class. */ - glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &attribs->klass); - #if 0 attribs->depth = vInfo->depth; attribs->redMask = vInfo->red_mask; @@ -1122,10 +1119,10 @@ main(int argc, char *argv[]) mesa_hack(dpy, scrnum); print_screen_info(dpy, scrnum, allowDirect, limits); printf("\n"); -#ifdef GLX_VERSION_1_3 print_visual_info(dpy, scrnum, mode); -#endif +#ifdef GLX_VERSION_1_3 print_fbconfig_info(dpy, scrnum, mode); +#endif if (scrnum + 1 < numScreens) printf("\n\n"); } -- cgit v1.2.3 From a5b4bb393f818d9906ed7862b9b8e4d2fa401603 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 17 Oct 2007 14:43:35 -0400 Subject: glxinfo: Also print number of fbconfigs. --- progs/xdemos/glxinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'progs') diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c index dfad1d3919..329cbb3e0a 100644 --- a/progs/xdemos/glxinfo.c +++ b/progs/xdemos/glxinfo.c @@ -928,7 +928,7 @@ print_fbconfig_info(Display *dpy, int scrnum, InfoMode mode) if (numFBConfigs == 0) return; - printf("GLXFBConfigs:\n"); + printf("%d GLXFBConfigs:\n", numFBConfigs); if (mode == Normal) print_visual_attribs_short_header(); else if (mode == Wide) -- cgit v1.2.3 From aad5c0fdc79153e7997f2140ae758db367e6c932 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 17 Oct 2007 17:03:33 -0400 Subject: pbutil: Do not require GLX_SGIX_pbuffer for fbconfig only-functions. --- progs/xdemos/pbutil.c | 71 ++++++++++++++++++++++++++++++++------------------- progs/xdemos/pbutil.h | 3 +++ 2 files changed, 48 insertions(+), 26 deletions(-) (limited to 'progs') diff --git a/progs/xdemos/pbutil.c b/progs/xdemos/pbutil.c index 6c340fd7f9..ce133d012d 100644 --- a/progs/xdemos/pbutil.c +++ b/progs/xdemos/pbutil.c @@ -18,12 +18,12 @@ * Test if we pixel buffers are available for a particular X screen. * Input: dpy - the X display * screen - screen number - * Return: 0 = pixel buffers not available. - * 1 = pixel buffers are available via GLX 1.3. - * 2 = pixel buffers are available via GLX_SGIX_fbconfig/pbuffer. + * Return: 0 = fbconfigs not available. + * 1 = fbconfigs are available via GLX 1.3. + * 2 = fbconfigs and pbuffers are available via GLX_SGIX_fbconfig */ int -QueryPbuffers(Display *dpy, int screen) +QueryFBConfig(Display *dpy, int screen) { #if defined(GLX_VERSION_1_3) { @@ -40,36 +40,55 @@ QueryPbuffers(Display *dpy, int screen) } #endif -#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) /* Try the SGIX extensions */ { char *extensions; extensions = (char *) glXQueryServerString(dpy, screen, GLX_EXTENSIONS); - if (!extensions || - !strstr(extensions,"GLX_SGIX_fbconfig") || - !strstr(extensions,"GLX_SGIX_pbuffer")) { - return 0; + if (extensions && strstr(extensions,"GLX_SGIX_fbconfig")) { + return 2; } - return 2; } -#endif return 0; } +/** + * Test if we pixel buffers are available for a particular X screen. + * Input: dpy - the X display + * screen - screen number + * Return: 0 = pixel buffers not available. + * 1 = pixel buffers are available via GLX 1.3. + * 2 = pixel buffers are available via GLX_SGIX_fbconfig/pbuffer. + */ +int +QueryPbuffers(Display *dpy, int screen) +{ + int ret; + ret = QueryFBConfig(dpy, screen); + if (ret == 2) { + char *extensions; + extensions = (char *) glXQueryServerString(dpy, screen, GLX_EXTENSIONS); + if (extensions && strstr(extensions, "GLX_SGIX_pbuffer")) + return 2; + else + return 0; + } + else + return ret; +} FBCONFIG * ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs) { - int pbSupport = QueryPbuffers(dpy, screen); + int fbcSupport = QueryPbuffers(dpy, screen); #if defined(GLX_VERSION_1_3) - if (pbSupport == 1) { + if (fbcSupport == 1) { return glXChooseFBConfig(dpy, screen, attribs, nConfigs); } #endif #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) - if (pbSupport == 2) { + if (fbcSupport == 2) { return glXChooseFBConfigSGIX(dpy, screen, (int *) attribs, nConfigs); } #endif @@ -80,14 +99,14 @@ ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs) FBCONFIG * GetAllFBConfigs(Display *dpy, int screen, int *nConfigs) { - int pbSupport = QueryPbuffers(dpy, screen); + int fbcSupport = QueryFBConfig(dpy, screen); #if defined(GLX_VERSION_1_3) - if (pbSupport == 1) { + if (fbcSupport == 1) { return glXGetFBConfigs(dpy, screen, nConfigs); } #endif #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) - if (pbSupport == 2) { + if (fbcSupport == 2) { /* The GLX_SGIX_fbconfig extensions says to pass NULL to get list * of all available configurations. */ @@ -101,14 +120,14 @@ GetAllFBConfigs(Display *dpy, int screen, int *nConfigs) XVisualInfo * GetVisualFromFBConfig(Display *dpy, int screen, FBCONFIG config) { - int pbSupport = QueryPbuffers(dpy, screen); + int fbcSupport = QueryFBConfig(dpy, screen); #if defined(GLX_VERSION_1_3) - if (pbSupport == 1) { + if (fbcSupport == 1) { return glXGetVisualFromFBConfig(dpy, config); } #endif #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) - if (pbSupport == 2) { + if (fbcSupport == 2) { return glXGetVisualFromFBConfigSGIX(dpy, config); } #endif @@ -130,11 +149,11 @@ GetFBConfigAttrib(Display *dpy, int screen, int attrib ) { - int pbSupport = QueryPbuffers(dpy, screen); + int fbcSupport = QueryFBConfig(dpy, screen); int value = 0; #if defined(GLX_VERSION_1_3) - if (pbSupport == 1) { + if (fbcSupport == 1) { /* ok */ if (glXGetFBConfigAttrib(dpy, config, attrib, &value) != 0) { value = 0; @@ -145,7 +164,7 @@ GetFBConfigAttrib(Display *dpy, int screen, #endif #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) - if (pbSupport == 2) { + if (fbcSupport == 2) { if (glXGetFBConfigAttribSGIX(dpy, config, attrib, &value) != 0) { value = 0; } @@ -295,9 +314,9 @@ PrintFBConfigInfo(Display *dpy, int screen, FBCONFIG config, Bool horizFormat) GLXContext CreateContext(Display *dpy, int screen, FBCONFIG config) { - int pbSupport = QueryPbuffers(dpy, screen); + int fbcSupport = QueryFBConfig(dpy, screen); #if defined(GLX_VERSION_1_3) - if (pbSupport == 1) { + if (fbcSupport == 1) { /* GLX 1.3 */ GLXContext c; c = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, True); @@ -309,7 +328,7 @@ CreateContext(Display *dpy, int screen, FBCONFIG config) } #endif #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) - if (pbSupport == 2) { + if (fbcSupport == 2) { GLXContext c; c = glXCreateContextWithConfigSGIX(dpy, config, GLX_RGBA_TYPE_SGIX, NULL, True); if (!c) { diff --git a/progs/xdemos/pbutil.h b/progs/xdemos/pbutil.h index e95b2565a2..d420522ff0 100644 --- a/progs/xdemos/pbutil.h +++ b/progs/xdemos/pbutil.h @@ -26,6 +26,9 @@ #endif +extern int +QueryFBConfig(Display *dpy, int screen); + extern int QueryPbuffers(Display *dpy, int screen); -- cgit v1.2.3 From b961eccc92d853eb573597ffc73304b65aa800c4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 17 Oct 2007 12:05:55 -0700 Subject: Support cards that have ARB_fp but not ARB_shadow. --- progs/demos/shadowtex.c | 62 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 13 deletions(-) (limited to 'progs') diff --git a/progs/demos/shadowtex.c b/progs/demos/shadowtex.c index 59253e8c1e..c2d40bda74 100644 --- a/progs/demos/shadowtex.c +++ b/progs/demos/shadowtex.c @@ -84,6 +84,7 @@ static const char *FragProgNames[] = { "program with \"OPTION ARB_fragment_program_shadow\"", }; +static GLboolean HaveShadow = GL_FALSE; static GLboolean HaveFBO = GL_FALSE; static GLboolean UseFBO = GL_FALSE; static GLboolean HaveVP = GL_FALSE; @@ -529,7 +530,10 @@ ShowShadowMap(void) DisableTexgen(); /* interpret texture's depth values as luminance values */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + if (HaveShadow) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + } + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); @@ -596,7 +600,9 @@ Display(void) } if (DisplayMode == SHOW_DEPTH_MAPPING) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + if (HaveShadow) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + } glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); @@ -614,8 +620,10 @@ Display(void) } else { assert(DisplayMode == SHOW_SHADOWS); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, - GL_COMPARE_R_TO_TEXTURE_ARB); + if (HaveShadow) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, + GL_COMPARE_R_TO_TEXTURE_ARB); + } if (curr_frag > 0) { glEnable(GL_FRAGMENT_PROGRAM_ARB); @@ -723,6 +731,10 @@ Key(unsigned char key, int x, int y) break; case 'M': curr_frag = (1 + curr_frag) % max_frag; + if (!HaveShadow && (curr_frag == 0)) { + curr_frag = 1; + } + printf("Using fragment %s\n", FragProgNames[curr_frag]); if (HaveFP) { @@ -740,8 +752,10 @@ Key(unsigned char key, int x, int y) if (Operator >= 8) Operator = 0; printf("Operator: %s\n", OperatorName[Operator]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, - OperatorFunc[Operator]); + if (HaveShadow) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, + OperatorFunc[Operator]); + } } break; case 'p': @@ -858,17 +872,31 @@ Init(void) { static const GLfloat borderColor[4] = {1.0, 0.0, 0.0, 0.0}; - if (!glutExtensionSupported("GL_ARB_depth_texture") || - !glutExtensionSupported("GL_ARB_shadow")) { - printf("Sorry, this demo requires the GL_ARB_depth_texture and GL_ARB_shadow extensions\n"); + if (!glutExtensionSupported("GL_ARB_depth_texture")) { + printf("Sorry, this demo requires the GL_ARB_depth_texture extension\n"); exit(1); } - printf("Using GL_ARB_depth_texture and GL_ARB_shadow\n"); + HaveShadow = glutExtensionSupported("GL_ARB_shadow"); HaveVP = glutExtensionSupported("GL_ARB_vertex_program"); HaveFP = glutExtensionSupported("GL_ARB_fragment_program"); HaveFP_Shadow = glutExtensionSupported("GL_ARB_fragment_program_shadow"); + if (!HaveShadow && !HaveFP) { + printf("Sorry, this demo requires either the GL_ARB_shadow extension " + "or the GL_ARB_fragment_program extension\n"); + exit(1); + } + + printf("Using GL_ARB_depth_texture\n"); + if (HaveShadow) { + printf("and GL_ARB_shadow\n"); + } + + if (HaveFP) { + printf("and GL_ARB_fragment_program\n"); + } + HaveShadowAmbient = glutExtensionSupported("GL_ARB_shadow_ambient"); if (HaveShadowAmbient) { printf("and GL_ARB_shadow_ambient\n"); @@ -895,9 +923,12 @@ Init(void) glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, - GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + + if (HaveShadow) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, + GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + } if (HaveShadowAmbient) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.3); @@ -954,6 +985,11 @@ Init(void) max_frag = 3; } + if (!HaveShadow) { + curr_frag = 1; + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, frag_progs[curr_frag]); + } + glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); -- cgit v1.2.3 From a074857cdc00fb73eed826503360b37cb251ade1 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 18 Oct 2007 15:19:08 -0400 Subject: glxinfo: Try creating a GLX context using an fbconfig if no visuals are available. --- progs/xdemos/glxinfo.c | 59 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 13 deletions(-) (limited to 'progs') diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c index 329cbb3e0a..db7d1ed08e 100644 --- a/progs/xdemos/glxinfo.c +++ b/progs/xdemos/glxinfo.c @@ -395,20 +395,61 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits) XSetWindowAttributes attr; unsigned long mask; Window root; - GLXContext ctx; + GLXContext ctx = NULL; XVisualInfo *visinfo; int width = 100, height = 100; root = RootWindow(dpy, scrnum); visinfo = glXChooseVisual(dpy, scrnum, attribSingle); - if (!visinfo) { + if (!visinfo) visinfo = glXChooseVisual(dpy, scrnum, attribDouble); - if (!visinfo) { - fprintf(stderr, "Error: couldn't find RGB GLX visual\n"); - return; + + if (visinfo) + ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect ); + +#ifdef GLX_VERSION_1_3 + { + int fbAttribSingle[] = { + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, GL_TRUE, + None }; + int fbAttribDouble[] = { + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + None }; + GLXFBConfig *configs = NULL; + int nConfigs; + + if (!visinfo) + configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs); + if (!visinfo) + configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs); + + if (configs) { + visinfo = glXGetVisualFromFBConfig(dpy, configs[0]); + ctx = glXCreateNewContext(dpy, configs[0], GLX_RGBA_TYPE, NULL, allowDirect); + XFree(configs); } } +#endif + + if (!visinfo) { + fprintf(stderr, "Error: couldn't find RGB GLX visual or fbconfig\n"); + return; + } + + if (!ctx) { + fprintf(stderr, "Error: glXCreateContext failed\n"); + XFree(visinfo); + XDestroyWindow(dpy, win); + return; + } attr.background_pixel = 0; attr.border_pixel = 0; @@ -419,14 +460,6 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits) 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr); - ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect ); - if (!ctx) { - fprintf(stderr, "Error: glXCreateContext failed\n"); - XFree(visinfo); - XDestroyWindow(dpy, win); - return; - } - if (glXMakeCurrent(dpy, win, ctx)) { const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR); const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION); -- cgit v1.2.3 From 55d4f32fc211dbc37bd28c0e67da5ce5e0da5777 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Oct 2007 13:55:22 -0600 Subject: fix assorted bugs, works now --- progs/demos/streaming_rect.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'progs') diff --git a/progs/demos/streaming_rect.c b/progs/demos/streaming_rect.c index 86e00803c0..4c1d8535fd 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); } -- cgit v1.2.3 From 8578534f48a9d6b3e13364a675c263bc5a38700f Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Thu, 25 Oct 2007 11:34:16 -0700 Subject: Ignore new programs --- progs/demos/.gitignore | 1 + progs/glsl/.gitignore | 3 +++ progs/xdemos/.gitignore | 2 ++ 3 files changed, 6 insertions(+) (limited to 'progs') diff --git a/progs/demos/.gitignore b/progs/demos/.gitignore index 9c5957602c..ad20499f1e 100644 --- a/progs/demos/.gitignore +++ b/progs/demos/.gitignore @@ -4,6 +4,7 @@ arbfslight arbocclude bounce clearspd +copypix cubemap drawpix engine diff --git a/progs/glsl/.gitignore b/progs/glsl/.gitignore index 622e0417a8..b63693bbb5 100644 --- a/progs/glsl/.gitignore +++ b/progs/glsl/.gitignore @@ -1,10 +1,13 @@ +bitmap brick bump deriv extfuncs.h mandelbrot noise +points readtex.c readtex.h texdemo1 +trirast toyball diff --git a/progs/xdemos/.gitignore b/progs/xdemos/.gitignore index 250bc17d98..25022c112d 100644 --- a/progs/xdemos/.gitignore +++ b/progs/xdemos/.gitignore @@ -1,3 +1,4 @@ +corender glthreads glxcontexts glxdemo @@ -7,6 +8,7 @@ glxheads glxinfo glxpbdemo glxpixmap +glxsnoop glxswapcontrol manywin offset -- cgit v1.2.3 From c05aa5ec4cc29f949eff350582cb6f6c03dce3c6 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Mon, 29 Oct 2007 09:03:01 -0600 Subject: specify app lib dependencies in Makefiles (patch 1/3) --- progs/beos/Makefile | 10 ++++++---- progs/demos/Makefile | 16 +++++++++------- progs/directfb/Makefile | 4 +++- progs/fbdev/Makefile | 3 ++- progs/fp/Makefile | 2 +- progs/glsl/Makefile | 6 ++++-- progs/miniglx/Makefile | 4 +++- progs/osdemos/Makefile | 4 +++- progs/redbook/Makefile | 4 +++- progs/samples/Makefile | 6 ++++-- progs/slang/Makefile | 8 +++++--- progs/tests/Makefile | 2 +- progs/trivial/Makefile | 2 +- progs/vp/Makefile | 2 +- progs/xdemos/Makefile | 16 +++++++++------- 15 files changed, 55 insertions(+), 34 deletions(-) (limited to 'progs') diff --git a/progs/beos/Makefile b/progs/beos/Makefile index 45782fb3cf..491e8e442d 100644 --- a/progs/beos/Makefile +++ b/progs/beos/Makefile @@ -10,7 +10,9 @@ include $(TOP)/configs/current # # Modified by Philippe Houdoin -LDFLAGS += -soname=_APP_ $(APP_LIB_DEPS) +LDFLAGS += -soname=_APP_ + +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) INCLUDES = -I. -I- -I../../include @@ -21,13 +23,13 @@ clean: rm -f *.o demo: demo.o - $(LD) demo.o $(LDFLAGS) -o $@ + $(LD) demo.o $(LDFLAGS) $(LIBS) -o $@ sample: sample.o - $(LD) sample.o $(LDFLAGS) -o $@ + $(LD) sample.o $(LDFLAGS) $(LIBS) -o $@ GTLInfo: GLInfo.o - $(LD) GLInfo.o $(INCLUDES) $(LDFLAGS) -o $@ + $(LD) GLInfo.o $(INCLUDES) $(LDFLAGS) $(LIBS) -o $@ .cpp.o: $(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@ diff --git a/progs/demos/Makefile b/progs/demos/Makefile index 4d9eb30b68..57e56f52a3 100644 --- a/progs/demos/Makefile +++ b/progs/demos/Makefile @@ -13,6 +13,8 @@ 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) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) + PROGS = \ arbfplight \ arbfslight \ @@ -75,7 +77,7 @@ PROGS = \ # make executable from .c file: .c: $(LIB_DEP) readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@ + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@ ##### TARGETS ##### @@ -119,35 +121,35 @@ extfuncs.h: $(TOP)/progs/util/extfuncs.h reflect: reflect.o showbuffer.o readtex.o - $(CC) $(LDFLAGS) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) -o $@ + $(CC) $(LDFLAGS) reflect.o showbuffer.o readtex.o $(LIBS) -o $@ reflect.o: reflect.c showbuffer.h $(CC) -c -I$(INCDIR) $(CFLAGS) reflect.c shadowtex: shadowtex.o showbuffer.o - $(CC) $(LDFLAGS) shadowtex.o showbuffer.o $(APP_LIB_DEPS) -o $@ + $(CC) $(LDFLAGS) shadowtex.o showbuffer.o $(LIBS) -o $@ shadowtex.o: shadowtex.c showbuffer.h $(CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c gloss: gloss.o trackball.o readtex.o - $(CC) $(LDFLAGS) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@ + $(CC) $(LDFLAGS) gloss.o trackball.o readtex.o $(LIBS) -o $@ gloss.o: gloss.c trackball.h $(CC) -c -I$(INCDIR) $(CFLAGS) gloss.c engine: engine.o trackball.o readtex.o - $(CC) $(LDFLAGS) engine.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@ + $(CC) $(LDFLAGS) engine.o trackball.o readtex.o $(LIBS) -o $@ engine.o: engine.c trackball.h $(CC) -c -I$(INCDIR) $(CFLAGS) engine.c fslight: fslight.o - $(CC) $(LDFLAGS) fslight.o $(APP_LIB_DEPS) -o $@ + $(CC) $(LDFLAGS) fslight.o $(LIBS) -o $@ fslight.o: fslight.c extfuncs.h $(CC) -c -I$(INCDIR) $(CFLAGS) fslight.c @@ -155,7 +157,7 @@ fslight.o: fslight.c extfuncs.h viewdds: viewdds.c - $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -L. -lgltc -o $@ + $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(LIBS) -L. -lgltc -o $@ clean: diff --git a/progs/directfb/Makefile b/progs/directfb/Makefile index e03680e516..93c2a7df14 100644 --- a/progs/directfb/Makefile +++ b/progs/directfb/Makefile @@ -11,6 +11,8 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) CFLAGS += $(shell pkg-config --cflags directfb) APP_LIB_DEPS += $(shell pkg-config --libs directfb) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) + PROGS = df_gears \ df_reflect \ df_morph3d \ @@ -22,7 +24,7 @@ PROGS = df_gears \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ ##### TARGETS ##### diff --git a/progs/fbdev/Makefile b/progs/fbdev/Makefile index 92bfd043c1..56daf56f8a 100644 --- a/progs/fbdev/Makefile +++ b/progs/fbdev/Makefile @@ -15,6 +15,7 @@ INCLUDES = \ -I. \ -I$(TOP)/include +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) ##### RULES ##### @@ -22,7 +23,7 @@ INCLUDES = \ .SUFFIXES: .c .c: - $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ .c.o: $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@ diff --git a/progs/fp/Makefile b/progs/fp/Makefile index d979be83d3..a395b734ef 100644 --- a/progs/fp/Makefile +++ b/progs/fp/Makefile @@ -8,7 +8,7 @@ TOP = ../.. include $(TOP)/configs/current -LIBS = $(APP_LIB_DEPS) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) SOURCES = \ tri-abs.c \ diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 8b44239b43..fe2943d88d 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -7,6 +7,8 @@ INCDIR = $(TOP)/include 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) + PROGS = \ bitmap \ brick \ @@ -28,7 +30,7 @@ PROGS = \ # make executable from .c file: .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ ##### TARGETS ##### @@ -64,7 +66,7 @@ points.c: extfuncs.h toyball.c: extfuncs.h texdemo1: texdemo1.o readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@ + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o $(LIBS) -o $@ texdemo1.o: texdemo1.c readtex.h extfuncs.h $(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c diff --git a/progs/miniglx/Makefile b/progs/miniglx/Makefile index 56cecf4081..5d0c8eae64 100644 --- a/progs/miniglx/Makefile +++ b/progs/miniglx/Makefile @@ -20,6 +20,8 @@ INCLUDES = \ -I. \ -I$(TOP)/include +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) + ##### RULES ##### @@ -27,7 +29,7 @@ INCLUDES = \ .SUFFIXES: .c .c: - $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ .c.o: $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@ diff --git a/progs/osdemos/Makefile b/progs/osdemos/Makefile index 7e657744e3..148d603b35 100644 --- a/progs/osdemos/Makefile +++ b/progs/osdemos/Makefile @@ -13,6 +13,8 @@ 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) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) + PROGS = \ osdemo \ ostest1 @@ -26,7 +28,7 @@ PROGS = \ # make executable from .c file: .c: $(LIB_DEP) readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@ + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@ ##### TARGETS ##### diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile index 078f19125a..7ba676c265 100644 --- a/progs/redbook/Makefile +++ b/progs/redbook/Makefile @@ -7,6 +7,8 @@ INCDIR = $(TOP)/include 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) + PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \ bezcurve bezmesh checker clip colormat cube depthcue dof \ double drawf feedback fog fogindex font hello image light \ @@ -24,7 +26,7 @@ PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ diff --git a/progs/samples/Makefile b/progs/samples/Makefile index 8c99e8df25..6509a559a5 100644 --- a/progs/samples/Makefile +++ b/progs/samples/Makefile @@ -7,6 +7,8 @@ INCDIR = $(TOP)/include 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) + PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \ font line logo nurb olympic overlay point prim quad select \ shape sphere star stencil stretch texture tri wave @@ -18,7 +20,7 @@ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ ##### TARGETS ##### @@ -27,7 +29,7 @@ default: $(PROGS) sphere: sphere.o readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@ + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) sphere.o readtex.o $(LIBS) -o $@ sphere.o: sphere.c readtex.h $(CC) -c -I$(INCDIR) $(CFLAGS) sphere.c diff --git a/progs/slang/Makefile b/progs/slang/Makefile index 61db26d080..ea1e9b6afd 100644 --- a/progs/slang/Makefile +++ b/progs/slang/Makefile @@ -8,6 +8,8 @@ INCDIR = $(TOP)/include LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) + # # targets # @@ -29,13 +31,13 @@ clean: # cltest: cltest.o framework.o $(LIB_DEP) - $(CC) $(LDFLAGS) cltest.o framework.o $(APP_LIB_DEPS) -o cltest + $(CC) $(LDFLAGS) cltest.o framework.o $(LIBS) -o cltest sotest: sotest.o framework.o $(LIB_DEP) - $(CC) $(LDFLAGS) sotest.o framework.o $(APP_LIB_DEPS) -o sotest + $(CC) $(LDFLAGS) sotest.o framework.o $(LIBS) -o sotest vstest: vstest.o framework.o $(LIB_DEP) - $(CC) $(LDFLAGS) vstest.o framework.o $(APP_LIB_DEPS) -o vstest + $(CC) $(LDFLAGS) vstest.o framework.o $(LIBS) -o vstest # # objects diff --git a/progs/tests/Makefile b/progs/tests/Makefile index e8d0edda3a..454b0adf9c 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -8,7 +8,7 @@ TOP = ../.. include $(TOP)/configs/current -LIBS = $(APP_LIB_DEPS) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) SOURCES = \ afsmultiarb.c \ diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 259e20aa57..7610a5df08 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -8,7 +8,7 @@ TOP = ../.. include $(TOP)/configs/current -LIBS = $(APP_LIB_DEPS) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) SOURCES = \ clear.c \ diff --git a/progs/vp/Makefile b/progs/vp/Makefile index 4952a52fc9..3349fd5342 100644 --- a/progs/vp/Makefile +++ b/progs/vp/Makefile @@ -8,7 +8,7 @@ TOP = ../.. include $(TOP)/configs/current -LIBS = $(APP_LIB_DEPS) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) SOURCES = \ vp-tris.c diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile index a7ba9afcac..d49b3d2f5c 100644 --- a/progs/xdemos/Makefile +++ b/progs/xdemos/Makefile @@ -8,6 +8,8 @@ INCDIR = $(TOP)/include LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) + PROGS = \ corender \ glthreads \ @@ -41,7 +43,7 @@ PROGS = \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ ##### TARGETS ##### @@ -56,10 +58,10 @@ clean: # special cases pbinfo: pbinfo.o pbutil.o - $(CC) $(LDFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@ + $(CC) $(LDFLAGS) pbinfo.o pbutil.o $(LIBS) -o $@ pbdemo: pbdemo.o pbutil.o - $(CC) $(LDFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@ + $(CC) $(LDFLAGS) pbdemo.o pbutil.o $(LIBS) -o $@ pbinfo.o: pbinfo.c pbutil.h $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbinfo.c @@ -71,13 +73,13 @@ pbutil.o: pbutil.c pbutil.h $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbutil.c glxgears_fbconfig: glxgears_fbconfig.o pbutil.o - $(CC) $(LDFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@ + $(CC) $(LDFLAGS) glxgears_fbconfig.o pbutil.o $(LIBS) -o $@ glxgears_fbconfig.o: glxgears_fbconfig.c pbutil.h $(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c xrotfontdemo: xrotfontdemo.o xuserotfont.o - $(CC) $(LDFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@ + $(CC) $(LDFLAGS) xrotfontdemo.o xuserotfont.o $(LIBS) -o $@ xuserotfont.o: xuserotfont.c xuserotfont.h $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xuserotfont.c @@ -86,10 +88,10 @@ xrotfontdemo.o: xrotfontdemo.c xuserotfont.h $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xrotfontdemo.c corender: corender.o ipc.o - $(CC) $(CFLAGS) corender.o ipc.o $(APP_LIB_DEPS) -o $@ + $(CC) $(CFLAGS) corender.o ipc.o $(LIBS) -o $@ corender.o: corender.c ipc.h $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) corender.c ipc.o: ipc.c ipc.h - $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) ipc.c \ No newline at end of file + $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) ipc.c -- cgit v1.2.3 From 8b8a970593cd13cd4d0fc5c27e3fd7182f631a0e Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 30 Oct 2007 10:23:58 -0600 Subject: test glStencilFuncSeparateATI() --- progs/tests/getprocaddress.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'progs') diff --git a/progs/tests/getprocaddress.c b/progs/tests/getprocaddress.c index 8b000d234a..ca66025d2d 100644 --- a/progs/tests/getprocaddress.c +++ b/progs/tests/getprocaddress.c @@ -268,6 +268,32 @@ test_VertexAttrib4dvNV(generic_func func) } +static GLboolean +test_StencilFuncSeparateATI(generic_func func) +{ +#ifdef GL_ATI_separate_stencil + PFNGLSTENCILFUNCSEPARATEATIPROC stencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) func; + GLint frontFunc, backFunc; + GLint frontRef, backRef; + GLint frontMask, backMask; + (*stencilFuncSeparateATI)(GL_LESS, GL_GREATER, 2, 0xa); + glGetIntegerv(GL_STENCIL_FUNC, &frontFunc); + glGetIntegerv(GL_STENCIL_BACK_FUNC, &backFunc); + glGetIntegerv(GL_STENCIL_REF, &frontRef); + glGetIntegerv(GL_STENCIL_BACK_REF, &backRef); + glGetIntegerv(GL_STENCIL_VALUE_MASK, &frontMask); + glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &backMask); + if (frontFunc != GL_LESS || + backFunc != GL_GREATER || + frontRef != 2 || + backRef != 2 || + frontMask != 0xa || + backMask != 0xa) + return GL_FALSE; +#endif + return GL_TRUE; +} + static GLboolean test_StencilFuncSeparate(generic_func func) { -- cgit v1.2.3