In OpenGL with C#, I am setting ambient and diffuse material properties for a complied glList containing triangles in Windows Paint event.
Typically I use,
void Control_Paint(object sender, PaintEventArgs e)
{
....
float[] CustomColor = { 0.5f, 0.0f, 0.5f, 0.8f };
if(UserInputColor == true)
gl.Materialfv(gl.FRONT_AND_BACK, gl.AMBIENT_AND_DIFFUSE, CustomColor);
gl.CallList(listId);
....
....
}
In the first call
UserInputColor
value is true.
In the subsequent calls of the Paint event
UserInputColor
value could be false.
I see that the material properties are retaining the previously set values in subsequent paint events.
In my case, I want to retain only the
gl.FRONT
&
gl.AMBIENT
settings at the end of Paint event. Retaining these values would make me to optimize on unnecessary setting of properties in every Paint event.
I do not want
gl.BACK
&
gl.DIFFUSE
to be retained if the
UserInputColor
variable is false. So I want to clear them off at the end of the event.
Is there a way to restore specific material properties after the execution of a compiled glList through any OpenGL command?