View Full Version : how to undo glMaterial()?
05-15-2003, 02:42 PM
If some objects are rendered using material commands, glMaterial()'s, and then another set of objects need to be rendered using glColorMaterial(), what commands should I make between these two renderings so that the glMaterial()'s won't affect the 2nd set of objects' rendering? Please help. Thanks.
You can push the GL_LIGHTING_BIT attribute group and pop it when done. Check out glPush/PopAttrib.
05-16-2003, 08:50 AM
I think glPushAttrib() and glPophAttrib() cannot solve my problem. The 1st set objects' rendering affects the 2nd set objects'. The 1st set objects' rendering is done by a 3rd party. I cannot place glPushAttrib() and glPophAttrib() there. And I cannot change the rendering sequence either. I really need to know how to disable their material setting. Please help. I will appreciate it very much.
05-16-2003, 09:00 AM
So do it outside the third party stuff.
//Call 3rd party stuff
// Draw your own stuff
It's either that or after you do the 3rd party stuff, you set the material back to the defaults (or whatever else you might want.) OpenGL is a state machine and the only way to "undo" a previously set state of something is with the push/pop stuff, or by setting the state back to the original value afterwards.
05-16-2003, 02:09 PM
Thanks for the replies. Could someone kindly tell me how to set the material back to the defaults? I cannot use attributes push/pop commands because my rendering is done in a function (subroutine) called by the 3rd party just before buffer swapping.
05-16-2003, 04:35 PM
There does not exist a command like "glSetDefault" or anything related to default parameters.
At best, you could check the spec and get the initial state so that you can repeat it.
For instance, the initial emissive reflectance is black, so reseting emissive color to "default" is equivalent to calling this :
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black);
You have to call glMaterial for everything like GL_SPECULAR, GL_DIFFUSE, GL_AMBIENT, GL_SHININESS... each with its own "default" value read from the spec. You already have downloaded the spec, didn't you ? http://www.opengl.org/discussion_boards/ubb/wink.gif
05-20-2003, 12:21 PM
It appears they finally fixed the posting problem...
Anyway... as I tried to post yesterday:
MSDN lists the defaults as follows:
GL_AMBIENT = (0.2, 0.2, 0.2, 1.0)
GL_DIFFUSE = (0.8, 0.8, 0.8, 1.0)
GL_SPECULAR = (0.0, 0.0, 0.0, 1.0)
GL_EMISSION = (0.0, 0.0, 0.0, 1.0)
GL_SHININESS = 0
Also, you could STILL do the push/pop stuff, though it might not seem quite as nice.
05-20-2003, 12:53 PM
Could someone tell me where to download the OpenGL spec mentioned in a previous post? Thanks so much.
05-21-2003, 03:49 AM
check out www.opengl.org (http://www.opengl.org/developers/documentation/index.html) ! http://22.214.171.124/discussion_boards/ubb/wink.gif
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.