public interface State
Nodes in a scene graph can set OpenGL attributes by calling OpenGL functions explicitly. Alternatively, these attributes can be set by applying a state class that implements this interface. This second alternative offers two advantages.
First, classes that implement this interface define standard collections
of OpenGL state attributes, with a convenient interface for getting and
setting those attributes. For example, color attributes can be set by
passing a Color
.
Second, states can be associated with nodes and shared among multiple nodes in a scene graph. Then, changes to any state's attributes are reflected in all nodes that share that state.
Classes that implement this interface have fields that correspond to OpenGL state attributes. States have methods that set and unset the values of these attribute fields. A state applies itself by calling relevant OpenGL functions for all attribute fields that are set. A state does not call OpenGL functions for fields that are not set.
States also have methods that determine whether or not an attribute field has been set and methods that get the values of a field. For attribute fields not set, these get methods return OpenGL default values.
Modifier and Type | Method and Description |
---|---|
void |
apply()
Applies this OpenGL state.
|
int |
getAttributeBits()
Gets the OpenGL attribute bits for this state.
|