zbuffer lrectread

Mike Papper mpapp at
Wed Jun 12 01:32:29 AEST 1991


I have been trying to read the contents (of a small area) of the 
zbuffer using lrectread. All I seem to get is a smattering of
16777216s (i.e. almost 2 * 8388607 i.e. 2 * 0x7FFFFF), sometimes
mixed in with other values.


For instance after a zclear() i do the following:

/* l,r,b,t are the left,right,bottom,and top points of a rectangle,
in window coords. */
static long get_z_data( long l, long r, long b, long t)
{
long oldmode;
unsigned long *ztemp;

  ztemp = (unsigned long *)ALLOC (sizeof(unsigned long) * (r-l+1)*(t-b+1));

  oldmode = getdrawmode();
  drawmode(NORMALDRAW);
  readsource(SRC_ZBUFFER);
  lrectread((Screencoord)l,(Screencoord)b,(Screencoord)r,(Screencoord)t,ztemp);
  readsource(SRC_AUTO);
  drawmode(oldmode);
}

On this particular machine (a GTX) getgdesc(GD_ZMAX) returns
8388607 i.e. 0x7FFFFF. Why does a zclear seem to fill 
the zbuffer with values twice this size (plus other values???)?

I believe that since I'm using unsigned longs the "top" (or is it bottom)
8 bits of the word are zeros (since the zbuffer contains 24 bit values
and I assume that unsigned longs are 32 bits), thus I should not
need to use pixmode.

Note: I have also tried writing to the zbuffer then reading it.
I use zbuffer(1) followed by a lrectwrite, I bel;ieve zdraw()
and the use of pixmode is uness. as zbuffer(1) will allow a subsequent
write to go directly into the zbuffer -- in this case I write zbuffer values,
not color indices.


However, I still get the wrong results (I write different values
and after a subsequent read, the values are the same).

Does anyone have some strightforward code that reads the numeric zbuffer values
from the current zbuffer? (These values shouyld always
be in the range used in lsetdepth(near, far)).

Email responses would be preffered.

Mike Papper
mpapp at godzilla.cgl.rmit.oz.au



More information about the Comp.sys.sgi mailing list