- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r);
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r);
- glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emission.r);
- glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
+ if(set_current(this))
+ {
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emission.r);
+ glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
+ }
+}
+
+void Material::unbind()
+{
+ set_current(0);