Re: Lighting in draw callback

New Message Reply Date view Thread view Subject view Author view

Rob Jenkins (robj++at++sgi.com)
Fri, 15 Jan 1999 07:20:44 -0800


pfBasicState disables lighting I believe which would explain your
problem. I wonder if you could reproduce everything you're trying to do
with all pf calls:

Just around your cone drawing, if you used PFTR_BLEND_ALPHA |
PFTR_NO_OCCLUDE that should do
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) and disable writes to
the depth buffer as well.

If this works you can avoid messing with the pfstate which is always
best even if just that the glenable/disables that would get triggered by
the state push/basic/pop will have some overhead that would then be
avoided.

If you try it and it's not clear what's going on, I'd suggest tracing
with ogldebug.

Cheers
Rob

Bryan Walsh wrote:
>
> Hello pfFellows,
>
> Because I need to draw some geometry in native OpenGL, and as a work around
> to some sorting issues, I have several pfGroup draw callbacks. The geometry
> drawn include pfdCones, pfdSpheres, as well as my native OpenGL geometry.
> Everything works fine except the specular component of the material. i.e., I
> don't see the highlighting/reflection from the material. Below is a sample
> of what I'm trying to do. Any helpful suggestions would be greatly
> appreciated.
>
> typedef struct {
> int color;
> int visible;
> pfGeoSet *cone;
> pfMaterial *material;
> pfLightModel *lightmodel;
> pfLight *light[PF_MAX_LIGHTS];
> pfGeoState *state;
> int first;
> } ConeData;
>
> int drawCone(pfTraverser *, void *data) {
> ConeData *pd = (ConeData*)data;
> if (pd->first) {
> //
> // pd->cone = pfdNewCone called externally
> // pfdNewCone includes normals
> //
> pd->first = 0;
> float fcolor[4];
> fcolor[0] = (float)(pd->color & 0xff) / 0xff;
> fcolor[1] = (float)((pd->color >> 8) & 0xff) / 0xff;
> fcolor[2] = (float)((pd->color >> 16) & 0xff) / 0xff;
> fcolor[3] = 0.2;
> pd->material = new pfMaterial();
> pd->material->setAlpha(0.15f);
> pd->material->setShininess(40.0f);
> pd->material->setColor(PFMTL_DIFFUSE, fcolor[0],fcolor[1],fcolor[2]);
> pd->lightmodel = new pfLightModel();
>
> pd->light[0] = new pfLight();
>
> pfPushIdentMatrix();
> pd->light[0]->setPos(0.0f, 1.0f, 0.0f, 0.0f);
> pfPopMatrix();
>
> pd->lightmodel->setAmbient(0.8f, 0.8f, 0.8f);
> pd->lightmodel->setLocal(PF_OFF);
> pd->lightmodel->setTwoSide(PF_ON);
> pd->state = new pfGeoState();
> pd->state->setMode(PFSTATE_TRANSPARENCY, PFTR_HIGH_QUALITY);
> pd->state->setAttr(PFSTATE_FRONTMTL, pd->material);
> pd->state->setAttr(PFSTATE_BACKMTL, pd->material);
> pd->cone->setGState(pd->state);
> }
>
> pfPushState();
> pfPushMatrix();
> pfBasicState();
>
> pd->lightmodel->apply();
> pd->light[0]->on();
>
> glEnable(GL_BLEND);
> glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
> glDepthMask(GL_FALSE);
> pd->cone->draw();
> glDepthMask(GL_TRUE);
>
> pfPopMatrix();
> pfPopState();
>
> return PFTRAV_CONT;
> }
>
> Help would be greatly appreciated,
>
> Thanks
>
> Bryan Walsh
>
> =======================================================================
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com

-- 
________________________________________________________________
Rob Jenkins	Silicon Graphics 	mailto:robj++at++sgi.com

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Fri Jan 15 1999 - 07:29:45 PST

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