Hi there,

i find that there is a setPostDrawCallback function, However, how could i 
remove that PostDrawCallback after it was used.

currently, i use a composite factory to resolve this problem that i write a 
class CameraPostDrawCallback which is derived from Camera::DrawCallback and in 
fact is a composite DrawCallback which keep a list of real DrawCallback 
pointers. I setup this CameraPostDrawCallback to the Camera when program 
starting up, and leave it there forever. when ever i want to use a 
DrawCallback, a object is defined and is  appended  to CameraPostDrawCallback, 
so that it has chance to be executed, after it was used, it will be removed.
key code snippet:

void operator()(const Camera& camera){        
        while(mCallbackList.size()>0){
            Camera::DrawCallback* callback=mCallbackList.takeFirst();
            mCallbackList.pop_front();
            try{
              (*callback)(camera);
            }catch(...){}
            mBackupList.push_back(callback);            
        }
        mCallbackList.append(mBackupList);
        mBackupList.clear();
    }

It works well now. However I doubt it is erroneous way to use DrawCallback that 
those nested DrawCallback do not have chance to be touched by Osg Core sot that 
can't be initialized correctly.

So, am i working in a correct way? if no ,then how do i remove a 
PostDrawCallback?
I do have tried to set a NULL to the camera, it is breaked after leaving my 
function.

Regards,
Abe. Zhu
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to