本文整理汇总了C++中Contexts类的典型用法代码示例。如果您正苦于以下问题:C++ Contexts类的具体用法?C++ Contexts怎么用?C++ Contexts使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Contexts类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stopThreading
CompositeViewer::~CompositeViewer()
{
OSG_INFO<<"CompositeViewer::~CompositeViewer()"<<std::endl;
stopThreading();
Scenes scenes;
getScenes(scenes);
for(Scenes::iterator sitr = scenes.begin();
sitr != scenes.end();
++sitr)
{
Scene* scene = *sitr;
if (scene->getDatabasePager())
{
scene->getDatabasePager()->cancel();
scene->setDatabasePager(0);
}
}
Contexts contexts;
getContexts(contexts);
// clear out all the previously assigned operations
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
(*citr)->close();
}
OSG_INFO<<"finished CompositeViewer::~CompositeViewer()"<<std::endl;
}
示例2: getAllThreads
Viewer::~Viewer()
{
//OSG_NOTICE<<"Viewer::~Viewer()"<<std::endl;
Threads threads;
getAllThreads(threads);
OSG_INFO<<"Viewer::~Viewer():: start destructor getThreads = "<<threads.size()<<std::endl;
stopThreading();
if (_scene.valid() && _scene->getDatabasePager())
{
_scene->getDatabasePager()->cancel();
_scene->setDatabasePager(0);
}
Contexts contexts;
getContexts(contexts);
// clear out all the previously assigned operations
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
(*citr)->close();
}
//OSG_NOTICE<<"finish Viewer::~Viewer()"<<std::endl;
getAllThreads(threads);
OSG_INFO<<"Viewer::~Viewer() end destructor getThreads = "<<threads.size()<<std::endl;
}
示例3: getContexts
void CompositeViewer::setStartTick(osg::Timer_t tick)
{
_startTick = tick;
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
(*vitr)->setStartTick(tick);
}
Contexts contexts;
getContexts(contexts,false);
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*citr);
if (gw)
{
gw->getEventQueue()->setStartTick(_startTick);
}
}
}
示例4: DummyContexts
Contexts DummyContexts()
{
Contexts ctxts;
SWRContext c = { 0 };
ctxts.insert(std::make_pair(0, (SWRContext)c));
return ctxts;
}
示例5: isRealized
void CompositeViewer::addView(osgViewer::View* view)
{
if (!view) return;
bool alreadyRealized = isRealized();
bool threadsWereRunning = _threadsRunning;
if (threadsWereRunning) stopThreading();
_views.push_back(view);
view->_viewerBase = this;
if (view->getSceneData())
{
// make sure that existing scene graph objects are allocated with thread safe ref/unref
if (getThreadingModel()!=ViewerBase::SingleThreaded)
{
view->getSceneData()->setThreadSafeRefUnref(true);
}
// update the scene graph so that it has enough GL object buffer memory for the graphics contexts that will be using it.
view->getSceneData()->resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts());
}
view->setFrameStamp(_frameStamp.get());
if (alreadyRealized)
{
Contexts contexts;
if (view->getCamera()->getGraphicsContext())
{
contexts.push_back(view->getCamera()->getGraphicsContext());
}
for(unsigned int i=0; i<view->getNumSlaves(); ++i)
{
if (view->getSlave(i)._camera->getGraphicsContext())
{
contexts.push_back(view->getSlave(i)._camera->getGraphicsContext());
}
}
for(Contexts::iterator itr = contexts.begin();
itr != contexts.end();
++itr)
{
if (!((*itr)->isRealized()))
{
(*itr)->realize();
}
}
}
if (threadsWereRunning) startThreading();
}
示例6: execute
void ExecutableOpHolder::execute( const Contexts &contexts ) const
{
for ( Contexts::const_iterator cit = contexts.begin(); cit != contexts.end(); cit++ )
{
// \todo Implement a way to get the CompoundObject for a given context without modifying the Op's parameter
// and passing it explicitly in the operate call. Than multi-thread this loop.
Context::Scope scope( *cit );
constPointerCast<CompoundParameterHandler>( parameterHandler() )->setParameterValue();
constPointerCast<Op>( getOp() )->operate();
}
}
示例7: getContexts
void Viewer::realize()
{
//OSG_INFO<<"Viewer::realize()"<<std::endl;
// 保存了osg::GraphicsContext指针的向量组
Contexts contexts;
// 获取所有的图形上下文,并保存到这个向量组中来
getContexts(contexts);
// 如果没有得到任何图形上下文的话,就说明仿真系统还没有合适的显示平台
// 这个时候就需要创建一个缺省的GraphicsContext设备,并再次执行getContexts
if (contexts.empty())
{
OSG_INFO<<"Viewer::realize() - No valid contexts found, setting up view across all screens."<<std::endl;
// no windows are already set up so set up a default view
// 创建缺省GraphicsContext设备的方法有以下几种:
// 读取OSG_CONFIG_FILE环境变量的内容,如果用户在这个环境变量中定义了一个文件路径的话
// 使用配置文件设置当前视景器
const char* ptr = 0;
if ((ptr = getenv("OSG_CONFIG_FILE")) != 0)
{
readConfiguration(ptr);
}
else
{
int screenNum = -1;
if ((ptr = getenv("OSG_SCREEN")) != 0)
{
if (strlen(ptr)!=0) screenNum = atoi(ptr);
else screenNum = -1;
}
int x = -1, y = -1, width = -1, height = -1;
if ((ptr = getenv("OSG_WINDOW")) != 0)
{
std::istringstream iss(ptr);
iss >> x >> y >> width >> height;
}
if (width>0 && height>0)
{
if (screenNum>=0) setUpViewInWindow(x, y, width, height, screenNum);
else setUpViewInWindow(x,y,width,height);
}
else if (screenNum>=0)
{
setUpViewOnSingleScreen(screenNum);
}
else
{
setUpViewAcrossAllScreens();
}
}
示例8: wglMakeCurrent
WINGDIAPI BOOL WINAPI wglMakeCurrent(HDC hdc, DHGLRC hglrc)
{
if (!gCurrentContextSet)
{
gCurrentContext = gContexts.end();
gCurrentContextSet = true;
}
if (!hdc || !hglrc)
{
gCurrentContext = gContexts.end();
return 1;
}
int rc = (int)hglrc;
if (gContexts.find(rc) == gCurrentContext)
{
return 1;
}
gCurrentContext = gContexts.find(rc);
auto &xCtxt = gContexts[rc];
OGL::State *pState = xCtxt.pState;
HWND hWnd = WindowFromDC(hdc);
RECT rect;
GetClientRect(hWnd, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
SetOGL(pState);
OGL::GetDDProcTable().pfnBindContext(OGL::GetDDHandle(), NULL, hWnd, NULL, width, height);
// according to spec, only set current viewport to draw buffer dimensions if the context hasn't
// been initialized
if (!xCtxt.initialized)
{
pState->mViewport.x = 0;
pState->mViewport.y = 0;
pState->mViewport.width = width;
pState->mViewport.height = height;
pState->mScissor.x = 0;
pState->mScissor.y = 0;
pState->mScissor.width = width;
pState->mScissor.height = height;
xCtxt.initialized = true;
}
return 1;
}
示例9: setCameraWithFocus
void Viewer::realize()
{
//OSG_INFO<<"Viewer::realize()"<<std::endl;
setCameraWithFocus(0);
Contexts contexts;
getContexts(contexts);
if (contexts.empty())
{
OSG_INFO<<"Viewer::realize() - No valid contexts found, setting up view across all screens."<<std::endl;
// no windows are already set up so set up a default view
const char* ptr = 0;
if ((ptr = getenv("OSG_CONFIG_FILE")) != 0)
{
readConfiguration(ptr);
}
else
{
int screenNum = -1;
if ((ptr = getenv("OSG_SCREEN")) != 0)
{
if (strlen(ptr)!=0) screenNum = atoi(ptr);
else screenNum = -1;
}
int x = -1, y = -1, width = -1, height = -1;
if ((ptr = getenv("OSG_WINDOW")) != 0)
{
std::istringstream iss(ptr);
iss >> x >> y >> width >> height;
}
if (width>0 && height>0)
{
if (screenNum>=0) setUpViewInWindow(x, y, width, height, screenNum);
else setUpViewInWindow(x,y,width,height);
}
else if (screenNum>=0)
{
setUpViewOnSingleScreen(screenNum);
}
else
{
setUpViewAcrossAllScreens();
}
}
示例10: getContexts
void ViewerBase::getWindows(Windows& windows, bool onlyValid)
{
windows.clear();
Contexts contexts;
getContexts(contexts, onlyValid);
for(Contexts::iterator itr = contexts.begin();
itr != contexts.end();
++itr)
{
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*itr);
if (gw) windows.push_back(gw);
}
}
示例11: inPlug
void ExecutableRender::execute( const Contexts &contexts ) const
{
const ScenePlug *scene = inPlug()->getInput<ScenePlug>();
if( !scene )
{
throw IECore::Exception( "No input scene" );
}
/// \todo This doesn't belong here. It'll be the responsibility of the Despatchers
/// to save the script if necessary, and to save it to an alternate location than
/// the current one.
scriptNode()->save();
for( Contexts::const_iterator it = contexts.begin(), eIt = contexts.end(); it != eIt; it++ )
{
Context::Scope scopedContext( it->get() );
ConstCompoundObjectPtr globals = scene->globalsPlug()->getValue();
createDisplayDirectories( globals );
IECore::RendererPtr renderer = createRenderer();
outputOptions( globals, renderer );
outputCamera( scene, globals, renderer );
{
WorldBlock world( renderer );
outputLights( scene, globals, renderer );
outputWorldProcedural( scene, renderer );
}
std::string systemCommand = command();
if( systemCommand.size() )
{
const ApplicationRoot *applicationRoot = scene->ancestor<ApplicationRoot>();
if( applicationRoot && applicationRoot->getName() == "gui" )
{
/// \todo We need this weird background execution behaviour because we
/// don't want to block the ui while rendering, but really the LocalDespatcher
/// should be responsible for launching a separate process to do the execution
/// from anyway.
systemCommand += "&";
}
system( systemCommand.c_str() );
}
}
}
示例12: wglGetCurrentDC
WINGDIAPI HDC WINAPI wglGetCurrentDC(VOID)
{
if (!gCurrentContextSet)
{
gCurrentContext = gContexts.end();
gCurrentContextSet = true;
}
if (gCurrentContext == gContexts.end())
{
return NULL;
}
else
{
return gCurrentContext->second.hdc;
}
}
示例13: getAllThreads
Viewer::~Viewer()
{
//OSG_NOTICE<<"Viewer::~Viewer()"<<std::endl;
Threads threads;
getAllThreads(threads);
OSG_INFO<<"Viewer::~Viewer():: start destructor getThreads = "<<threads.size()<<std::endl;
stopThreading();
if (_scene.valid() && _scene->getDatabasePager())
{
_scene->getDatabasePager()->cancel();
_scene->setDatabasePager(0);
}
Contexts contexts;
getContexts(contexts);
// clear out all the previously assigned operations
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
osg::GraphicsContext* gc = *citr;
// Run destroy operation on each context before closing it
if (_cleanUpOperation.valid() && gc->valid())
{
gc->makeCurrent();
(*_cleanUpOperation)(gc);
gc->releaseContext();
}
gc->close();
}
//OSG_NOTICE<<"finish Viewer::~Viewer()"<<std::endl;
getAllThreads(threads);
OSG_INFO<<"Viewer::~Viewer() end destructor getThreads = "<<threads.size()<<std::endl;
}
示例14: checkWindowStatus
void ViewerBase::checkWindowStatus(const Contexts& contexts)
{
if (contexts.size()==0)
{
_done = true;
if (areThreadsRunning()) stopThreading();
}
}
示例15: wglGetCurrentContext
WINGDIAPI HGLRC WINAPI wglGetCurrentContext(VOID)
{
if (!gCurrentContextSet)
{
gCurrentContext = gContexts.end();
gCurrentContextSet = true;
}
if (gCurrentContext == gContexts.end())
{
return NULL;
}
else
{
return reinterpret_cast<HGLRC>(gCurrentContext->first);
}
}