Material colors and multiple pfPipeWindows

New Message Reply Date view Thread view Subject view Author view

RUS (Daniela.Rainer++at++RUS.Uni-Stuttgart.DE)
Fri, 22 Aug 1997 18:08:08 +0000


Hello,

I have a state problem with in an application with multiple windows and I
attached a small test example that shows the problem:

Both windows have the same view of an object. The object geoset contains colors
and normals.

I defined a global material with all components set to grey or white and
pfMtlColorMode(state->mtl, PFMTL_BOTH, PFMTL_CMODE_OFF) which should prohibit
that the object is drawn with the geometry colors.

Of course this is only a test program that should show the inconsistency
between the two windows, normally I would not define geometry colors and then
doesn't use them.

In the first window this looks like it was defined (an uncolored cube but
shaded cube) but in the second window the object is always drawn ambient with
the geometry color.

Does anybody have experience with multiple windows and state problems?

I compiled this program on an Indy 24-bit with IRIX 6.2 and Performer2.0.1.

Thanks for any help.

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 multiple windowsmaterial */ /* Spotlight seem to have a problem on RealityEngine with Performer 2.01 */ /* */ /* OpenGL based Performer 2.0(1) */ /* */ /* cc -o state_multiwin state_multiwin.c -lGLU -lGL -lpf_ogl -lpfdu_ogl */ /* -lpfutil_ogl -lmpc -limage -lfm -lXirisw -lXm -lXt -lfpe -lXmu -lX11 */ /* -lm -lmalloc -lC -lXext */ /* */ /****************************************************************************************/

#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 { pfLightModel *lm; pfLight *lt; pfMaterial *mtl;

} 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);

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) {

pfOpenPWin(pw);

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

/* global state */ pfCullFace(PFCF_OFF); pfShadeModel(PFSM_GOURAUD); pfEnable(PFEN_LIGHTING); /* twosided lighting */ state->lm = pfNewLModel(pfGetSharedArena()); pfLModelTwoSide(state->lm, PF_ON); pfLModelLocal(state->lm, PF_ON); pfApplyLModel(state->lm);

/* finite light */ 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); /* two sided material that ignores all geometry colors*/ state->mtl = pfNewMtl(pfGetSharedArena()); pfMtlSide(state->mtl, PFMTL_BOTH); pfMtlColorMode(state->mtl, PFMTL_BOTH, PFMTL_CMODE_OFF); pfMtlColor(state->mtl, PFMTL_AMBIENT, 0.2, 0.2, 0.2); pfMtlColor(state->mtl, PFMTL_DIFFUSE, 0.9, 0.9, 0.9); pfMtlColor(state->mtl, PFMTL_SPECULAR, 0.8, 0.8, 0.8); pfMtlColor(state->mtl, PFMTL_EMISSION, 0.0f, 0.0f, 0.0f); pfMtlShininess(state->mtl, 16.0f); pfApplyMtl(state->mtl);

}

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.