Re: Material colors and multiple pfPipeWindows in MULTIPROCESSING mode

New Message Reply Date view Thread view Subject view Author view

RUS (Daniela.Rainer++at++RUS.Uni-Stuttgart.DE)
Tue, 26 Aug 1997 10:54:29 +0000


Hello Brian,

thanks a lot for your answer.

The second material was not the only change you did to my program. You also
changed the multiprocessing model to PFMP_DEFAULT which is on my single
processor Indy PFMP_APPCULLDRAW. But in single processing this problem doesn't
arise.

The global shared material that was used twice was an error in my test program.
As I don't need it further more, I create the material in the OpenWindow
callback now. Only the light is a global variable.

Would you please have again a look at my program?

Best Regards
Daniela

-- 
-------------------------------------------------------------------------
Daniela Rainer                       | email: rainer++at++rus.uni-stuttgart.de
Rechenzentrum Uni Stuttgart (RUS)    | Tel:   +49 (0) 711 685 5790	
Allmandring 30a, 70550 Stuttgart     | Fax:   +49 (0) 711 682 357

/****************************************************************************************/ /* */ /* Test for state varaibles in multiple windows and multiple processes */ /* */ /* OpenGL based Performer 2.0(1) */ /* */ /* cc -o state_multiwin state_multiwin.c -lpf_ogl -lpfdu_ogl */ /* -lpfutil_ogl -lmpc -limage -lfm -lfpe -lm -lmalloc -lC */ /* */ /****************************************************************************************/

#include <stdlib.h> #include <stdio.h> #include <math.h>

#define PF_CPLUSPLUS_API 0 #include <Performer/pf.h> #include <Performer/pr.h> #include <Performer/pfutil.h> #include <Performer/pfdu.h> #include <Performer/pfui.h>

void OpenWindow(pfPipeWindow *pw); void DrawFunc(pfChannel *chan, void *data); void PreDraw(pfChannel *chan, void *data); void PostDraw(pfChannel *chan, void *data);

pfGeode *loadCube(float size);

typedef struct { pfLight *lt;

} sharedState;

sharedState *state;

int main(int argc, char *argv[]) { pfChannel *chan1, *chan2; pfScene *scene; pfDCS *rotateDCS; pfGeode *cubeGeode; pfGeode *testObject; pfMatrix DCSMat, mat; pfPipeWindow *pw1, *pw2; pfCoord view; pfVec3 axis;

pfInit();

state = (sharedState *) pfCalloc(1, sizeof(sharedState), pfGetSharedArena());

pfMultiprocess(PFMP_APPCULL_DRAW); /* Please let the multiprocess model unchanged because the problem arises only in mutiprocessing */

pfConfig();

scene = pfNewScene(); rotateDCS = pfNewDCS(); cubeGeode = loadCube(5.0f); pfAddChild(scene, rotateDCS); pfAddChild(rotateDCS, cubeGeode);

pw1 = pfNewPWin(pfGetPipe(0)); pfPWinOriginSize(pw1, 100, 100, 400, 400); pfPWinConfigFunc(pw1, OpenWindow); pfConfigPWin(pw1); pfFrame();

pw2 = pfNewPWin(pfGetPipe(0)); pfPWinOriginSize(pw2, 500, 100, 400, 400); pfPWinConfigFunc(pw2, OpenWindow); pfConfigPWin(pw2); pfFrame();

chan1 = pfNewChan(pfGetPipe(0)); pfChanTravFunc(chan1, PFTRAV_DRAW, DrawFunc); pfChanScene(chan1,scene); pfChanNearFar(chan1, 8.0, 20.0); pfMakePerspChan(chan1,-3.0f, 3.0f, -3.0f, 3.0f); pfSetVec3(view.xyz, 0.0f, -14.0f, 0.0f); pfSetVec3(view.hpr, 0.0f, 0.0f, 0.0f); pfChanView(chan1, view.xyz, view.hpr); pfAddChan(pw1, chan1);

chan2 = pfNewChan(pfGetPipe(0)); pfChanTravFunc(chan2, PFTRAV_DRAW, DrawFunc); pfChanScene(chan2,scene); pfChanNearFar(chan2, 8.0, 20.0); pfMakePerspChan(chan2,-3.0f, 3.0f, -3.0f, 3.0f); pfSetVec3(view.xyz, 0.0f, -14.0f, 0.0f); pfSetVec3(view.hpr, 0.0f, 0.0f, 0.0f); pfChanView(chan2, view.xyz, view.hpr); pfAddChan(pw2, chan2);

pfSetVec3(axis,1.0f, 0.0f, 0.0f); pfNormalizeVec3(axis); pfMakeRotMat(mat, 0.9f,axis[0], axis[1], axis[3]); while (1) { pfSync();

pfGetDCSMat(rotateDCS, DCSMat); pfPostMultMat(DCSMat, mat); pfDCSMat(rotateDCS, DCSMat);

pfFrame(); } }

