From: Yair Kurzion (yair++at++polygon.engr.sgi.com)
Date: 04/07/2003 11:59:23
Hello Steve !
Performer maintains an internal copy of the OpenGL state. It doesn't know that
you changed the current texture. When you call pfTexture::apply, it checks its
internal state and finds that this texture is already bound (and skips the
apply).
In general, if you tweak OpenGL state without Performer's knowledge, you
have to restore state to what Performer left it.
I can think of two ways to fix this problem:
o Restore the Performer texture:
// Check current Performer texture.
pfTexture *curTexture = pfGetCurTex();
glBindTexture(GL_TEXTURE_2D, ogl_tex);
... Your rendering code here ...
// Restore OpenGL state.
glBindTexture(GL_TEXTURE_2D, curTexture -> getGLHandle());
o Define another texture, foo. Before you call texture->apply, call
foo->apply. This will cost you an extra texture bind but should modify
the internal Performer state so that texture->apply will really apply it.
-yair
>
> Hi,
>
> I have a draw callback specified on a geode. The
> callback binds to an OpenGL texture object and
> then draws some geometry. The callback returns
> and the geode is then drawn. The problem is the
> geode is drawn with the OpenGL texture, not
> the pfTexture specified on its geostate ie. the
> OpenGL texture seems to override the pfTexture.
>
> int pre_draw_callback(pfTraverser *trav, void *data)
> {
> glBindTexture(GL_TEXTURE_2D, ogl_tex);
>
> ... draw some geometry, textured with "ogl_tex" ...
>
> // Try to switch back to the pfTexture
> pfGeode *node = (pfGeode *)trav->getNode();
> pfGeoSet *geoset = node->getGSet(0);
> pfGeoState *gstate = geoset->getGState();
> pfTexture *texture = (pfTexture *)gstate->getAttr(PFSTATE_TEXTURE);
> texture->apply();
> }
>
> ... then draw the geode ...
>
> int post_draw_callback(pfTraverser *trav, void *data)
> {
> ... clean up ...
> }
>
> I have tried using pfTexture::apply() in the callback
> to switch back to the pfTexture after I'm finished
> with the OpenGL texture object, but it has no effect.
>
> Any ideas?
>
> cheers
> steve
>
> -----------------------------------------------------------------------
> 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
> -----------------------------------------------------------------------
>
--
\_________ \_____ \__ \__ \_____
\_________ \_____ \__ \__ \_____ Yair Kurzion
\__ \__ \____\__ \__ yair++at++sgi.com
\__ \__ \__ (650) 933-6502
\__ \__ \__
\__ \__ \__
This archive was generated by hypermail 2b29 : Mon Apr 07 2003 - 11:59:28 PDT