# Visualization Library A lightweight C++ OpenGL middleware for 2D/3D graphics | [Home] [Tutorials] [All Classes] [Grouped Classes]

# vl::DepthSortCallback Class Reference

The DepthSortCallback class sorts the primitives of the Geometry object bound to the Actor in which the callback is installed. More...

`#include <DepthSortCallback.hpp>`

Inheritance diagram for vl::DepthSortCallback:

List of all members.

## Classes
class | Line
class | Point
class | PrimitiveZ
class | Quad
class | Sorter_Back_To_Front
class | Sorter_Front_To_Back
class | Triangle
## Public Member Functions
| DepthSortCallback ()
virtual const char * | className ()
| Returns the name of the class.
virtual void | operator() (const Camera *cam, Actor *actor, Renderable *renderable, const Shader *, int pass)
| Performs the actual sorting.
template<typename T , typename deT >
void | sort (deT *polys, std::vector< Point< T > > &sorted_points, std::vector< Line< T > > &sorted_lines, std::vector< Triangle< T > > &sorted_triangles, std::vector< Quad< T > > &sorted_quads)
ESortMode | sortMode () const
void | setSortMode (ESortMode sort_mode)
void | invalidateCache ()
| Forces sorting at the next rendering.
## Protected Attributes
ref< ArrayFVec3 > | mEyeSpaceVerts
std::vector< PrimitiveZ > | mPrimitiveZ
std::vector< PointUInt > | mSortedPointsUInt
std::vector< LineUInt > | mSortedLinesUInt
std::vector< TriangleUInt > | mSortedTrianglesUInt
std::vector< QuadUInt > | mSortedQuadsUInt
std::vector< PointUShort > | mSortedPointsUShort
std::vector< LineUShort > | mSortedLinesUShort
std::vector< TriangleUShort > | mSortedTrianglesUShort
std::vector< QuadUShort > | mSortedQuadsUShort
std::vector< PointUByte > | mSortedPointsUByte
std::vector< LineUByte > | mSortedLinesUByte
std::vector< TriangleUByte > | mSortedTrianglesUByte
std::vector< QuadUByte > | mSortedQuadsUByte
vl::mat4 | mCacheMatrix
ESortMode | mSortMode

## Detailed Description

The DepthSortCallback class sorts the primitives of the Geometry object bound to the Actor in which the callback is installed.

This callback in order to work requires the following conditions:

- The Actor must be bound to a Geometry
- The bound Geometry must have a Geometry::vertexArray() of type ArrayFVec3
- Sorts only DrawElementsUInt/UShort/UByte objects with primitive type: PT_POINTS, PT_LINES, PT_TRIANGLES, PT_QUADS

Despite the fact that the condition list seems to be quite limiting it actually covers the most common usage cases. Furthermore the use of DrawElements* and the primitive types PT_POINTS, PT_LINES, PT_TRIANGLES, PT_QUADS grant the maximum flexibility.

Note:

- This callback works well with different LODs.
- This callback works well with multipassing, the sorting is done only once.

Remarks:

- The sorting is based on the position of the vertices as specified by Geometry::vertexArray() and for obvious reasons cannot take into consideration transformations made in the vertex shader or in the geometry shader.
- The sorting is performed on a per Primitives basis. For example, if a Geometry has 2 Primitives A and B bound to it, then the polygons, lines or points of A will alway be rendered before the ones specified by B.

See also:
  Transparency and Polygon Depth Sorting Tutorial

## Constructor & Destructor Documentation

vl::DepthSortCallback::DepthSortCallback | ( |  | ) | `[inline]`

## Member Function Documentation

virtual const char* vl::DepthSortCallback::className | ( |  | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::Object.

virtual void vl::DepthSortCallback::operator() | ( | const Camera * | cam,
|  | Actor * | actor,
|  | Renderable * | renderable,
|  | const Shader * | ,
|  | int | pass |
| ) |  |  | `[inline, virtual]`

Performs the actual sorting.

Implements vl::ActorRenderingCallback.

template<typename T , typename deT >

void vl::DepthSortCallback::sort | ( | deT * | polys,
|  | std::vector< Point< T > > & | sorted_points,
|  | std::vector< Line< T > > & | sorted_lines,
|  | std::vector< Triangle< T > > & | sorted_triangles,
|  | std::vector< Quad< T > > & | sorted_quads |
| ) |  |  | `[inline]`

ESortMode vl::DepthSortCallback::sortMode | ( |  | ) | const`[inline]`

void vl::DepthSortCallback::setSortMode | ( | ESortMode | sort_mode | ) | `[inline]`

void vl::DepthSortCallback::invalidateCache | ( |  | ) | `[inline]`

Forces sorting at the next rendering.

## Member Data Documentation

ref<ArrayFVec3> vl::DepthSortCallback::mEyeSpaceVerts`[protected]`

std::vector<PrimitiveZ> vl::DepthSortCallback::mPrimitiveZ`[protected]`

std::vector<PointUInt> vl::DepthSortCallback::mSortedPointsUInt`[protected]`

std::vector<LineUInt> vl::DepthSortCallback::mSortedLinesUInt`[protected]`

std::vector<TriangleUInt> vl::DepthSortCallback::mSortedTrianglesUInt`[protected]`

std::vector<QuadUInt> vl::DepthSortCallback::mSortedQuadsUInt`[protected]`

std::vector<PointUShort> vl::DepthSortCallback::mSortedPointsUShort`[protected]`

std::vector<LineUShort> vl::DepthSortCallback::mSortedLinesUShort`[protected]`

std::vector<TriangleUShort> vl::DepthSortCallback::mSortedTrianglesUShort`[protected]`

std::vector<QuadUShort> vl::DepthSortCallback::mSortedQuadsUShort`[protected]`

std::vector<PointUByte> vl::DepthSortCallback::mSortedPointsUByte`[protected]`

std::vector<LineUByte> vl::DepthSortCallback::mSortedLinesUByte`[protected]`

std::vector<TriangleUByte> vl::DepthSortCallback::mSortedTrianglesUByte`[protected]`

std::vector<QuadUByte> vl::DepthSortCallback::mSortedQuadsUByte`[protected]`

vl::mat4 vl::DepthSortCallback::mCacheMatrix`[protected]`

ESortMode vl::DepthSortCallback::mSortMode`[protected]`

The documentation for this class was generated from the following file:

- E:/VisualizationLibrary/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vl/DepthSortCallback.hpp

Visualization Library v2009.08 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Sun Nov 8 14:28:56 2009.
Permission is granted to use this page to write and publish articles regarding Visualization Library.