Re: [Plib-devel] Texture and blend modes
Brought to you by:
sjbaker
From: Curtis L. O. <cu...@in...> - 2000-08-22 02:39:26
|
Steve Baker writes: > > So you are saying I could do something like the following: > > > > static int predraw( ssgEntity *e ) { > > > > glPushAttrib( GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT ); > > > > glDisable( GL_DEPTH_TEST ); > > glDisable( GL_FOG ); > > > > return true; > > } > > > > static int postdraw( ssgEntity *e ) { > > glPopAttrib(); > > > > return true; > > } > > Yes - exactly...although pushing and popping ALL the enable bits is > perhaps a tad drastic... > > There is a 'gotcha' here. Since the pre-draw callback is called BEFORE > ssgState::apply() is called, your 'pop' will also have undone any glEnable > or glDisable's that ssgSimpleState may have done. Since ssgSimpleState > doesn't know that you did that, it'll assume that whatever it enabled > or disabled is *STILL* that way when the next state is applied - and since > it's lazy - it won't re-enable anything that it *thinks* is already > enabled. Let's see if I understand ... I am (by definition) not tweaking any states that ssg normally would manage. But, since these states are grouped, and doing a glPushAttribute() saves a whole slew of states, I may unwittingly alter a state that ssg *does* manage as a side effect of my glPopAttribute() > So you need to either be rather surgical and save only exactly the > things that need saving (and I'm not sure if the granularity of the > attribute stack allows you to be that precise)...OR you could do an > > if ( e -> hasState () ) e->getState()->force() ; > > ...just AFTER your glPopAttrib - or (more obscurely - but more > efficiently) an > > if ( e -> hasState () ) e->getState()->apply() ; > > ...just BEFORE your glPushAttrib. > > Either of these *should* fix up any problems you might have in a > clean manner. Urrrggggg ... brainnn ... can't ... quite .... reach ... Hold on, let me find a stool. Ok, that's better ... I'll give it a try in my sky code ... Here's what I get now: no matching function for call to `ssgEntity::hasState ()' no matching function for call to `ssgEntity::getState ()' A check of ssg.h indicates that these are indeed not members of ssgEntity. But, the compiler lets me get away with this ... sound reasonable? ssgLeaf *f = (ssgLeaf *)e; if ( f -> hasState () ) f->getState()->apply() ; I'll play around with this some more. I'm still having a touch of bad luck with GL_DEPTH_TEST, but I'm forcing this in other places in my code too. Could be that I'm entering the code with it off and since the sky code is actually preserving the state rather than turning it [back] on when it is done, I could be exiting they sky rendering section with the state set different now. Curt. -- Curtis Olson Human Factors Research Lab Flight Gear Project Twin Cities cu...@hf... cu...@fl... Minnesota http://www.menet.umn.edu/~curt http://www.flightgear.org |