Re: How to display the pfGeoSet

New Message Reply Date view Thread view Subject view Author view

Angel-Ventura Mendo Gomez (ventura++at++labri.u-bordeaux.fr)
Tue, 11 May 1999 15:49:21 +0200


Mr li Yonglin wrote:
>
> Hi, performers
> I am trying to construct my own pfGeoSet so that I can control it
> easily. I did it well in iris6.2 but after I transfered my codes from
> iris6.2 to iris6.4 I found my programs cannot compile and run. Then I
> use the codes in /usr/share/Performer/src/sample/C++/perfly and
> /usr/share/Performer/src/sample/C++/common plus my own programs to
> recompile and link. But it is funny that I can not see any thing on the
> screen. But the code I used can display my own pfGeoSets well on
> iris6.2.
> So any body knows how to display the objects of your own pfGeoSet. For
> example. How to construct and display a cube in perfly using your own
> codes. Especially how to display?
>
> Thanks in advance.
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com

The problem is that if you use Multiprocesing you must allocate the
pfGeoSet in the
shared Arena and also the vertex array ex :

pfGeoSet *
GeoSetEditor::makeGeoSet(void *arena)
{
  pfVec3 *coords;
  pfVec4 *colors;

  coords = (pfVec3 *)pfMalloc(sizeof(pfVec3)*VERTEX_NUMBER,arena);
  coords[0].set(-2.0f, -2.0f, 2.0f );
  coords[1].set( 2.0f, -2.0f, 2.0f );
  coords[2].set( 2.0f, 2.0f, 2.0f );
  coords[3].set(-2.0f, 2.0f, 2.0f );

  colors = (pfVec4 *)pfMalloc(sizeof(pfVec4)*VERTEX_NUMBER,arena);
  colors[0].set(1.0f, 1.0f, 1.0f, 1.0f);
  colors[1].set(0.0f, 0.0f, 1.0f, 1.0f);
  colors[2].set(1.0f, 0.0f, 0.0f, 1.0f);
  colors[3].set(0.0f, 1.0f, 0.0f, 1.0f);

  pfGeoSet gset = new(arena) pfGeoSet();
  
  gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, coords, NULL);
  gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, colors, NULL);
  gset->setPrimType(PFGS_QUADS);
  gset->setNumPrims(1);

 return gset;
}

and now the main :

void
main(void)
{

                .......

  pfConfig();

  sharedData->geoSet=makeGeoSet(pfGetSharedArena());
                ......

   sharedData->chanel = new pfChannel(p);

    sharedData->chanel->setChanData(&sharedData, sizeof(SharedData *));
    sharedData->chanel->passChanData();
    sharedData->chanel->setTravFunc(PFTRAV_DRAW,DrawChannel);

        ect ...

  while (1){
                ...
  }

}
  
static void
DrawChannel (pfChannel *, void *userData)
{
  SharedData **ptr=(SharedData **)userData;
  SharedData *sharedData=(*ptr);

  static int i=0;
  static pfVec4 clr[] = { pfVec4(1.0f, 0.0f, 0.0f, 1.0f),
                          pfVec4(0.0f, 0.0f, 1.0f, 1.0f) };

  // erase framebuffer and draw Earth-Sky model
  pfClear(PFCL_COLOR | PFCL_DEPTH, &clr[i]);
  i^=1;

  // invoke Performer draw-processing for this frame
  pfDraw();

  // drawing pfGeoSet
  sharedData->geoSet->draw();
   

}

  
Et voila ;-)

        Good Luck

-- 
	ventura++at++labri.u-bordeaux.fr
	http://dept-info.labri.u-bordeaux.fr/~ventura
	telephone 05.56.84.69.20

Quod natura non dat Salmantica non praestat.


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Tue May 11 1999 - 06:51:58 PDT

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