Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class ColorBufferState

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.BufferState
          extended by org.j3d.aviatrix3d.ColorBufferState
All Implemented Interfaces:
java.lang.Comparable, BufferStateRenderable, Renderable

public class ColorBufferState
extends BufferState
implements BufferStateRenderable

Describes attributes used when interacting with the colour buffer.

Including this state class in the global setup automatically enables colour buffering. If an instance of this state is not included in the scene, the default values, and depth testing are enabled automatically. Use this class to override the defaults, or to deliberately disable depth testing.

The default setup for this class has all 4 colour channels enabled:

Version:
$Revision: 2.4 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.BufferState
lastParent, liveCount, parentList
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Fields inherited from interface org.j3d.aviatrix3d.rendering.BufferStateRenderable
ACCUMULATION_BUFFER, COLOR_BUFFER, DEPTH_BUFFER, GENERAL_BUFFER, STENCIL_BUFFER
 
Constructor Summary
ColorBufferState()
          Constructs a state set with default values.
 
Method Summary
 boolean checkClearBufferState()
          Check to see if this buffer should be cleared at the start of this run.
 void clearBufferState(javax.media.opengl.GL gl)
          Restore all state to the default values.
 int compareTo(ColorBufferState cbs)
          Compares this object with the specified object for order.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(ColorBufferState cbs)
          Compares this object with the specified object to check for equivalence.
 boolean equals(java.lang.Object o)
          Compare this object for equality to the given object.
 float getAlpha()
          Get the current alpha channel clear value
 float getBlue()
          Get the current blue channel clear value
 int getBufferBitMask()
          Get the GL buffer bit flag that this state class represents.
 int getBufferType()
          Get the type of buffer this state represents.
 float getGreen()
          Get the current green channel clear value
 float getRed()
          Get the current red channel clear value
 boolean isAlphaEnabled()
          Check to see if the alpha channel is currently enabled
 boolean isBlueEnabled()
          Check to see if the blue channel is currently enabled
 boolean isGreenEnabled()
          Check to see if the green channel is currently enabled
 boolean isRedEnabled()
          Check to see if the red channel is currently enabled
 void setBufferState(javax.media.opengl.GL gl)
          Issue ogl commands needed for this buffer to set the initial state, including the initial enabling.
 void setClearBufferState(boolean clear)
          Set the flag for whether the buffer state should be cleared when this state object is executed.
 void setClearColor(float red, float green, float blue, float alpha)
          Set the value that each of the colour channels should be cleared to.
 void setColorMask(boolean red, boolean green, boolean blue, boolean alpha)
          Set the flags describing which channels should be enabled in the colour buffer.
 void updateBufferState(javax.media.opengl.GL gl)
          Issue ogl commands needed for this component to change the state, assuming that it is already enabled.
 
Methods inherited from class org.j3d.aviatrix3d.BufferState
addParent, getParents, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorBufferState

public ColorBufferState()
Constructs a state set with default values.

Method Detail

getBufferType

public int getBufferType()
Get the type of buffer this state represents.

Specified by:
getBufferType in interface BufferStateRenderable
Returns:
One of the _BUFFER constants

getBufferBitMask

public int getBufferBitMask()
Get the GL buffer bit flag that this state class represents. Used for bulk clearing all the states at once.

Specified by:
getBufferBitMask in interface BufferStateRenderable
Returns:
The bit state constant for Stencil Buffers

checkClearBufferState

public boolean checkClearBufferState()
Check to see if this buffer should be cleared at the start of this run. If it should be, add the bit mask from this state to the global list.

Specified by:
checkClearBufferState in interface BufferStateRenderable
Returns:
true if the state should be cleared

setBufferState

public void setBufferState(javax.media.opengl.GL gl)
Issue ogl commands needed for this buffer to set the initial state, including the initial enabling.

Specified by:
setBufferState in interface BufferStateRenderable
Parameters:
gl - The gl context to draw with

updateBufferState

public void updateBufferState(javax.media.opengl.GL gl)
Issue ogl commands needed for this component to change the state, assuming that it is already enabled.

Specified by:
updateBufferState in interface BufferStateRenderable
Parameters:
gl - The gl context to draw with

clearBufferState

public void clearBufferState(javax.media.opengl.GL gl)
Restore all state to the default values.

Specified by:
clearBufferState in interface BufferStateRenderable
Parameters:
gl - The gl context to draw with

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The objec to be compared
Returns:
-1, 0 or 1 depending on order
Throws:
java.lang.ClassCastException - The specified object's type prevents it from being compared to this Object

equals

public boolean equals(java.lang.Object o)
Compare this object for equality to the given object.

Specified by:
equals in interface Renderable
Overrides:
equals in class java.lang.Object
Parameters:
o - The object to be compared
Returns:
True if these represent the same values

setClearBufferState

public void setClearBufferState(boolean clear)
                         throws InvalidWriteTimingException
Set the flag for whether the buffer state should be cleared when this state object is executed.

Parameters:
clear - True if the buffer should be cleared when this is the first state to be used in the current operation
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

setColorMask

public void setColorMask(boolean red,
                         boolean green,
                         boolean blue,
                         boolean alpha)
                  throws InvalidWriteTimingException
Set the flags describing which channels should be enabled in the colour buffer.

Parameters:
red - true if the red channel should be enabled
green - true if the green channel should be enabled
blue - true if the blue channel should be enabled
alpha - true if the alpha channel should be enabled
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

isRedEnabled

public boolean isRedEnabled()
Check to see if the red channel is currently enabled

Returns:
true if the red channel is currently being written

isGreenEnabled

public boolean isGreenEnabled()
Check to see if the green channel is currently enabled

Returns:
true if the green channel is currently being written

isBlueEnabled

public boolean isBlueEnabled()
Check to see if the blue channel is currently enabled

Returns:
true if the blue channel is currently being written

isAlphaEnabled

public boolean isAlphaEnabled()
Check to see if the alpha channel is currently enabled

Returns:
true if the alpha channel is currently being written

setClearColor

public void setClearColor(float red,
                          float green,
                          float blue,
                          float alpha)
                   throws InvalidWriteTimingException
Set the value that each of the colour channels should be cleared to. The values are automatically clamped by OpenGL to the range [-1,1].

Parameters:
red - The red channel clear value
green - The green channel clear value
blue - The blue channel clear value
alpha - The alpha channel clear value
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data update callback method

getRed

public float getRed()
Get the current red channel clear value

Returns:
The current red channel clear value [-1,1]

getGreen

public float getGreen()
Get the current green channel clear value

Returns:
The current green channel clear value [-1,1]

getBlue

public float getBlue()
Get the current blue channel clear value

Returns:
The current blue channel clear value [-1,1]

getAlpha

public float getAlpha()
Get the current alpha channel clear value

Returns:
The current alpha channel clear value [-1,1]

compareTo

public int compareTo(ColorBufferState cbs)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
cbs - The attributes instance to be comcbsred
Returns:
-1, 0 or 1 depending on order

equals

public boolean equals(ColorBufferState cbs)
Compares this object with the specified object to check for equivalence.

Parameters:
cbs - The attributes instance to be compared
Returns:
true if the objects represent identical values

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org