void OpenWindow(pfPipeWindow *pw) { static int firsttime = TRUE; pfMaterial *mtl; pfLightModel *lm;

pfOpenPWin(pw);

pfPWinIndex(pw, PFWIN_GFX_WIN); pfSelectPWin(pw);

/* global state */ pfCullFace(PFCF_OFF); pfShadeModel(PFSM_GOURAUD); pfEnable(PFEN_LIGHTING);

/* two sided material that ignores all geometry colors*/ mtl = pfNewMtl(pfGetSharedArena()); pfMtlSide(mtl, PFMTL_BOTH); pfMtlColorMode(mtl, PFMTL_BOTH, PFMTL_CMODE_OFF); pfMtlColor(mtl, PFMTL_AMBIENT, 0.2, 0.2, 0.2); pfMtlColor(mtl, PFMTL_DIFFUSE, 0.9, 0.9, 0.9); pfMtlColor(mtl, PFMTL_SPECULAR, 0.8, 0.8, 0.8); pfMtlColor(mtl, PFMTL_EMISSION, 0.0f, 0.0f, 0.0f); pfMtlShininess(mtl, 16.0f); pfApplyMtl(mtl); /*twosided light model*/ lm = pfNewLModel(pfGetSharedArena()); pfLModelTwoSide(lm, PF_ON); pfLModelLocal(lm, PF_ON); pfApplyLModel(lm);

if (firsttime == TRUE) /* create the light only once */ { firsttime = FALSE; state->lt = pfNewLight(pfGetSharedArena()); pfLightPos(state->lt, 0.0f, 0.0f, 10.0f, 1.0f); pfLightColor(state->lt, PFLT_DIFFUSE, 1.0f, 1.0f, 1.0f); pfLightColor(state->lt, PFLT_AMBIENT, 0.1f, 0.1f, 0.1f); pfLightColor(state->lt, PFLT_SPECULAR, 1.0f, 1.0f, 1.0f);

}

}

void DrawFunc(pfChannel *chan, void *data) { PreDraw(chan,data); pfDraw(); PostDraw(chan,data); }

void PreDraw(pfChannel *chan, void *data) { pfLightOn(state->lt); pfClearChan(chan); }

void PostDraw(pfChannel *leftChan, void *data) { }

pfGeode *loadCube(float size) { pfGeoSet *cubeGeoSet; pfGeode *cubeGeode; pfGeoState *cubeGeoState; pfMatrix scaleMat, rotMat; static pfVec4 *cubeColor; pfMaterial *cubemtl; cubeGeode = pfNewGeode(); cubeGeoSet = pfdNewCube(pfGetSharedArena()); cubeColor = (pfVec4 *)pfCalloc(1, sizeof(pfVec4), pfGetSharedArena()); pfSetVec4(cubeColor[0], 0.0f, 1.0f, 1.0f, 1.0f); pfGSetAttr(cubeGeoSet, PFGS_COLOR4, PFGS_OVERALL, cubeColor, NULL); pfMakeScaleMat(scaleMat, size, size, size); pfdXformGSet(cubeGeoSet, scaleMat); pfMakeRotMat(rotMat, 45.0f, 1.0f, 0.0f, 0.0f); pfdXformGSet(cubeGeoSet, rotMat); pfAddGSet(cubeGeode, cubeGeoSet);

return(cubeGeode);

}

======================================================================= 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:55:46 PDT

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