class SG_EXPORT osg::Drawable

Pure virtual base class for drawable Geometry.

Inheritance:


Public Methods

[more] Drawable()
[more] Drawable(const Drawable& drawable, const CopyOp& copyop=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy
[more]virtual bool isSameKindAs(const Object* obj) const
[more]virtual const char* libraryName() const
[more]virtual const char* className() const
[more]inline const ParentList& getParents() const
Get the parent list of drawable.
[more]inline ParentList getParents()
Get the a copy of parent list of node.
[more]inline Node* getParent(const unsigned int i)
Get a single parent of Drawable.
[more]inline const Node* getParent(const unsigned int i) const
Get a single const parent of Drawable.
[more]inline const unsigned int getNumParents() const
Get the number of parents of node.
[more]inline void setStateSet(StateSet* state)
Set the StateSet attached to the Drawable.
[more]inline StateSet* getStateSet()
Get the attached StateSet
[more]inline const StateSet* getStateSet() const
Get the attached const StateSet
[more]void setSupportsDisplayList(const bool flag)
Set the drawable to it can or cannot be used in conjunction with OpenGL display lists.
[more]inline const bool getSupportsDisplayList() const
Get whether display lists are supported for this drawable instance
[more]void setUseDisplayList(const bool flag)
When set to true, force the draw method to use OpenGL Display List for rendering.
[more]inline const bool getUseDisplayList() const
Return whether OpenGL display lists are being used for rendering
[more]void dirtyDisplayList()
Force a recompile on next draw() of any OpenGL display list associated with this geoset
[more]void dirtyBound()
Dirty the bounding box, forcing a computeBound() on the next call to getBound().
[more]inline const BoundingBox& getBound() const
get bounding box of geoset.
[more]void compile(State& state)
Immediately compile this drawable into an OpenGL Display List.
[more]void setAppCallback(AppCallback* ac)
Set the AppCallback which allows users to attach customize the undating of an object during the app traversal
[more]AppCallback* getAppCallback()
Get the non const AppCallback
[more]const AppCallback* getAppCallback() const
Get the const AppCallback
[more]void setCullCallback(CullCallback* cc)
Set the CullCallback which allows users to attach customize the culling of Drawable during the cull traversal
[more]CullCallback* getCullCallback()
Get the non const CullCallback
[more]const CullCallback* getCullCallback() const
Get the const CullCallback
[more]void setDrawCallback(DrawCallback* dc)
Set the DrawCallback which allows users to attach customize the drawing of existing Drawable object
[more]DrawCallback* getDrawCallback()
Get the non const DrawCallback
[more]const DrawCallback* getDrawCallback() const
Get the const DrawCallback
[more]virtual void drawImmediateMode(State& state) = 0
draw directly ignoring an OpenGL display list which could be attached.
[more]static void deleteDisplayList(uint contextID, uint globj)
use deleteDisplayList instead of glDeleteList to allow OpenGL display list to cached until they can be deleted by the OpenGL context in which they were created, specified by contextID
[more]static void flushDeletedDisplayLists(uint contextID)
flush all the cached display list which need to be deleted in the OpenGL context related to contextID
[more]virtual bool getStats(Statistics&)
Collect Stistics count from Drawable
[more]virtual AttributeBitMask suppportsAttributeOperation() const
return the attributes supported by applyAttrbuteOperation() as an AttributeBitMask
[more]virtual AttributeBitMask applyAttributeOperation(AttributeFunctor&)
return the attributes successully applied in applyAttributeUpdate
[more]virtual void applyPrimitiveOperation(PrimitiveFunctor&)
apply the internal geometry as basic primitives to a PrimitiveFunctor
[more]inline void draw(State& state)
draw OpenGL primitives.

Public Members

[more]typedef std::vector<Node*> ParentList
A vector of osg::Node pointers which is used to store the parent(s) of drawable
[more]struct AppCallback: public osg::Referenced
[more]struct CullCallback: public osg::Referenced
[more]struct DrawCallback: public osg::Referenced
Callback attached to an Drawable which allows the users to customize the drawing of an exist Drawable object.
[more]typedef uint AttributeBitMaskenum AttributeBitMaskValues
class AttributeFunctor
class PrimitiveFunctor

Protected Fields

[more]ParentList _parents
[more]ref_ptr<StateSet> _dstate
[more]bool _supportsDisplayList
[more]bool _useDisplayList
[more]mutable BoundingBox _bbox
[more]mutable bool _bbox_computed
[more]ref_ptr<AppCallback> _appCallback
[more]ref_ptr<DrawCallback> _drawCallback
[more]ref_ptr<CullCallback> _cullCallback

Protected Methods

[more]Drawable& operator = (const Drawable&)
[more]virtual ~Drawable()
[more]virtual const bool computeBound() const = 0
compute the bounding box of the drawable.
[more]void addParent(osg::Node* node)
[more]void removeParent(osg::Node* node)

Protected Members

[more]typedef std::vector<uint> GLObjectList mutable GLObjectList _globjList
[more]typedef std::map<uint,std::set<uint> >static DeletedDisplayListCache DeletedDisplayListCache s_deletedDisplayListCache


Inherited from Object:

Public Methods

ovirtual Object* cloneType() const
ovirtual Object* clone(const CopyOp&) const
oinline void setDataVariance(const DataVariance dv)
oinline const DataVariance getDataVariance() const

Public Members

oenum DataVariance

Protected Fields

oDataVariance _dataVariance


Inherited from Referenced:

Public Methods

oinline void ref() const
oinline void unref() const
oinline void unref_nodelete() const
oinline const int referenceCount() const

Protected Fields

omutable int _refCount


Documentation

Pure virtual base class for drawable Geometry. Contains no drawing primitives directly, these are provided by subclasses such as osg::Geometry. State attributes for a Drawable are maintained in StateSet which the Drawable maintains a referenced counted pointer to. Both Drawable's and StateSet's can be shared for optimal memory usage and graphics performance.

Subclasses should provide an instance of getStats(Statistics *st) if the subclass contains drawing primitives. This member function should add the primitives it draws into the Statistics class; for example add the number of quads, triangles etc created. For an example see Geometry.cpp: getStats(osgUtil::Statistics *stat). Failure to implement this routine will only result in the stats displayed for your drawable being wrong. Another example is in the InfinitePlane class- this draws a normal geoset AND its own special set of quads, so this case of getPrims calls: the normal geoset stats gs->getStats(..), and then adds the number of quads rendered directly (it is rendered in a display list, but we do know how many quads are in the display list).

o Drawable()

o Drawable(const Drawable& drawable, const CopyOp& copyop=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy

ovirtual bool isSameKindAs(const Object* obj) const

ovirtual const char* libraryName() const

ovirtual const char* className() const

otypedef std::vector<Node*> ParentList
A vector of osg::Node pointers which is used to store the parent(s) of drawable

oinline const ParentList& getParents() const
Get the parent list of drawable.

oinline ParentList getParents()
Get the a copy of parent list of node. A copy is returned to prevent modification of the parent list.

oinline Node* getParent(const unsigned int i)
Get a single parent of Drawable.
Parameters:
i - index of the parent to get.
Returns:
the parent i.

oinline const Node* getParent(const unsigned int i) const
Get a single const parent of Drawable.
Parameters:
i - index of the parent to get.
Returns:
the parent i.

oinline const unsigned int getNumParents() const
Get the number of parents of node.
Returns:
the number of parents of this node.

oinline void setStateSet(StateSet* state)
Set the StateSet attached to the Drawable. Previously attached StateSet are automatically unreferenced on assignment of a new drawstate.

oinline StateSet* getStateSet()
Get the attached StateSet

oinline const StateSet* getStateSet() const
Get the attached const StateSet

ovoid setSupportsDisplayList(const bool flag)
Set the drawable to it can or cannot be used in conjunction with OpenGL display lists. With set to true, calls to Drawable::setUseDisplayList, whereas when set to false, no display lists can be created and calls to setUseDisplayList are ignored, and a warning is produced. The later is typically used to guard against the switching on of display lists on objects with dynamic internal data such as continuous Level of Detail algorithms.

oinline const bool getSupportsDisplayList() const
Get whether display lists are supported for this drawable instance

ovoid setUseDisplayList(const bool flag)
When set to true, force the draw method to use OpenGL Display List for rendering. If false rendering directly. If the display list has not been already compile the next call to draw will automatically create the display list.

oinline const bool getUseDisplayList() const
Return whether OpenGL display lists are being used for rendering

ovoid dirtyDisplayList()
Force a recompile on next draw() of any OpenGL display list associated with this geoset

ovoid dirtyBound()
Dirty the bounding box, forcing a computeBound() on the next call to getBound(). Should be called in the internal geometry of the Drawable is modified.

oinline const BoundingBox& getBound() const
get bounding box of geoset. Note, now made virtual to make it possible to implement user-drawn objects albeit so what crudely, to be improved later.

ovoid compile(State& state)
Immediately compile this drawable into an OpenGL Display List. Note I, operation is ignored if _useDisplayList to false. Note II, compile is not intended to be overridden in subclasses.

ostruct AppCallback: public osg::Referenced

ovirtual void app(osg::NodeVisitor* visitor, osg::Drawable* drawable) = 0
do customized app code

ovoid setAppCallback(AppCallback* ac)
Set the AppCallback which allows users to attach customize the undating of an object during the app traversal

oAppCallback* getAppCallback()
Get the non const AppCallback

oconst AppCallback* getAppCallback() const
Get the const AppCallback

ostruct CullCallback: public osg::Referenced

ovirtual bool cull(osg::NodeVisitor* visitor, osg::Drawable* drawable, osg::State* state=NULL) const = 0
do customized cull code

ovoid setCullCallback(CullCallback* cc)
Set the CullCallback which allows users to attach customize the culling of Drawable during the cull traversal

oCullCallback* getCullCallback()
Get the non const CullCallback

oconst CullCallback* getCullCallback() const
Get the const CullCallback

ostruct DrawCallback: public osg::Referenced
Callback attached to an Drawable which allows the users to customize the drawing of an exist Drawable object. The draw callback is implement as a replacement to the Drawable's own drawImmediateMode() method, if the the user intends to decorate the exist draw code then simple call the drawable->drawImmediateMode() from with the callbacks drawImmediateMode() method. This allows the users to do both pre and post callbacks without fuss and can even diable the inner draw in required.

ovirtual void drawImmediateMode(State& state, osg::Drawable* drawable) const = 0
do customized draw code

ovoid setDrawCallback(DrawCallback* dc)
Set the DrawCallback which allows users to attach customize the drawing of existing Drawable object

oDrawCallback* getDrawCallback()
Get the non const DrawCallback

oconst DrawCallback* getDrawCallback() const
Get the const DrawCallback

ovirtual void drawImmediateMode(State& state) = 0
draw directly ignoring an OpenGL display list which could be attached. This is the internal draw method which does the drawing itself, and is the method to override when deriving from Drawable.

ostatic void deleteDisplayList(uint contextID, uint globj)
use deleteDisplayList instead of glDeleteList to allow OpenGL display list to cached until they can be deleted by the OpenGL context in which they were created, specified by contextID

ostatic void flushDeletedDisplayLists(uint contextID)
flush all the cached display list which need to be deleted in the OpenGL context related to contextID

ovirtual bool getStats(Statistics&)
Collect Stistics count from Drawable

otypedef uint AttributeBitMaskenum AttributeBitMaskValues

o COORDS

o NORMALS

o COLORS

o TEXTURE_COORDS

o TEXTURE_COORDS_0

o TEXTURE_COORDS_1

o TEXTURE_COORDS_2

o TEXTURE_COORDS_3

ovirtual AttributeBitMask suppportsAttributeOperation() const
return the attributes supported by applyAttrbuteOperation() as an AttributeBitMask

ovirtual AttributeBitMask applyAttributeOperation(AttributeFunctor&)
return the attributes successully applied in applyAttributeUpdate

ovirtual void applyPrimitiveOperation(PrimitiveFunctor&)
apply the internal geometry as basic primitives to a PrimitiveFunctor

oDrawable& operator = (const Drawable&)

ovirtual ~Drawable()

ovirtual const bool computeBound() const = 0
compute the bounding box of the drawable. Method must be implemented by subclasses.

ovoid addParent(osg::Node* node)

ovoid removeParent(osg::Node* node)

oParentList _parents

oref_ptr<StateSet> _dstate

obool _supportsDisplayList

obool _useDisplayList

otypedef std::vector<uint> GLObjectList mutable GLObjectList _globjList

omutable BoundingBox _bbox

omutable bool _bbox_computed

oref_ptr<AppCallback> _appCallback

oref_ptr<DrawCallback> _drawCallback

oref_ptr<CullCallback> _cullCallback

otypedef std::map<uint,std::set<uint> >static DeletedDisplayListCache DeletedDisplayListCache s_deletedDisplayListCache

oinline void draw(State& state)
draw OpenGL primitives. If the drawable has _useDisplayList set to true then use an OpenGL display list, automatically compiling one if required. Otherwise call drawImmediateMode(). Note, draw method should *not* be overridden in subclasses as it manages the optional display list.


Direct child classes:
ImpostorSprite
Geometry
GeoSet
DrawPixels
Friends:
class Node
class Geode

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.