Re: Performer 2.2.3 on textures

New Message Reply Date view Thread view Subject view Author view

Yair Kurzion (yair++at++polygon.engr.sgi.com)
Tue, 26 Jan 1999 17:16:29 -0800 (PST)


Hi Mark !

> I'm also having problems with 2.2.3. I have a geoset with a list of fluxed
> points (PFGS_POINTS) that won't render at all with 2.2.3. It fails on Onyx2,
> Octane, and O2 systems in both n32 and 64 bit mode. Works fine with previous
> versions of Performer.

You hit on a bug with point primitives. This bug has nothing to do with the
Flux-ing of GeoSet attributes. Following is the complete bug description and
a work-around:

This bug exists in 2.2.3 and has already been fixed in 2.2.4.

Conditions for the bug:
  1. A pfGeoSet with primitive type PFGS_POINTS.
  2. No attribute PFSTATE_LPOINTSTATE (light-point state) on the attached
     GeoState.

Bug behavior:
  On non-O2 machines, the points will not show up.
  On O2, the program will crash.

The Work-around:

  1. Create an empty light-point state:
      pfLPointState *lps = new pfLPointState;

  2. Attach it to your pfGeoState (that you use on the POINT pfGeoSet):
      geoState->setAttr (PFSTATE_LPOINTSTATE, lps);

I modified your sample program to include this workaround and it now
runs well on O2 and other machines (Program follows)

-yair

-------------------------- Sample Program w/workaround -----------------------

#include <Performer/pr/pfWindow.h>
#include <Performer/pr/pfGeoState.h>
#include <Performer/pr/pfLPointState.h>
#include <Performer/pr/pfLinMath.h>
#include <Performer/pf/pfGeode.h>
#include <Performer/pr/pfGeoSet.h>
#include <Performer/pr/pfFlux.h>

pfGeoSet *createGeoSet ()

{
    // Make an empty Light-Point-State
    pfLPointState *lps = new pfLPointState;

#if 0

    // Variation without Flux.

    pfVec4 *pointFluxColor = (pfVec4 *) pfMalloc (sizeof(pfVec4));
    pfVec3 *pointFluxCoords = (pfVec3 *) pfMalloc (sizeof(pfVec3) * 4);

    pointFluxCoords[0].set(-1.0f, -1.0f, 0.0f );
    pointFluxCoords[1].set( 1.0f, -1.0f, 0.0f );
    pointFluxCoords[2].set( 1.0f, 1.0f, 0.0f );
    pointFluxCoords[3].set(-1.0f, 1.0f, 0.0f );

    pointFluxColor[0].set (1.0,1.0,1.0,1.0);

     
#else
    // Variation with Flux.

//------------------------------------------------------------------------
    // Allocate memory for point and colors
    //
    pfFlux *pointFluxColor = new pfFlux(sizeof(pfVec4),
                                        PFFLUX_DEFAULT_NUM_BUFFERS);

    pfFlux *pointFluxCoords = new pfFlux(sizeof(pfVec3) * 4,
                                        PFFLUX_DEFAULT_NUM_BUFFERS);
    pointFluxCoords->setMode (PFFLUX_COPY_LAST_DATA,PF_ON);

//------------------------------------------------------------------------
    // Add some random points
    //
    pfVec3 *points = (pfVec3 *)pointFluxCoords->getWritableData ();
    points[0].set(-1.0f, -1.0f, 0.0f );
    points[1].set( 1.0f, -1.0f, 0.0f );
    points[2].set( 1.0f, 1.0f, 0.0f );
    points[3].set(-1.0f, 1.0f, 0.0f );
    pointFluxCoords->writeComplete ();

//------------------------------------------------------------------------
    // Set point color to white
    //
    pfVec4 *color = (pfVec4 *)pointFluxColor->getWritableData ();
    color[0].set (1.0,1.0,1.0,1.0);
    pointFluxColor->writeComplete ();
#endif

//------------------------------------------------------------------------
    // Create the geoset
    //
    pfGeoSet *pointGSet = new pfGeoSet;
    pointGSet->setPrimType (PFGS_POINTS);
    pointGSet->setNumPrims (4);
    pointGSet->setPntSize (5.0);
    pointGSet->setAttr (PFGS_COORD3,PFGS_PER_VERTEX,pointFluxCoords,NULL);
    pointGSet->setAttr (PFGS_COLOR4,PFGS_OVERALL,pointFluxColor,NULL);

//------------------------------------------------------------------------
    // create a geostate for the geoset
    //
    pfGeoState *geoState = new pfGeoState;
    geoState->setMode (PFSTATE_CULLFACE,PFCF_OFF);
    geoState->setMode (PFSTATE_SHADEMODEL,PFSM_FLAT);
    geoState->setMode (PFSTATE_ENLIGHTING,PF_OFF);
    geoState->setMode (PFSTATE_ANTIALIAS,PFAA_OFF);

    // Add an empty Light-Point-State
    geoState->setAttr (PFSTATE_LPOINTSTATE, lps);

//------------------------------------------------------------------------
    // add the geostate to the geoset
    //
    pointGSet->setGState (geoState);

    return pointGSet;
}

int main (void)
{
    float t = 0.0f;

    // Initialize Performer
    pfInit();
    pfInitState(NULL);

    // Initialize GL
    pfWindow *win = new pfWindow;
    win->setOriginSize(100, 100, 500, 500);
    win->setName("Iris Performer");
    win->setWinType(PFWIN_TYPE_X);
    win->open();

    // set up the window
    pfFrustum *frust = new pfFrustum;
    frust->apply();
    delete frust;

    pfGeoSet *gset = createGeoSet();

    pfTranslate (0.0f, 0.0f, -4.0f);

    // Simulate for twenty seconds.
    pfInitClock (0.0f);
    while (t < 20.0f)
    {
        static pfVec4 clr(0.1f, 0.0f, 0.4f, 1.0f);

        t = pfGetTime();
        pfClear(PFCL_COLOR | PFCL_DEPTH, &clr);
        pfRotate (PF_Y, 1.0f);
        gset->draw();

        win->swapBuffers();
    }
}

-- 
\_________  \_____  \__    \__  \_____         Yair Kurzion
\_________  \_____   \__   \__  \_____         yair++at++sgi.com
       \__     \__   \____\__      \__   http://reality.sgi.com/yair
       \__          \__  \__                Work: (650) 933-6502
       \__          \__   \__               Home: (408) 226-9771
       \__          \__    \__             

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Tue Jan 26 1999 - 17:16:34 PST

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