Marco Tartaglia (marco++at++infobyte.it)
Thu, 18 Jan 1996 12:06:26 +0000
probably i'm unlucky today. Thank you for your answer, but the problem is not
solved yet; this is the complete test code so you can better check where is my
problem(s).
Thanks again for any suggestions.
On Jan 18, 12:31am, Tom McReynolds wrote:
> Subject: Re: Project Texture Problem
>
> It's difficult to tell for sure what might be wrong from the program outline
> you've sent, but there's enough there that I'll take a guess, and say you're
> running into a classic Performer programming bug:
>
> When pfConfig() is called, (when you're not running with PFMP_APPCULLDRAW)
> the pipe processes get forked. At fork time, the variables are
> copied. You're correctly creating and setting textures, lights, etc. after
> the pfConfig(), but the copied variables in your other processes don't see
> the changes you've made.
>
> If this is the problem you're seeing, we have a standard way to avoid it:
>
> 1. Declare a structure that contains all the state that needs sharing
> 2. Define a static pointer to that structure
> 3. *Allocate* a structure and set the pointer to its address.
> 4. Now call pfConfig(). The fork will copy the pointer to the structure, so
> all the forked processes can see changes made to the variables in the
> structure.
> 5. Go ahead and create and set things, using the variables in the allocated
> structure.
>
> It's a bit easier to just look at some code. in the sample directory,
> sample/pfguide/libpf/C, take a look at complex.c. The shared structure
> is called "SharedData"; the pointer to the structure is called "Shared".
>
> If your problem is something else, let me know...
>
> Good Luck!
>
> -Tom
>
>
>-- End of excerpt from Tom McReynolds
-- Marco Tartaglia Infobyte Spa VR R&D Software Engineer Via della Camilluccia 67 E-mail marco++at++infobyte.it 00135 Roma Tel +39-6-35572210 Fax +39-6-35572300
/* * file: dummy.c * ---------------- * * $Revision: 1.00 $ * $Date: 1996/01/17 12:00:00 $ * * IBX dummy program source. * * Test for ProjectTexture. * */
#include <Performer/pf.h> #include <Performer/pfdu.h>
static void TravDraw(pfChannel* handle, void* data);
typedef struct { pfChannel* chan; pfScene* scene; pfNode* node; pfLightSource* sun;
pfLightSource *spot; pfFrustum *spotFrust; pfTexture *spotTex; pfFog *spotFog; pfEarthSky *esky; pfDCS *spotDCS; pfCoord coord;
pfLightModel *lm; } dummySharedData;
static dummySharedData* dummmy;
void main(int argc, char* argv[]) { pfVec3 xyz, hpr;
pfInit(); pfNotifyLevel(5); pfMultiprocess(PFMP_APPCULL_DRAW);
dummmy = (dummySharedData*)pfCalloc(1, sizeof(dummySharedData), pfGetSharedArena());
pfConfig();
dummmy->chan = pfNewChan(pfGetPipe(0)); pfChanTravFunc(dummmy->chan, PFTRAV_DRAW, TravDraw); dummmy->scene = pfNewScene(); pfChanScene(dummmy->chan, dummmy->scene); dummmy->node = pfdLoadFile("/usr/share/Performer/data/esprit.flt"); pfAddChild(dummmy->scene, dummmy->node); pfSetVec3(xyz, 0.0f, -15.0f, 0.0f); pfSetVec3(hpr, 0.0f, 0.0f, 0.0f); pfChanView(dummmy->chan, xyz, hpr);
/* This light is used to avoid the 'faceting' of planar poligons */ dummmy->sun = pfNewLSource(); pfLSourcePos(dummmy->sun, 0.0f, 1.0f, 0.0f, 0.0f); pfSpotLSourceDir(dummmy->sun, 0.0f, 1.0f, 0.0f); pfLSourceColor(dummmy->sun, PFLT_DIFFUSE, 1.0f, 1.0f, 1.0f); pfSpotLSourceCone(dummmy->sun, 0.0f, 20.0f); pfAddChild(dummmy->scene, dummmy->sun);
dummmy->spotTex = pfNewTex(pfGetSharedArena()); pfTexRepeat(dummmy->spotTex, PFTEX_WRAP, PFTEX_CLAMP); printf("\n\nSpot Texture Loaded: %d\n\n", pfLoadTexFile(dummmy->spotTex, "scacchi.inta"));
dummmy->spotFrust = pfNewFrust(pfGetSharedArena()); pfMakeSimpleFrust(dummmy->spotFrust, 60.0f); pfFrustNearFar(dummmy->spotFrust, 1.0f, 1000.0f);
dummmy->spot = pfNewLSource(); pfLSourcePos(dummmy->spot, 0.0f, 0.0f, 0.0f, 1.0f); pfSpotLSourceDir(dummmy->spot, 0.0f, 1.0f, 0.0f); pfLSourceColor(dummmy->spot, PFLT_DIFFUSE, 1.0f, 1.0f, 1.0f); pfSpotLSourceCone(dummmy->spot, 0.0f, 20.0f); pfLSourceAttr(dummmy->spot, PFLS_PROJ_TEX, dummmy->spotTex); pfLSourceAttr(dummmy->spot, PFLS_PROJ_FRUST, dummmy->spotFrust); pfLSourceMode(dummmy->spot, PFLS_PROJTEX_ENABLE, PF_ON);
dummmy->spotDCS = pfNewDCS(); pfAddChild(dummmy->spotDCS, dummmy->spot); pfAddChild(dummmy->scene, dummmy->spotDCS); pfSetVec3(dummmy->coord.xyz, 0.0f, -2.0f, 0.0f); pfSetVec3(dummmy->coord.hpr, 0.0f, 0.0f, 0.0f); pfDCSCoord(dummmy->spotDCS, &(dummmy->coord));
while (TRUE) { pfFrame(); }
}
static void TravDraw(pfChannel* handle, void* data) { static int first = 1; if (first) { dummmy->lm = pfNewLModel(pfGetSharedArena()); pfLModelAmbient(dummmy->lm, 0.5f, 0.5f, 0.5f); /* if i call pfLModelLocal the 'faceting' of poligons is back */ /* pfLModelLocal(dummmy->lm, PF_ON);*/
pfApplyLModel(dummmy->lm);
first = 0; } pfClearChan(handle); pfDraw(); }
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:16 PDT