Re: [info-performer] Relationship between a pfTexture and a pfdImage?

Date view Thread view Subject view Author view

From: Alexander Lechner (alexander.lechner++at++vertigo-systems.de)
Date: 08/31/2005 10:08:17


Hi Dan!

I can't really comment on pfdImage and pfTexture but I used your well-known
stub and put in some lines.
You basically create a geostate and textures and then apply the
geostate in your draw cb. Of course it is possible to use
pfTexture->apply() directly, but this is a bit less flexible.

in your app PROC:

pfGeoState *gstate = new pfGeoState;
pfTexture *tex = new pfTexture;
pfTexEnv *tex = new pfTexEnv;
tex->loadFile("tex.rgb");
gstate->setAttr(PFSTATE_TEXTURE, tex);
gstate->setMode(PFSTATE_ENTEXTURE, 1);
gstate->setMode(PFSTATE_ENLIGHTING, 0);
gstate->setAttr(PFSTATE_TEXENV, tev);
;; configure the gstate as you like, but these are the basic settings for
texturing

pass gstate with your APchannel data to draw PROC.

[If you really want to do video texturing you will have
to configure your texture for subloading and then use
the pfTexture->subload method].

// here is your stub and some code

PFAPCDLLEXPORT void
DrawBackgroundImage (pfChannel *channel, void *data)
{
    ChanPassData *pass;
    APchannel * apChan;
    int xsize, ysize;

    pass = (ChanPassData *)data;
    apChan = pass->apchannel;

    pfGetChanSize( channel, &xsize, &ysize );

    pfPushState();
    pfBasicState();

    glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0,xsize,0,ysize, -1.0, 1.0);

    glDisable(GL_DEPTH_TEST); // don't do a depth test, we just draw over
    pfGeoState* gstate = pass->gstate; // get a geostate from the app
    gstate->apply(); // apply the geostate, enables texturing
    glBegin(GL_QUADS);
    glTexCoord2i(0, 0); glVertex2i(0, 0);
    glTexCoord2i(1, 0); glVertex2i(xsize, 0);
    glTexCoord2i(1, 1); glVertex2i(xsize, ysize);
    glTexCoord2i(0, 1); glVertex2i(0, xsize);
    glEnd();

    pfFlushState(); // maybe not necessary

    /* make sure the depth buffer is also cleared */
    // you can also use the above full screen quad to write into the depth
    // buffer, which is basically a clear. but wrt. latest experiments with
    // an Onyx, better keep this separate.

    glClear( GL_DEPTH_BUFFER_BIT  );

    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

    glDepthRange(0.0,1.0);
    glDepthFunc(GL_LEQUAL);

    pfPopState();
}

Good luck,

Alex

On Wednesday 31 August 2005 17:49, Dan Johnston wrote:
> I recently did some changes to my applications to allow a
> display of an image in the background of any channel.
> The low-level draw callback will call glDrawPixels with
> the image scaled to fit the display window size of the
> pfChannel.
>
> This works fine, but I used copies of the pfdImage code
> (found in ../Performer/src/lib/libpfdu ) to load the
> image file and pack it into the format needed by
> glDrawPixels. (I copied the files and changed them
> because - for one thing - the image data is
> 'malloc' from non-shared memory, not pfMalloc
> and therefore not pfDelete.)
>
> I would prefer to use the more general pfTexture.
> I have looked at a lot of Performer source code, read
> the sections of the manual on textures a few times,
> and hacked up some test code. No luck so far.
> (Actually I can load the file with pfLoadTexFile
> and then call a modified pfdImageFromPfTexture
> to change a static image to a usable format.)
>
> Can I get image data from pfTexture in a format
> usable by glDrawPixels? I can allow a lot of
> initialization time (i.e. image conversion) at start
> up of my applications as long as run-time is
> still fast. I would prefer to use the pfTexture
> image data directly without a run-time conversion
> so that I can create features like using a video
> stream as the source for my pfTexture.
>
> Thanks for any ideas or help!
>
> Daniel.Johnston++at++nrc.gc.ca
>
> --
> ___|__ |
> / | \ ||\ 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!
>
>
>
> -----------------------------------------------------------------------
> List Archives, Info, FAQ: 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
> -----------------------------------------------------------------------


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 31 2005 - 10:08:50 PDT