From: Dan Johnston (dan.johnston++at++nrc.gc.ca)
Date: 08/26/2005 11:40:32
Alexander Lechner wrote:
> Some clarification:
> glDrawPixels of course generates fragments, so the depth buffer should get
> updated as well. Your code writes 1.0 into the depth buffer with
> glDrawPixels, so this should be fine.
> Nevertheless I would try to clear the depth buffer manually with glClear.
> Alex
>
> On Friday 26 August 2005 15:57, Alexander Lechner wrote:
> > Hi Dan!
> >
> > Just a guess:
> > glDrawPixels only updates the color buffer, so your depth/Z buffer is never
> > cleared. So I would try to clear the depth/Z buffer, either before or after
> > drawing your background image.
> > Also, be aware that glDrawPixels is rather slow, use a texture and a
> > fullscreen quad instead.
> > I cannot explain why some visuals work and some don't but I remember those
> > special clear modes on ONYX hardware when using multisampling. The pixels
> > only get tagged as cleared instead of really writing to them.
> >
> > Good luck.
> >
> > Alex
> > alexander.lechner++at++vertigo-systems.de
> >
Alexander was right! I've added an explicit call
to clear the depth buffer (after my glDrawPixels,
as before didn't help).
The final draw callback sub-function is listed
below for anyone it may help. Remember, my
main draw callback will check for a non-NULL
image and call this routine or else it will
just do a pfClearChan.
PFAPCDLLEXPORT void
DrawBackgroundImage (pfChannel *channel, void *data)
{
ChanPassData *pass;
APchannel * apChan;
static int justOnce = 0;
int xsize, ysize;
pass = (ChanPassData *)data;
apChan = pass->apchannel;
pfGetChanSize( channel, &xsize, &ysize );
if (justOnce == 0)
{
pfNotify(PFNFY_DEBUG, PFNFY_PRINT,
"preDraw, channel size is %d %d!\n",xsize,ysize);
justOnce = 1;
}
/* we need to get our background texture and draw it */
pfPushState();
pfBasicState();
/* we can skip pfClearChan and get both
* buffers (color and depth) initialized by
* our background image
*/
glDepthFunc(GL_ALWAYS);
glDepthRange(1.0,1.0);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,xsize,0,ysize, -1.0, 1.0);
glRasterPos2i(0, 0);
/*match image size to screen size */
glPixelZoom( (float)xsize/(float)apChan->imageData->xsize,
(float)ysize/(float)apChan->imageData->ysize );
glDrawPixels(apChan->imageData->xsize, apChan->imageData->ysize,
GL_RGB, GL_UNSIGNED_BYTE, apChan->imageData->packed);
/* restore the default zoom value */
glPixelZoom( 1.0f, 1.0f);
/* make sure the depth buffer is also cleared */
glClear( GL_DEPTH_BUFFER_BIT );
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glDepthRange(0.0,1.0);
glDepthFunc(GL_LEQUAL);
pfPopState();
}
Thanks to everyone that helped!
Dan Johnston
BTW: I had a suggestion to write a texture to
a quad and move it to the far clip plane. This
was my first idea too, but how to you keep the
image steady when the viewpoint changes due to
flying and position tracking? This requires
a frame-by-frame re-calculation of the position
of this background image. I suppose this is
what SGI does with their "earth sky" object, but
we don't get to see the code for this.
Dan
--
___|__ |
/ | \ ||\ Daniel (Dan) Johnston
/___|___\ || \ Dan.Johnston++at++nrc.gc.ca
_____|____ || \ National Research Council of Canada, London, ON
| | | || \ Integrated Manufacturing Technologies Institute
\___| | | ||____\ Tel: (519) 430-7081 Fax: (519) 430-7140
\_o_\___|____|_|______\_ Inst: http://www.nrc.gc.ca/imti
\ o / These opinions are my own! Not those of NRC.
\________________/ Virtual Reality:
http://imti.nrc.gc.ca/vetc_e/vetc_e.html
More Tall Ships - Fewer Computers!
This archive was generated by hypermail 2b29 : Fri Aug 26 2005 - 11:43:09 PDT