From: Marcin Romaszewicz (marcin++at++asmodean.engr.sgi.com)
Date: 04/06/2001 11:46:19
You have to set up the texture internal format correctly since Performer
has no code to infer this from the frame buffer format. Here's a code
snippet from some work I've done which initializes a texture for
subloading RGBA data:
pfTexture *tex2 = new pfTexture();
tex2->setRepeat(PFTEX_WRAP, PFTEX_CLAMP);
tex2->setFilter(PFTEX_MINFILTER, PFTEX_POINT);
tex2->setFilter(PFTEX_MAGFILTER, PFTEX_POINT);
tex2->setFormat(PFTEX_IMAGE_FORMAT, PFTEX_RGBA);
tex2->setFormat(PFTEX_INTERNAL_FORMAT, PFTEX_RGBA_8);
tex2->setFormat(PFTEX_EXTERNAL_FORMAT, GL_UNSIGNED_BYTE);
tex2->setImage(NULL, 4, 512, 512, 1); //Must call this to specify size
//and number of components
pfTextures can be set up to subload data from your window
automatically. Take a look at
pfTexture::setLoadMode(...),
pfTexture::setLoadOrigin(..),
pfTexture::setLoadSize(...),
pfTexture::setLoadImage(...)
-- Marcin
On Fri, 6 Apr 2001, Stephane Jaeger wrote:
> Hi,
> I am trying to read the backbuffer and copy it onto a pftexture. I use
> two channels added on the same pfPipeWindow. The first channel acts just
> as a regular channel and renders the scene while the second
> reads the previously rendered scene, updates a pftexture and renders its
> own scene using the texture. To ensure the update of the pfTexture after
> the first channel's rendering, I use a traversal callback for the second
> channel in which I do a pfTexture->subLoad() call before the pfDraw().
> Hence I assume that the first channel renders to the backbuffer and
> that Performer doesn t swap the buffer in between the second channel's
> rendering. Is that right so far ?
> The trouble is that my pfTexture doesn t update. I suppose it comes from
> the fact I am setting wrong parameters for the subload routine. Notice
> that I need to initialize my pftexture object by loading .rgb file
> otherwise I m getting the following warning for each frame at run-time:
> PF Warning/Usage: pfTexture::apply() - bad number of
> components -1
> Does anybody know what's going on ?
> Thank you for your help,
> Stephane
>
> Following are the texture initialisation and the traversal callback.
> ---------------------------------------
> spotTex = new pfTexture();
> if ( ! spotTex->loadFile("blackbg.rgb"))
> exit(1);
> firstpass->getPWin()->getSize(&x,&y);
> spotTex->setRepeat(PFTEX_WRAP, PFTEX_CLAMP);
> spotTex->setFormat(PFTEX_SUBLOAD_FORMAT, PF_ON);
> spotTex->setLoadOrigin(0, 0, 0);
> spotTex->setLoadOrigin(1, 0, 0);
> spotTex->setLoadSize(x,y);
> spotTex->setLoadMode(PFTEX_LOAD_SOURCE, PFTEX_SOURCE_FRAMEBUFFER);
> -----------------------------------------
> static void MyTravFunc (pfChannel *channel, void *)
> {
> //channel->clear(); //wouldn t it clear the backbuffer I m trying to
> read thereafter
> //update window size
> channel->getPWin()->getSize(&x, &y);
> spotTex->subload(PFTEX_SOURCE_FRAMEBUFFER, NULL, 0, 0,x, 0, 0, x,y);
>
> pfDraw();
> }
>
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
>
This archive was generated by hypermail 2b29 : Fri Apr 06 2001 - 11:46:23 PDT