void StereoManager::updateAllDependentRenderTargets(bool isLeftEye) { Ogre::uint32 mask; if(isLeftEye) { mask = left_mask_; } else { mask = right_mask_; } RenderTargetList::iterator itarg, itargend; itargend = rendertarget_list_.end(); for( itarg = rendertarget_list_.begin(); itarg != itargend; ++itarg ) { Ogre::RenderTarget *rt = itarg->first; int n = rt->getNumViewports(); std::vector<int> maskVector(n); // VS2005 gives a warning if I declare the vector as uint32 but not with int for(int i = 0; i<n ; ++i) { maskVector[i] = rt->getViewport(i)->getVisibilityMask(); rt->getViewport(i)->setVisibilityMask(maskVector[i] & mask); } rt->update(); for(int i = 0; i<n ; ++i) { rt->getViewport(i)->setVisibilityMask(maskVector[i]); } } }
void Screen::toggleRenderMode() { if (mPolygonMode == Ogre::PM_SOLID) { mPolygonMode = Ogre::PM_WIREFRAME; } else { mPolygonMode = Ogre::PM_SOLID; } Ogre::RenderSystem::RenderTargetIterator renderTargetI = Ogre::Root::getSingleton().getRenderSystem()->getRenderTargetIterator(); for (Ogre::RenderSystem::RenderTargetIterator::iterator I = renderTargetI.begin(); I != renderTargetI.end(); ++I) { Ogre::RenderTarget* renderTarget = I->second; for (unsigned short i = 0; i < renderTarget->getNumViewports(); ++i) { Ogre::Camera* camera = renderTarget->getViewport(i)->getCamera(); if (camera) { camera->setPolygonMode(mPolygonMode); } } } }
bool CGUIDriverOgre::Init( GUI::TWindowContextPtr windowContext ) { if ( !m_ceGuiInitialized ) { try { Ogre::RenderTarget* renderTarget = nullptr; CORE::CString renderTargetPtrStr = windowContext->GetProperty( "Ogre::RenderTarget" ); if ( !renderTargetPtrStr.IsNULLOrEmpty() ) { renderTarget = static_cast< Ogre::RenderTarget* >( CORE::StringToPointer( renderTargetPtrStr ) ); if ( NULL == renderTarget ) return false; } Ogre::SceneManager* sceneManager = nullptr; CORE::CString sceneManagerPtrStr = windowContext->GetProperty( "Ogre::SceneManager" ); if ( !sceneManagerPtrStr.IsNULLOrEmpty() ) { sceneManager = static_cast< Ogre::SceneManager* >( CORE::StringToPointer( sceneManagerPtrStr ) ); if ( NULL == sceneManager ) return false; } // Auto-create a viewport here if none exists yet unsigned short viewportCount = renderTarget->getNumViewports(); if ( 0 == viewportCount ) { Ogre::Camera* camera = sceneManager->createCamera( "CEGUI" ); camera->setPosition( Ogre::Vector3( 0, 0, 500 ) ); camera->lookAt( Ogre::Vector3( 0, 0, -300 ) ); camera->setNearClipDistance( 5 ); // Create a viewport covering whole window Ogre::Viewport* viewport = renderTarget->addViewport( camera ); viewport->setBackgroundColour( Ogre::ColourValue( 0.0f, 0.0f, 0.0f, 0.0f ) ); viewport->setOverlaysEnabled( true ); // Update the camera aspect ratio to that of the viewport camera->setAspectRatio( Ogre::Real( viewport->getActualWidth() ) / Ogre::Real( viewport->getActualHeight() ) ); } CEGUI::Sizef displaySize( (float) windowContext->GetWidth(), (float) windowContext->GetHeight() ); m_guiRenderer = &CEGUI::OgreRenderer::create( *renderTarget );// displaySize );//, CEGUI::OpenGLRenderer::TTT_AUTO ); m_guiRenderer->setDefaultRootRenderTarget( *renderTarget ); m_guiSystem = &CEGUI::System::create( *m_guiRenderer, &m_vfsResourceProvider, &m_xmlParserAdapter, m_imageCodecAdapter ); // setup default group for validation schemas CEGUI::XMLParser* parser = m_guiSystem->getXMLParser(); if ( nullptr != parser && parser->isPropertyPresent( "SchemaDefaultResourceGroup" ) ) parser->setProperty( "SchemaDefaultResourceGroup", m_schemasResourceGroup ); // Load the fonts CEGUI::FontManager::getSingleton().createAll( m_defaultFont, CEGUI::Font::getDefaultResourceGroup() ); // Load the scheme try { CEGUI::SchemeManager::getSingleton().createFromFile( "Generic.scheme" ); } catch ( CEGUI::Exception& e ) { CORE::CString info = e.getMessage() + " - at - " + e.getFileName() + ":" + e.getFunctionName() + ":" + CORE::UInt32ToString( e.getLine() ).STL_String(); GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_IMPORTANT, "Unhandled exception during CEGUI initialization: " + info ); } CEGUI::SchemeManager::getSingleton().createFromFile( m_schemeToUse ); // Set the defaults CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont( m_defaultFont ); CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage( m_defaultCursorImage ); CEGUI::Window* rootWindow = CEGUI::WindowManager::getSingleton().createWindow( "DefaultWindow", "root" ); CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow( rootWindow ); // clearing this queue actually makes sure it's created(!) CEGUI::System::getSingleton().getDefaultGUIContext().clearGeometry( CEGUI::RQ_OVERLAY ); m_ceGuiInitialized = true; } catch ( CEGUI::Exception& e ) { CORE::CString info = e.getMessage() + " - at - " + e.getFileName() + ":" + e.getFunctionName() + ":" + CORE::UInt32ToString( e.getLine() ).STL_String(); GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_IMPORTANT, "Unhandled exception during CEGUI initialization: " + info ); m_ceGuiInitialized = false; } } return m_ceGuiInitialized; }