Re: [Plib-devel] Texture and blend modes
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2000-08-21 23:08:44
|
"Curtis L. Olson" wrote: > > Steve Baker writes: > > glPushAttrib/glPopAttrib ? > > > > Call one in pre-draw and the other in post-draw. > > Those are nifty little calls, when did they get added? :-) Erm - was there an OpenGL before 1.0 ? :-) > 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. 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. > This unfortunately yields rendering problems ... can you see anything > obvious that I am doing wrong or misunderstanding here? Well, apart from the slight subtlety I explain above, as I mentioned before - Mesa has bugs in glPush/Pop attrib (or at least *had* - past tense - I havn't played with recent versions). -- Steve Baker HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sourceforge.net http://tuxaqfh.sourceforge.net http://tuxkart.sourceforge.net http://prettypoly.sourceforge.net |