The EZwgl provides a few handy routines for packing
lighting properties together. They can be used to save
a few EZ_***fv
calls.
EZ_Material *EZ_DefineMaterial(float *definitions)
This function define a material from the given defintion and return a pointer to the allocated material structure.
void EZ_BindMaterial(int face, EZ_Material *mat)
This function bind the defined material mat
to face
.
Here is an example.
static float mat[] = { EZ_SPECULAR_F, 1.0,1.0,1.0,1.0, EZ_DIFFUSE_F, 0.8, 0.0, 0.8, 0.0 EZ_NULL_F, }; EZ_Material material = EZ_DefineMaterial(mat); ... ... EZ_BindMaterial(EZ_FRONT_AND_BACK, material); ... ...
Predefined Materials
The EZwgl includes a few predefined materials. They can
be retrieved via
EZ_Material *EZ_GetDefaultMaterial(int which)
Here is a list of the predefined materials.
Symbolic Name | property values |
EZ_SILVER | emission (0.0,0.0,0.0,1.0) | ambient (0.19125, 0.0735, 0.0225, 1.0) | diffuse (0.7038, 0.27048, 0.0828, 1.0) | specular ( 0.256777, 0.137622, 0.086014, 1.0) | shininess 1.0 | color indices 0.0, 0.0, 1.0 |
EZ_SILVER_S | emission (0.0,0.0,0.0,1.0) | ambient (0.23125, 0.23125, 0.23125, 1.0) | diffuse (0.2775, 0.2775, 0.2775, 1.0) | specular ( 0.773911, 0.773911, 0.773911, 1.0) | shininess 7.0 | color indices 0.0, 0.0, 1.0 |
EZ_GOLD | emission (0.0,0.0,0.0,1.0) | ambient (0.24725, 0.1995, 0.0745, 1.0) | diffuse (0.75164, 0.60648, 0.22648, 1.0) | specular (0.628281, 0.555802, 0.366065, 1.0) | shininess 4.0 | color indices 0.0, 0.0, 1.0 |
EZ_GOLD_S | emission (0.0,0.0,0.0,1.0) | ambient (0.24725, 0.2245, 0.0645, 1.0) | diffuse (0.34615, 0.3143, 0.0903, 1.0) | specular (0.797357, 0.723991, 0.208006, 1.0) | shininess 6.5 | color indices 0.0, 0.0, 1.0 |
EZ_BRASS | emission (0.0,0.0,0.0,1.0) | ambient (0.329412, 0.223529, 0.027451, 1.0) | diffuse (0.780392, 0.568627, 0.113725, 1.0) | specular (0.992157, 0.941176, 0.807843, 1.0) | shininess 2.2 | color indices 0.0, 0.0, 1.0 |
EZ_COPPER | emission (0.0,0.0,0.0,1.0) | ambient (0.19125, 0.0735, 0.0225, 1.0) | diffuse (0.7038, 0.27048, 0.0828, 1.0) | specular (0.256777, 0.137622, 0.086014, 1.0) | shininess 1.0 | color indices 0.0, 0.0, 1.0 |
EZ_COPPER_S | emission (0.0,0.0,0.0,1.0) | ambient (0.2295, 0.08825, 0.0275, 1.0) | diffuse (0.5508, 0.2118, 0.066, 1.0) | specular (0.580594, 0.223257, 0.0695701, 1.0) | shininess 4.1 | color indices 0.0, 0.0, 1.0 |
Symbolic Name | property values |
EZ_BRONZE | emission (0.0,0.0,0.0,1.0) | ambient (0.2125, 0.1275, 0.054, 1.0) | diffuse (0.714, 0.4284, 0.18144, 1.0) | specular ( 0.393548, 0.271906, 0.166721, 1.0) | shininess 2.2 | color indices 0.0, 0.0, 1.0 |
EZ_RUBY | emission (0.0,0.0,0.0,1.0) | ambient (0.1745, 0.01175, 0.01175, 1.0) | diffuse (0.61424, 0.04136, 0.04136, 1.0) | specular (0.727811, 0.626959, 0.626959, 1.0) | shininess 6.5 | color indices 0.0, 0.0, 1.0 |
EZ_TURQUOISE | emission (0.0,0.0,0.0,1.0) | ambient (0.1, 0.18725, 0.1745, 1.0) | diffuse ( 0.396, 0.74151, 0.69102, 1.0) | specular ( 0.297254, 0.30829, 0.306678, 1.0) | shininess 1.0 | color indices 0.0, 0.0, 1.0 |
EZ_JADE | emission (0.0,0.0,0.0,1.0) | ambient ( 0.135, 0.2225, 0.1575, 1.0) | diffuse ( 0.54, 0.89, 0.63, 1.0) | specular ( 0.316228, 0.316228, 0.316228, 1.0) | shininess 1.2 | color indices 0.0, 0.0, 1.0 |
EZ_EMERALD | emission (0.0,0.0,0.0,1.0) | ambient ( 0.0215, 0.1745, 0.0215, 1.0) | diffuse ( 0.07568, 0.61424, 0.07568, 1.0) | specular ( 0.633, 0.727811, 0.633, 1.0) | shininess 6.4 | color indices 0.0, 0.0, 1.0 |
EZ_PERAL | emission (0.0,0.0,0.0,1.0) | ambient ( 0.25, 0.20725, 0.20725, 1.0) | diffuse ( 1.0, 0.829, 0.829, 1.0) | specular ( 0.296648, 0.296648, 0.296648, 1.0) | shininess 1.0 | color indices 0.0, 0.0, 1.0 |
EZ_LightSrc *EZ_DefineLight(float *definitions)
This function define a light source from the given defintion and return a pointer to the allocated light source structure.
void EZ_BindLight(int lightNum, EZ_LightSrc *lsrc)
This function bind the packed light source definition lsrc
to
light number lightNum
.
Here is an example.
static float light2[] =
EZ_POSITION_F, 0.0,5.0,10.0,1.0, EZ_SPECULAR_F, 1.0,1.0,1.0,1.0, EZ_SPOT_DIRECTION_F, 0.0,0.0,-1.0,0.0, EZ_SPOT_CUTOFF_F, 30.0, EZ_SPOT_EXPONENT_F, 10.0, EZ_NULL_F, ; EZ_LightSrc *lsrc2 = EZ_DefineLight(light2); ... ... EZ_BindLight(EZ_LIGHT4, lsrc2); ... ...
EZ_LightModel *EZ_DefineLightModel(float *definitions)
This function define a packed light model from the given defintion and return a pointer to the allocated light model structure.
void EZ_BindLightModel(EZ_LightModel *lmodel)
This function replace the current light model by the packed light
model lmodel
.
Here is an example.
static float lmodelDef[] =
EZ_AMBIENT_F, 0.0,0.4,0.4,0.0, EZ_LIGHT_MODEL_LOCAL_VIEWER, 1.0, EZ_LIGHT_MODEL_TWO_SIDE, 1.0, EZ_NULL_F, ; EZ_LightModel *lmodel = EZ_DefineLightModel(lmdelDef); ... ... EZ_BindLightModel(lmodel); ... ...