pfGroup node DRAW callback

New Message Reply Date view Thread view Subject view Author view

Anita Kishore (kishore++at++triavest.com)
Fri, 13 Mar 1998 09:54:55 -0800


Hi Sharon:

        I picked up on the work that I had left off a couple of months
back (when you had helped answer some questions regarding forming
matrices in performer appl. and loading it on to MODELVIEW stack through
node callbacks) and have seen something strange that I think is wrong
being done inside performer.

        I am attaching a small sample code to show this. The program
creates a simple geometry, adds a couple of DCS and a group node above it,
and attaches DRAW callbacks to all these nodes. These callbacks do not
do anything in particular but are there simply to track the problem.

        I tracked the GL calls that are generated through ogldebug, and here
is what I found:

        There is a pop matrix call immediately after finishing the pfGroup's
node callback. The rest of the GL calls seem to fall in place ok. Is this
pop correct? Why is it showing up here?

Now, returning to my original problem, my actual appl. is also similarly
structured scenegraph wise. I try to load a particular matrix onto the
MODELVIEW stack in the pre DRAW callback of a pfGroup node (below which my
geometry exists). But, the stack is not being affected (ie: this geometry is
not
drawn using the viewing matrix that I loaded). Upon tracing similarly
with ogldebug, I found the same 'pop' matrix GL call immediately after the
pre DRAW callback of this group node thus voiding the matrix that I just
laoded.
I am not doing any pop until the post draw callback. So why is this happening
only for a group node?

I am using performer2.2, Onyx2, Irix 6.4.

Thanks for your help.

-anita
kishore++at++triavest.com

#include <stdlib.h>
#include <Performer/pf.h>
#include <Performer/pfutil.h>
#include <Performer/pfdu.h>

/******************************************************************************
 * geometry
 ******************************************************************************
 */

#define GEO_SIZE 1.0

static pfGeoSet *geometry( void )
{
 pfGeoSet *gset;

 static pfVec3 verts[] = {
                          {-GEO_SIZE, 0, -GEO_SIZE},
                          { GEO_SIZE, 0, -GEO_SIZE},
                          { GEO_SIZE, 0, GEO_SIZE},
                          {-GEO_SIZE, 0, GEO_SIZE}
                         };

 static ushort vindex[] ={0, 1, 2, 3}; /* front */

 static pfVec3 norms[] ={{ 0.0f, -1.0f, 0.0f}};

 static ushort nindex[] ={0};

 fprintf ( stderr, "geometry()\n" );
 gset = pfNewGSet ( pfGetSharedArena () );

 pfGSetAttr ( gset, PFGS_COORD3, PFGS_PER_VERTEX, verts, vindex );
 pfGSetAttr ( gset, PFGS_NORMAL3, PFGS_PER_PRIM, norms, nindex );
 pfGSetPrimType ( gset, PFGS_QUADS );
 pfGSetNumPrims ( gset, 1 );
 return gset;
#ifdef XXX
 pfNode * node;
 node = pfdLoadFile ( "square.iv" );
 if ( !node )
  fprintf ( stderr, "load failed\n" );
 return ( pfGeoSet * )node;
#endif
}

int preScene(pfTraverser *trav, void *userData)
{
     int matMode;
     glGetIntegerv(GL_ALPHA_BITS, &matMode);

     return 0;
}

int postScene(pfTraverser *trav, void *userData)
{
     int matMode;
     glGetIntegerv(GL_ALPHA_BIAS, &matMode);

     return 0;
}

int preRoot(pfTraverser *trav, void *userData)
{
     int matMode;
     glGetIntegerv(GL_GREEN_BITS, &matMode);

     return 0;
}

int postRoot(pfTraverser *trav, void *userData)
{
     int matMode;
     glGetIntegerv(GL_GREEN_BIAS, &matMode);

     return 0;
}

int preGeode(pfTraverser *trav, void *userData)
{
     int matMode;
     glGetIntegerv(GL_BLUE_BITS, &matMode);

     return 0;
}

int postGeode(pfTraverser *trav, void *userData)
{
     int matMode;
     glGetIntegerv(GL_BLUE_BIAS, &matMode);

     return 0;
}

int preGroup(pfTraverser *trav, void *userData)
{
     int matMode;
     glGetIntegerv(GL_RED_BITS, &matMode);

     return 0;
}

int postGroup(pfTraverser *trav, void *userData)
{
     int matMode;
     glGetIntegerv(GL_RED_BIAS, &matMode);
}

