Hi,
Actually, whenever some material has to be setup, we have to call glMaterial for every parameter of it. Couldn’t we create some kind of material objects ? Something like :
GLuint my_material[2];
GLfloat blue_color[] = {1,0,0,1};
glGenMaterials(1, my_materials);
glBindMaterial(GL_FRONT, my_materials[0]);
glBindMaterial(GL_BACK, my_materials[1]);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_color);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 100.f);
Then, using a material would consist in a single call to :
glBindMaterial(GL_FRONT, my_materials[0]);
and why not :
glBindMaterial(GL_FRONT_AND_BACK, my_materials[0]);
On the same scheme, lights could be setup with :
GLuint my_light;
GLfloat yellow_color[] = [1,1,0,1};
glGenLights(1, &my_light);
glBindLight(GL_LIGHT0, my_light);
glLightfv(GL_LIGHT0, GL_SPECULAR, yellow_color);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.001f);
Then use it with :
glBindLight(GL_LIGHT0, my_light);
and certainly this would also be allowed :
glBindLight(GL_LIGHT5, my_light);
I know the concept of glGenX/glBindX/glDeleteX is redundant in OpenGL, but currently I’m tired of calling thousands of glLight and glMaterial commands. I know that display lists can help, but still display lists are less flexible (a light that has been setup on GL_LIGHT0 in a list will never end on GL_LIGHT1).
[This message has been edited by vincoof (edited 05-07-2003).]