This allows the creation of material properties, such as ambient, diffuse, specular and transparant surfaces. Note that a material is not applied to a specific object, but rather a material is set in force, and each object is rendered with that material until the material is changed. If no material is selected then a default one is used.
Note that in OpenGL the colour intensities are set with 4 values. The first three are normal RGB values. The last is the alpha value. In this use of OpenGL the fourth value will be used for transparancy, if the material is set to be Tranparant.
There is a file format for adding materials into 'native' files. VRML already includes materials.
#define NOMATERIAL ((Material *)0) typedef enum{ FlatShading, SmoothShading } ShadingModel; typedef enum{ Opaque,Transparant } Opacity; typedef struct{ GLenum model; /*GL_FLAT or GL_SMOOTH*/ GLfloat ambient[4]; /*rgb alpha*/ GLfloat diffuse[4]; /*rgb alpha*/ GLfloat specular[4]; /*rgb alpha*/ GLfloat shininess[1]; /*shininess for specular*/ Opacity opacity; /*transparant means glEnable(GL_BLEND)*/ } Material, MaterialPtr; Material *newMaterial(ShadingModel model, float ambient[4], float diffuse[4], float specular[4], float shininess, Opacity opacity); /*creates the material properties used by objects and faces*/ void setDefaultMaterial(void); /*sets a material for use when both object and face have NULL materials*/ void setMaterial(Material *material); /*sets the current material in OpenGL*/ Material *cloneMaterial(Material *mat); /*makes a copy of the material*/