Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members Related Pages
sglLayer Class Reference
#include <sglLayer.hpp>
Inheritance diagram for sglLayer::
List of all members.
Detailed Description
An sglLayer node is a specialized group that aids in rendering coplaner polygons without visual artifacts caused by z-fighting (or flimmering) in the depth buffer. The children of an sglLayer are assigned a visual priority based on their order in the group. The first child in the group (at index 0), often called the base layer, defines depth values that will be written into the depth buffer. Every child after that is then rendered in order on top of the base layer.
In order for the sglLayer to work properly, there are several restrictions:
- The layers should be coplanar. Every pixel of child n+1 will be rendered in front of child n, regardless of their depth values.
- The geometry for child layers 1..n, must be completely contained within boundary of the geometry for the base layer (child 0).
- The use of an sglLayer node will disable state sorting of the geometry contained in the group.
There are two methods that can be used for rendering the layers:
- eMULTIPASS where each layer is rendered in order, but multiple passes are required of the base layer.
- eSTENCIL where only one pass is required of each layer, but the stencil buffer is required. This method may perform better than LAYER_MULTIPASS, but is only available on some frame buffers.
Note: Use of the sglPolygonOffset statelet can provide much better performance than an sglLayer node without any of the above restrictions, at the cost of some visual quality. It is important to remember though, that sglPolygonOffset only works with polygons, whereas an sglLayer may also contain lines and points. Another alternative is to manipulate the OpenGL depth range before drawing layers using the sglDepthRange statelet, but the values needed to get the desired affect can vary from platform to platform and will affect the values written into the depth buffer.
Example:
sglLayer *layer = new sglLayer(sglLayer::eSTENCIL);
for (int ix=4; ix>=0; --ix)
{
sglGeode *geode = new sglGeode();
:
:
layer->addChild(geode);
}
-
Todo:
-
Add support for intersect traversal.
Add support for the pick traversal.
Definition at line 97 of file sglLayer.hpp.
Member Enumeration Documentation
enum sglLayer::LayerMethodEnum
|
|
|
The two different layering modes.
-
Enumeration values:
-
eMULTIPASS
|
the multipass rendering approach. |
eSTENCIL
|
the single pass approach requiring stencil planes. |
Definition at line 101 of file sglLayer.hpp. |
Constructor & Destructor Documentation
|
Constructor -
Parameters:
-
method
|
Sets the method to be used: eMULTIPASS or eSTENCIL (defaults to eMULTIPASS). |
|
sglLayer::~sglLayer (
|
) [virtual]
|
|
Member Function Documentation
|
Set the method to use for rendering the layers. -
Parameters:
-
method
|
The method which is one of eMULTIPASS or eSTENCIL. |
|
|
Get the current method for rendering the layers. -
Parameters:
-
The
|
current method which is one of eMULTIPASS or eSTENCIL. |
Definition at line 126 of file sglLayer.hpp. |
void sglLayer::setStencilMask (
|
GLuint mask )
|
|
|
Set the mask to use with the stencil buffer (for eSTENCIL method only). -
Parameters:
-
mask
|
The mask defaults to 0x1. The bit(s) set should not exceed the stencil buffer depth. |
|
GLuint sglLayer::getStencilMask (
|
) [inline]
|
|
|
Get the mask to use with the stencil buffer. -
Returns:
-
the current stencil mask.
Definition at line 137 of file sglLayer.hpp. |
virtual sglNode* sglLayer::clone (
|
unsigned int mode ) const [virtual]
|
|
|
Make a copy of the scenegraph rooted at this node. -
Parameters:
-
mode
|
Bit masks to control the behaviour of the clone. These are OR-ed together from the mode values in sglObject::CloneModeEnum. |
-
Returns:
-
Pointer to root of cloned scene graph.
Reimplemented from sglGroup. |
virtual void sglLayer::printInfo (
|
ostream & ostrm,
|
|
const char * indent_string ) const [virtual]
|
|
|
Output the state of this node to the specified ostream. -
Parameters:
-
ostrm
|
the ostream to which the output is sent |
indent_string
|
the string (usually spaces) that is output at the beginning of every line of output |
Reimplemented from sglGroup. |
virtual void sglLayer::cull (
|
sglCull< float > & trav_state,
|
|
unsigned int cull_flags ) const [protected, virtual]
|
|
|
The single precision cull traversal function that culls out subgraphs that do not lie in the view frustum (stored in the sglCull parameter). Subclasses must implement this function. The entry point for user-friendly culling is in the sglScene class. -
Parameters:
-
trav_state
|
The single precision traversal state that collects all the state and geometry information that passes the cull. |
cull_flags
|
Bit flags that indicate which planes of the view frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free drawing can be accomplished with cull_flags = 0. |
Reimplemented from sglGroup. |
virtual void sglLayer::cull (
|
sglCull< double > & trav_state,
|
|
unsigned int cull_flags ) const [protected, virtual]
|
|
|
The double precision cull traversal function that culls out subgraphs that do not lie in the view frustum (stored in the sglCull parameter). Subclasses must implement this function. The entry point for user-friendly culling is in the sglScene class. -
Parameters:
-
trav_state
|
The single precision traversal state that collects all the state and geometry information that passes the cull. |
cull_flags
|
Bit flags that indicate which planes of the view frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free drawing can be accomplished with cull_flags = 0. |
Reimplemented from sglGroup. |
The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:08 2002 for SGL by
1.2.6 written by Dimitri van Heesch,
© 1997-2001