Material class

From Solid Graphics Wiki

Jump to: navigation, search
Material class
Namespace: SKL3D
Base type: (None)
Include: Skl3DDraw.h
Lib (Release): SKL.lib
Lib (Debug): SKL_D.lib

The Material class specifies a material properties using it's ambient, diffuse, specular, emissive, shininess attributes. The attributes are defined the same as OpenGL material attributes with the same name.


Default material class constructor does not initialize the material attributes to any value. This is on purpose for performance reasons. Other class constructors allow to initialize the material object by it's attributes values.


Field name Type Description
ambient Color Ambient color.
diffuse Color Diffuse color.
specular Color Specular color.
emissive Color Emissive color.
shininess float The shininess attribute value.


Method name Description
Initialize Initializes all color components of ambient color to 0.2f, diffuse color components to 0.8f, specular color components to 0.0f, emissive color components to 0.0f, shininess to 0.2f * 128. Alpha components of all attributes are initialized to 1.0f.
Apply Applies the material attributes to current OpenGL rendering context state (by calling OpenGL's glMaterialf function.
LoadFromTextFile Loads the material attributes from File as XML.
SaveToTextFile Saves the material attributes to File as XML.
LoadFromXML Loads the material attributes from XmlReader.
SaveToXML Saves the material attributes to MemoryBuffer as XML.


== Returns true if both material operands have the same attributes, otherwise false.
!= Returns true if both material operands do not have the same attributes, otherwise false.

Predefined material constants

The Material class defines these static constants: White, LightGray, DimGray, DarkGray, Gray, Black, Yellow, Red, Green, Blue, Emerald, Jade, Obsidian, Pearl, Ruby, Turguoise, Brass, Bronze, Chrome, Copper, Gold, Silver, BlackPlastic, CyanPlastic, GreenPlastic, RedPlastic, WhitePlastic, YellowPlastic, BlackRubber, CyanRubber, GreenRubber, RedRubber, WhiteRubber, YellowRubber. The constants can be accessed by the Material class scope, for example:

Material theColor( Material::Pearl );

See Also


SolidKit Library Documentation

Personal tools