PDA

View Full Version : Example of use of Pop/PushAttrib?



08-07-2000, 05:53 AM
Who can give me an example about a "cool" use of PopAttrib and PushAttrib?

Bob
08-07-2000, 07:54 AM
Push/PopAttrib is good when you are calling functions, and don't know if a certain state is enabled/disabled, and you need to turn it on/off.




void foobar(void)
{
// hmm, wonder if depthdest is enabled or not?
// ... and is fogging enabled or not?

glPushAttrib(GL_ENABLE_BIT);
glEnable(GL_DEPTH_TEST); // make sure depthtest is enabled
glDisable(GL_FOG); // make sure fogging is disabled

// draw objects here
.
.
.

// now we restore all flags to the state they had before we entered foobar()
glPopAttrib()
}


This is usefull if you want to keep fogging/depthtest in the same state after foobar() as you had before you entered foobar().

ngill
08-07-2000, 08:03 AM
what's up with the word foobar in the programming world? I see it all the time.

Pauly
08-07-2000, 09:54 AM
"Foobar" - I'm not sure.

But "Fubar" here in Manchester usually means "****ed Up Beyond All Recognition" maybe its the same with a different spelling?

Paul.

Bob
08-08-2000, 12:49 AM
"Foo" is a generic word, and it means something like "anything", or "any kind of object", if I get it right. But where "bar" comes into the picture, I have no idea http://www.opengl.org/discussion_boards/ubb/tongue.gif