Class Material
java.lang.Object
com.codename1.gpu.Material
A declarative description of how a surface should be shaded. The 3D engine is
responsible for translating a material into a platform shader (GLSL on OpenGL
ES and WebGL, Metal Shading Language on iOS); applications never write shader
source. A material combines a lighting model (
Type), a base color, an
optional texture and pipeline RenderState.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe built in lighting model used to shade a surface. -
Constructor Summary
ConstructorsConstructorDescriptionMaterial()Creates an unlit white material.Material(Material.Type type) Creates a material of the supplied type. -
Method Summary
Modifier and TypeMethodDescriptionintgetColor()Returns the base color as a packed ARGB integer.Returns the pipeline render state.Returns a stable string identifying the shader variant required by this material.floatReturns the Phong specular exponent.Returns the diffuse texture, or null when the material is untextured.getType()Returns the lighting model.setColor(int argb) Sets the base color as a packed ARGB integer (0xAARRGGBB).setRenderState(RenderState renderState) Sets the pipeline render state.setShininess(float shininess) Sets the Phong specular exponent (used only byType.PHONG).setTexture(Texture texture) Sets the diffuse texture.setType(Material.Type type) Sets the lighting model.
-
Constructor Details
-
Material
public Material()Creates an unlit white material. -
Material
Creates a material of the supplied type.
Parameters
type: the lighting model
-
-
Method Details
-
getType
Returns the lighting model. -
setType
Sets the lighting model.
Parameters
type: the lighting model
Returns
this material for chaining
-
getColor
public int getColor()Returns the base color as a packed ARGB integer. -
setColor
Sets the base color as a packed ARGB integer (0xAARRGGBB).
Parameters
argb: the packed ARGB color
Returns
this material for chaining
-
getTexture
Returns the diffuse texture, or null when the material is untextured. -
setTexture
-
getShininess
public float getShininess()Returns the Phong specular exponent. -
setShininess
Sets the Phong specular exponent (used only by
Type.PHONG).Parameters
shininess: the specular exponent
Returns
this material for chaining
-
getRenderState
Returns the pipeline render state. -
setRenderState
Sets the pipeline render state.
Parameters
renderState: the render state
Returns
this material for chaining
-
getShaderKey
Returns a stable string identifying the shader variant required by this material. Backends use it together with the mesh
VertexFormatto cache generated and compiled shader programs. The key intentionally depends only on properties that change the generated source, not on values such as the color which are passed as uniforms.Returns
a shader variant cache key
-