PDA

View Full Version : Restarting opengl atributes



slarranaga
02-02-2010, 04:28 AM
Hi, i using opengl in a project where i can draw some geometrical figures and it works pretty well (state 1).

Then, in a special state of my program i would like to render a WRML file using a method that is already define (state 2). That works fine too ..

The problem is that when i come back to the state 1, the figura are being draw but the color is not coming out. The color is something like beige.

Something is happening inside the method to render WRML that chage some parameter on opengl and i dont know how to revert the changes.

This are the opengl sentences that the method does:

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslated( translation[0], translation[1], translation[2] );
glScaled(scale[0], scale[1], scale[2]);

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_FOG); // this is a global attribute
glDisable(GL_TEXTURE_2D);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
glCullFace(GL_BACK);

glEnable(GL_LIGHTING);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable(GL_NORMALIZE);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_BLEND);
glShadeModel(GL_SMOOTH);


glDisable(GL_LIGHTING);

glDisable(GL_BLEND);
glDisable(GL_CULL_FACE);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

glMatrixMode(GL_MODELVIEW);
glPopMatrix();


Any suggestions?
Thanks in advance.

slarranaga
02-02-2010, 07:46 AM
well i have fixed my problem using

glPushAttrib (0xffffffff);

and

glPopAttrib();

this save the attibutes of open gl.. it works like pushMatrix and popMatrix