int
main (int argc, char *argv[])
{
    pfScene *scene;
    pfPipe *p;
    pfPipeWindow *pw;
    pfChannel *chan;
    pfSphere bsphere;
    pfGeode *geode;
    pfTexture *vtex;
    pfGeoState *gstate;
    pfGeoSet *gset;
    pfCoord view;
    pfGroup *root;
     

    pfInit();
    pfConfig();

    /* set up scene graph */
    geode = pfNewGeode();
    gset = geometry();
    pfAddGSet(geode, gset);
    root = pfNewGroup();
    pfAddChild(root, geode);
    scene = pfNewScene();
    pfSwitch *sw = pfNewSwitch();
    pfDCS *dcs1 = pfNewDCS();
    pfGroup *grp = pfNewGroup();
    pfDCS * dcs2 = pfNewDCS();
    pfDCS * dcs3 = pfNewDCS();
    pfAddChild(scene, pfNewLSource());
    pfAddChild(scene, sw);
    pfAddChild(sw, dcs1);
    pfAddChild(dcs1, grp);
    pfAddChild(grp, dcs2);
    pfAddChild(dcs2, dcs3);
    pfAddChild(dcs3, root);

    pfNodeTravFuncs(scene, PFTRAV_DRAW, preScene, postScene);
    pfNodeTravFuncs(root, PFTRAV_DRAW, preRoot, postRoot);
    pfNodeTravFuncs(geode, PFTRAV_DRAW, preGeode, postGeode);
    pfNodeTravFuncs(grp, PFTRAV_DRAW, preGroup, postGroup);

    /* make a window */
    p = pfGetPipe(0);
    pw = pfNewPWin(p);
    pfPWinType(pw, PFPWIN_TYPE_X);
    pfPWinName(pw, "testCallback");
    pfPWinOriginSize(pw, 0, 0, 720, 486);
    pfConfigPWin(pw);
    pfFrame();

    /* make a channel */
    chan = pfNewChan(p);
    pfChanScene(chan, scene);
    pfChanFOV(chan, 45, 0);

    /* determine extent of scene's geometry */
    pfGetNodeBSphere (root, &bsphere);
    pfChanNearFar(chan, 1, 10 * bsphere.radius);
    pfCopyVec3 ( view . xyz, bsphere . center );
    view . xyz [ PF_Y ] -= 3.0f * bsphere.radius;
    pfSetVec3 ( view . hpr, 0.0f, 0.0f, 0.0f);
    pfChanView ( chan, view.xyz, view.hpr);

    /* make a geostate */
    gstate = pfNewGState (pfGetSharedArena());
    pfGSetGState(gset, gstate);
    pfFrame();

    while (1)
    {
          pfSync();
        pfFrame();
    }

    pfExit();
}

SHELL = /bin/sh

#-- provide a list of alternate locations for file searches
UNIQUE = .

#-- alternate locatins for included files
INCLUDE =

#SRCLIBOPT=_igl
SRCLIBOPT=_ogl

PERFORMER = \
        -lpf${SRCLIBOPT}

#-- IRIX 4.x uses shared gl {gl_s} library {System-V Make lacks #if movietex.cs}
#LIBGL1 = -lgl
LIBGL1 = -lGL

LIBGL2 = ${LIBGL1:.4=_s}
LIBGL = ${LIBGL2:.5=}

SYSTEM = \
        ${LIBGL} \
        -lGLU\
        -lX11 \
        -lm \
        -lfpe \
        -lC

LIBRARIES = \
        ${PERFORMER} ${SYSTEM}

#-- select c-compiler options
C++FLAGS = ${INCLUDE} ${COPT} -DPF_C_API=1 \
                 -DPF_CPLUSPLUS_API=0 \
                 -DPF_MAJOR_VERSION=2 -Xcpluscomm -mips2 -32
#-DIRISGL

#-- base name of program
TARGET = testCallback

#-- object files from which target built {some are in the common directory}
OBJECTS = \
        testCallback.o

${TARGET}: ${OBJECTS}
        ${C++C} ${C++FLAGS} -o $++at++ ${OBJECTS} ${LIBRARIES}

#-- objects are built from either unique or common files
testCallback.o: ${UNIQUE}/testCallback.c++
        ${C++C} ${C++FLAGS} -c testCallback.c++ -o $++at++

clean :
        rm -f testCallback testCallback.o

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:57:01 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.