|
楼主 |
发表于 2010-10-22 14:43:52
|
显示全部楼层
比如这两个函数的使用
void GraphicsContext::setCompileContext(unsigned int contextID, GraphicsContext* gc)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_contextIDMapMutex);
s_contextIDMap[contextID]._compileContext = gc;
}
GraphicsContext* GraphicsContext::getCompileContext(unsigned int contextID)
{
// OSG_NOTICE<<"GraphicsContext::getCompileContext "<<contextID<<std::endl;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_contextIDMapMutex);
ContextIDMap::iterator itr = s_contextIDMap.find(contextID);
if (itr != s_contextIDMap.end()) return itr->second._compileContext.get();
else return 0;
}
还有需要传入原始指针的地方
void GraphicsContext::removeCamera(osg::Camera* camera)
{
Cameras::iterator itr = std::find(_cameras.begin(), _cameras.end(), camera);
if (itr != _cameras.end())
{
// find a set of nodes attached the camera that we are removing that isn't
// shared by any other cameras on this GraphicsContext
typedef std::set<Node*> NodeSet;
NodeSet nodes;
for(unsigned int i=0; i<camera->getNumChildren(); ++i)
{
nodes.insert(camera->getChild(i));
}
for(Cameras::iterator citr = _cameras.begin();
citr != _cameras.end();
++citr)
{
if (citr != itr)
{
osg::Camera* otherCamera = *citr;
for(unsigned int i=0; i<otherCamera->getNumChildren(); ++i)
{
NodeSet::iterator nitr = nodes.find(otherCamera->getChild(i));
if (nitr != nodes.end()) nodes.erase(nitr);
}
}
}
// now release the GLobjects associated with these non shared nodes
for(NodeSet::iterator nitr = nodes.begin();
nitr != nodes.end();
++nitr)
{
const_cast<osg::Node*>(*nitr)->releaseGLObjects(_state.get());
}
// release the context of the any RenderingCache that the Camera has.
if (camera->getRenderingCache())
{
camera->getRenderingCache()->releaseGLObjects(_state.get());
}
_cameras.erase(itr);
}
}
等等吧。
没有仔细看过源码,只是觉得这样存在安全隐患 |
|