Name change and const change of Drawable::drawImmediateMode(State&) to
Drawable::drawImplementation(State&) const. Various updates to the rest of the OSG to accomodate this.
This commit is contained in:
@@ -51,7 +51,7 @@ class SG_EXPORT DrawPixels : public Drawable
|
||||
bool getUseSubImage() const { return _useSubImage; }
|
||||
|
||||
|
||||
virtual void drawImmediateMode(State& state);
|
||||
virtual void drawImplementation(State& state) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -163,7 +163,7 @@ class SG_EXPORT Drawable : public Object
|
||||
/** 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().
|
||||
* Otherwise call drawImplementation().
|
||||
* Note, draw method should *not* be overridden in subclasses as it
|
||||
* manages the optional display list.
|
||||
*/
|
||||
@@ -208,14 +208,22 @@ class SG_EXPORT Drawable : public Object
|
||||
|
||||
|
||||
/** 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
|
||||
* The draw callback is implement as a replacement to the Drawable's own drawImplementation() method, if the
|
||||
* the user intends to decorate the exist draw code then simple call the drawable->drawImplementation() from
|
||||
* with the callbacks drawImplementation() method. This allows the users to do both pre and post callbacks
|
||||
* without fuss and can even diable the inner draw in required.*/
|
||||
struct DrawCallback : public osg::Referenced
|
||||
{
|
||||
/** do customized draw code.*/
|
||||
virtual void drawImmediateMode(State& state,osg::Drawable* drawable) const = 0;
|
||||
#ifdef USE_DEPRECATED_API
|
||||
// adapt old drawImmediateMode API into new API to keep things compiling on old code.
|
||||
virtual void drawImplementation(State& state,const osg::Drawable* drawable) const { drawImmediateMode(state,const_cast<Drawable*>(drawable)); }
|
||||
|
||||
/** do customized draw code.*/
|
||||
virtual void drawImmediateMode(State& state,osg::Drawable* drawable) const = 0;
|
||||
#else
|
||||
/** do customized draw code.*/
|
||||
virtual void drawImplementation(State& state,const osg::Drawable* drawable) const = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Set the DrawCallback which allows users to attach customize the drawing of existing Drawable object.*/
|
||||
@@ -228,13 +236,27 @@ class SG_EXPORT Drawable : public Object
|
||||
const DrawCallback* getDrawCallback() const { return _drawCallback.get(); }
|
||||
|
||||
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
|
||||
// adapt old drawImmediateMode API into new API to keep things compiling on old code.
|
||||
virtual void drawImplementation(State& state) const { (const_cast<Drawable*>(this))->drawImmediateMode(state); }
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
virtual void drawImmediateMode(State& state) = 0;
|
||||
virtual void drawImmediateMode(State&) {}
|
||||
|
||||
#else
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
virtual void drawImplementation(State& state) const = 0;
|
||||
|
||||
#endif
|
||||
|
||||
/** use deleteDisplayList instead of glDeleteList to allow
|
||||
* OpenGL display list to cached until they can be deleted
|
||||
@@ -420,9 +442,9 @@ inline void Drawable::draw(State& state)
|
||||
globj = glGenLists( 1 );
|
||||
glNewList( globj, GL_COMPILE );
|
||||
if (_drawCallback.valid())
|
||||
_drawCallback->drawImmediateMode(state,this);
|
||||
_drawCallback->drawImplementation(state,this);
|
||||
else
|
||||
drawImmediateMode(state);
|
||||
drawImplementation(state);
|
||||
glEndList();
|
||||
|
||||
glCallList( globj);
|
||||
@@ -430,9 +452,9 @@ inline void Drawable::draw(State& state)
|
||||
globj = glGenLists( 1 );
|
||||
glNewList( globj, GL_COMPILE_AND_EXECUTE );
|
||||
if (_drawCallback.valid())
|
||||
_drawCallback->drawImmediateMode(state,this);
|
||||
_drawCallback->drawImplementation(state,this);
|
||||
else
|
||||
drawImmediateMode(state);
|
||||
drawImplementation(state);
|
||||
glEndList();
|
||||
#endif
|
||||
}
|
||||
@@ -442,9 +464,9 @@ inline void Drawable::draw(State& state)
|
||||
{
|
||||
// draw object as nature intended..
|
||||
if (_drawCallback.valid())
|
||||
_drawCallback->drawImmediateMode(state,this);
|
||||
_drawCallback->drawImplementation(state,this);
|
||||
else
|
||||
drawImmediateMode(state);
|
||||
drawImplementation(state);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ class SG_EXPORT GeoSet : public Drawable
|
||||
* This is the internal draw method which does the drawing itself,
|
||||
* and is the method to override when deriving from GeoSet for user-drawn objects.
|
||||
*/
|
||||
virtual void drawImmediateMode(State& state);
|
||||
virtual void drawImplementation(State& state) const;
|
||||
|
||||
bool check() const;
|
||||
|
||||
@@ -330,12 +330,21 @@ class SG_EXPORT GeoSet : public Drawable
|
||||
/** get the current AttributeDeleteFunction to handle attribute arrays attached to this Geoset.*/
|
||||
const AttributeDeleteFunctor* getAttributeDeleteFunctor() const { return _adf.get(); }
|
||||
|
||||
/** return true, osg::GeoSet does support accept(AttributeFunctor&).*/
|
||||
virtual bool supports(AttributeFunctor&) const { return true; }
|
||||
|
||||
/** accept an AttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
|
||||
virtual void accept(AttributeFunctor& af);
|
||||
|
||||
/** return true, osg::GeoSet does support accept(ConstAttributeFunctor&).*/
|
||||
virtual bool supports(ConstAttributeFunctor&) const { return true; }
|
||||
|
||||
/** accept an ConstAttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
|
||||
virtual void accept(ConstAttributeFunctor& af) const;
|
||||
|
||||
/** return true, osg::GeoSet does support accept(PrimitiveFunctor&) .*/
|
||||
virtual bool supports(PrimitiveFunctor&) const { return true; }
|
||||
|
||||
/** accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has.*/
|
||||
virtual void accept(PrimitiveFunctor& pf) const;
|
||||
|
||||
@@ -362,7 +371,7 @@ class SG_EXPORT GeoSet : public Drawable
|
||||
|
||||
mutable int _numcoords;
|
||||
Vec3 *_coords;
|
||||
IndexPointer _cindex;
|
||||
mutable IndexPointer _cindex;
|
||||
|
||||
BindingType _normal_binding;
|
||||
mutable int _numnormals;
|
||||
@@ -388,8 +397,8 @@ class SG_EXPORT GeoSet : public Drawable
|
||||
int _fast_path;
|
||||
|
||||
void set_fast_path( void );
|
||||
void draw_fast_path( State& state );
|
||||
void draw_alternate_path( State& state );
|
||||
void draw_fast_path( State& state ) const;
|
||||
void draw_alternate_path( State& state ) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ class SG_EXPORT Geometry : public Drawable
|
||||
* This is the internal draw method which does the drawing itself,
|
||||
* and is the method to override when deriving from Geometry for user-drawn objects.
|
||||
*/
|
||||
virtual void drawImmediateMode(State& state);
|
||||
virtual void drawImplementation(State& state) const;
|
||||
|
||||
/** return true, osg::Geometry does support accept(AttributeFunctor&).*/
|
||||
virtual bool supports(AttributeFunctor&) const { return true; }
|
||||
|
||||
@@ -114,7 +114,7 @@ class SG_EXPORT ImpostorSprite : public Drawable
|
||||
int t() const { return _t; }
|
||||
|
||||
/** draw ImpostorSprite directly. */
|
||||
virtual void drawImmediateMode(State& state);
|
||||
virtual void drawImplementation(State& state) const;
|
||||
|
||||
/** return true, osg::ImpostorSprite does support accept(AttributeFunctor&).*/
|
||||
virtual bool supports(AttributeFunctor&) const { return true; }
|
||||
|
||||
@@ -124,7 +124,7 @@ class SG_EXPORT ShapeDrawable : public Drawable
|
||||
* This is the internal draw method which does the drawing itself,
|
||||
* and is the method to override when deriving from ShapeDrawable for user-drawn objects.
|
||||
*/
|
||||
virtual void drawImmediateMode(State& state);
|
||||
virtual void drawImplementation(State& state) const;
|
||||
|
||||
/** return false, osg::ProceduralGeoemtry does not support accept(AttributeFunctor&).*/
|
||||
virtual bool supports(AttributeFunctor&) const { return false; }
|
||||
|
||||
@@ -164,13 +164,13 @@ namespace osgParticle
|
||||
bool update(double dt);
|
||||
|
||||
/// Perform some pre-rendering tasks. Called automatically by particle systems.
|
||||
inline void beginRender();
|
||||
inline void beginRender() const;
|
||||
|
||||
/// Render the particle. Called automatically by particle systems.
|
||||
void render(const osg::Vec3 &xpos, const osg::Vec3 &px, const osg::Vec3 &py, float scale = 1.0f) const;
|
||||
|
||||
/// Perform some post-rendering tasks. Called automatically by particle systems.
|
||||
inline void endRender();
|
||||
inline void endRender() const;
|
||||
|
||||
/// Get the current (interpolated) polygon size. Valid only after the first call to update().
|
||||
inline float getCurrentSize() const;
|
||||
@@ -369,7 +369,7 @@ namespace osgParticle
|
||||
massinv_ = 1 / m;
|
||||
}
|
||||
|
||||
inline void Particle::beginRender()
|
||||
inline void Particle::beginRender() const
|
||||
{
|
||||
switch (shape_)
|
||||
{
|
||||
@@ -383,7 +383,7 @@ namespace osgParticle
|
||||
}
|
||||
}
|
||||
|
||||
inline void Particle::endRender()
|
||||
inline void Particle::endRender() const
|
||||
{
|
||||
switch (shape_)
|
||||
{
|
||||
|
||||
@@ -149,9 +149,9 @@ namespace osgParticle
|
||||
ParticleSystem &operator=(const ParticleSystem &) { return *this; }
|
||||
|
||||
inline virtual bool computeBound() const;
|
||||
virtual void drawImmediateMode(osg::State &state);
|
||||
virtual void drawImplementation(osg::State &state) const;
|
||||
inline void update_bounds(const osg::Vec3 &p, float r);
|
||||
void single_pass_render(osg::State &state, const osg::Matrix &modelview);
|
||||
void single_pass_render(osg::State &state, const osg::Matrix &modelview) const;
|
||||
|
||||
private:
|
||||
typedef std::vector<Particle> Particle_vector;
|
||||
@@ -176,11 +176,11 @@ namespace osgParticle
|
||||
bool bounds_computed_;
|
||||
|
||||
Particle def_ptemp_;
|
||||
int last_frame_;
|
||||
mutable int last_frame_;
|
||||
bool freeze_on_cull_;
|
||||
|
||||
int detail_;
|
||||
int draw_count_;
|
||||
mutable int draw_count_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class OSGTEXT_EXPORT Font : public osg::Object
|
||||
|
||||
virtual bool create(osg::State& state,int pointSize, unsigned int res = 72 );
|
||||
virtual bool create(osg::State& state);
|
||||
virtual void output(osg::State& state,const char* text);
|
||||
virtual void output(osg::State& state,const char* text) const;
|
||||
|
||||
virtual bool isOk(void) const { return _init; }
|
||||
virtual bool isCreated(void) const { return isOk() && _created; }
|
||||
|
||||
@@ -101,9 +101,9 @@ class OSGTEXT_EXPORT Text : public osg::Drawable
|
||||
void setText(const std::string& text) { _text=text; _initAlignment=false; }
|
||||
const std::string& getText() const { return _text; }
|
||||
|
||||
virtual void drawImmediateMode(osg::State& state);
|
||||
virtual void drawBoundingBox(void);
|
||||
virtual void drawAlignment(void);
|
||||
virtual void drawImplementation(osg::State& state) const;
|
||||
virtual void drawBoundingBox(void) const;
|
||||
virtual void drawAlignment(void) const;
|
||||
|
||||
const osg::Vec3& getAlignmentPos() const { return _alignmentPos; };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user