コード例 #1
0
ファイル: ogrewidget.cpp プロジェクト: sartraher/exodus
/**
 * @brief init the object
 * @author kito berg-taylor
 */
void OgreWidget::init()
{
  // create the main ogre object
  mOgreRoot = new Ogre::Root;

  mOgreRoot->loadPlugin("RenderSystem_GL");
  Ogre::String rName("OpenGL Rendering Subsystem");
  Ogre::RenderSystemList rList = mOgreRoot->getAvailableRenderers();
  Ogre::RenderSystemList::iterator it = rList.begin();
  Ogre::RenderSystem *rSys = 0;
  while(it != rList.end())
  {
    rSys = * (it++);
    Ogre::String strx=rSys->getName();
    if(strx == rName)
    {
      mOgreRoot->setRenderSystem(rSys);
      break;
    }
  }
   QString dimensions = QString( "%1x%2" )
                    .arg(this->width())
                    .arg(this->height());
 
  rSys->setConfigOption( "Video Mode", dimensions.toStdString() );
 
  // initialize without creating window
  mOgreRoot->getRenderSystem()->setConfigOption( "Full Screen", "No" );
  mOgreRoot->saveConfig();
  mOgreRoot->initialise(false); // don't create a window
}
コード例 #2
0
	OgreRTTexture::OgreRTTexture(Ogre::TexturePtr _texture) :
		mViewport(nullptr),
		mSaveViewport(nullptr),
		mTexture(_texture)
	{
		mProjectMatrix = Ogre::Matrix4::IDENTITY;
		Ogre::Root* root = Ogre::Root::getSingletonPtr();
		if (root != nullptr)
		{
			Ogre::RenderSystem* system = root->getRenderSystem();
			if (system != nullptr)
			{
				size_t width = mTexture->getWidth();
				size_t height = mTexture->getHeight();

				mRenderTargetInfo.maximumDepth = system->getMaximumDepthInputValue();
				mRenderTargetInfo.hOffset = system->getHorizontalTexelOffset() / float(width);
				mRenderTargetInfo.vOffset = system->getVerticalTexelOffset() / float(height);
				mRenderTargetInfo.aspectCoef = float(height) / float(width);
				mRenderTargetInfo.pixScaleX = 1.0f / float(width);
				mRenderTargetInfo.pixScaleY = 1.0f / float(height);
			}

			if (mTexture->getBuffer()->getRenderTarget()->requiresTextureFlipping())
			{
				mProjectMatrix[1][0] = -mProjectMatrix[1][0];
				mProjectMatrix[1][1] = -mProjectMatrix[1][1];
				mProjectMatrix[1][2] = -mProjectMatrix[1][2];
				mProjectMatrix[1][3] = -mProjectMatrix[1][3];
			}
		}
	}
コード例 #3
0
ファイル: wxOgre.cpp プロジェクト: ChrisCarlsen/tortuga
void wxOgre::createOgreRenderWindow()
{
	// Grab the current render system from Ogre
	Ogre::RenderSystem* renderSystem =
        Ogre::Root::getSingleton().getRenderSystem();

	// Create a new parameters list according to compiled OS
	Ogre::NameValuePairList params;
    getWindowParams(&params);

	// Get wx control window size
	int width;
	int height;
	GetClientSize(&width, &height);
	std::string name(GetName().mb_str(wxConvUTF8));

	// Create the render window (give the name of wxWidget window to Ogre)
	mRenderWindow =
        renderSystem->createRenderWindow(name, width, height, false, &params);

	// Set the viewport up with camera
	// NOTE: You can only create a camera after you have made the first camera
	//       we are going to need to be passed a camera for the second one
	if (mCamera)
	{
        mViewport = mRenderWindow->addViewport(mCamera);
        mViewport->setBackgroundColour(Ogre::ColourValue(1.0f, 0.0f, 0.0f,
                                                         1.0f));
	}
}
コード例 #4
0
ファイル: qogrewidget.cpp プロジェクト: JasonForrest/Modules
	void OgreWidget::init(std::string const& plugins_file, std::string const& ogre_cfg_file, std::string const& ogre_log)
	{
		// create the main ogre object
		_mOgreRoot = new Ogre::Root(plugins_file, ogre_cfg_file, ogre_log);

		// setup a renderer
		Ogre::RenderSystemList::const_iterator renderers = _mOgreRoot->getAvailableRenderers().begin();
		while(renderers != _mOgreRoot->getAvailableRenderers().end())
		{
			Ogre::String rName = (*renderers)->getName();
			if (rName == "OpenGL Rendering Subsystem")
				break;
			renderers++;
		}

		Ogre::RenderSystem *renderSystem = *renderers;

		_mOgreRoot->setRenderSystem(renderSystem);
		QString dimensions = QString("%1x%2")
											.arg(this->width())
											.arg(this->height());

		renderSystem->setConfigOption("Video Mode", dimensions.toStdString());

		// initialize without creating window
		_mOgreRoot->getRenderSystem()->setConfigOption("Full Screen", "No");
		_mOgreRoot->saveConfig();
		_mOgreRoot->initialise(false); // don't create a window
	}
コード例 #5
0
void ApplicationContext::reconfigure(const Ogre::String &renderer, Ogre::NameValuePairList &options)
{
    mNextRenderer = renderer;
    Ogre::RenderSystem* rs = mRoot->getRenderSystemByName(renderer);

    // set all given render system options
    for (Ogre::NameValuePairList::iterator it = options.begin(); it != options.end(); it++)
    {
        rs->setConfigOption(it->first, it->second);

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
        // Change the viewport orientation on the fly if requested
        if(it->first == "Orientation")
        {
            if (it->second == "Landscape Left")
                mWindow->getViewport(0)->setOrientationMode(Ogre::OR_LANDSCAPELEFT, true);
            else if (it->second == "Landscape Right")
                mWindow->getViewport(0)->setOrientationMode(Ogre::OR_LANDSCAPERIGHT, true);
            else if (it->second == "Portrait")
                mWindow->getViewport(0)->setOrientationMode(Ogre::OR_PORTRAIT, true);
        }
#endif
    }

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
    // Need to save the config on iOS to make sure that changes are kept on disk
    mRoot->saveConfig();
#endif
    mRoot->queueEndRendering();   // break from render loop
}
コード例 #6
0
ファイル: manager.cpp プロジェクト: jhooks1/openmw
    void setRenderSystem(Ogre::RenderSystem* _render)
    {
        // отписываемся
        if (mRenderSystem != nullptr)
        {
            mRenderSystem->removeListener(this);
            mRenderSystem = nullptr;
        }

        mRenderSystem = _render;

        // подписываемся на рендер евент
        if (mRenderSystem != nullptr)
        {
            mRenderSystem->addListener(this);

            // формат цвета в вершинах
            Ogre::VertexElementType vertex_type = mRenderSystem->getColourVertexElementType();
            if (vertex_type == Ogre::VET_COLOUR_ARGB)
                mVertexFormat = VertexColourType::ColourARGB;
            else if (vertex_type == Ogre::VET_COLOUR_ABGR)
                mVertexFormat = VertexColourType::ColourABGR;

            updateRenderInfo();
        }
    }
コード例 #7
0
ファイル: DynamicLineDrawer.cpp プロジェクト: EdwardKL/Astral
void CDynamicLineDrawer::FillHardwareBuffers()
{
	int Size = int(Points.size());

	PrepareHardwareBuffers(Size);

	if (!Size) {
		mBox.setExtents( Ogre::Vector3::ZERO, Ogre::Vector3::ZERO );
		Dirty = false;
		return;
	}

	Ogre::Vector3 AABMin = Points[0];
	Ogre::Vector3 AABMax = Points[0];

	Ogre::HardwareVertexBufferSharedPtr VBuf =
		mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);

	Ogre::HardwareVertexBufferSharedPtr CBuf =
		mRenderOp.vertexData->vertexBufferBinding->getBuffer(1);

	// get rendersystem to pack colours
	Ogre::RenderSystem* RS = Ogre::Root::getSingleton().getRenderSystem();

	Ogre::Real* VPrPos = static_cast<Ogre::Real*>(VBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD));
	Ogre::RGBA* CPrPos = static_cast<Ogre::RGBA*>(CBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD));
	for(int i = 0; i < Size; i++)
	{
		*VPrPos++ = Points[i].x;
		*VPrPos++ = Points[i].y;
		*VPrPos++ = Points[i].z;

		Ogre::RGBA color;
		RS->convertColourValue(Colours[i], &color);
		*CPrPos++ = color;
		//*CPrPos++ = unsigned int(Colours[i].g);
		//*CPrPos++ = unsigned int(Colours[i].b);

		if(Points[i].x < AABMin.x)
			AABMin.x = Points[i].x;
		if(Points[i].y < AABMin.y)
			AABMin.y = Points[i].y;
		if(Points[i].z < AABMin.z)
			AABMin.z = Points[i].z;

		if(Points[i].x > AABMax.x)
			AABMax.x = Points[i].x;
		if(Points[i].y > AABMax.y)
			AABMax.y = Points[i].y;
		if(Points[i].z > AABMax.z)
			AABMax.z = Points[i].z;
	}
	VBuf->unlock();
	CBuf->unlock();

	mBox.setExtents(AABMin, AABMax);

	Dirty = false;
}
コード例 #8
0
void OgreMinimalSetup::debugRenderList(const Ogre::RenderSystemList& rsl)
{
  assert(rsl.size() && "RenderSystemList size is 0");
  cout << "RenderSystemList size is " << rsl.size() << endl;
  Ogre::RenderSystem* rs = rsl[0];
  assert(rs && "First RenderSystem is NULL");
  cout << "First RenderSystem name is '" << rs->getName() << "'" << endl;
}
コード例 #9
0
ファイル: main_OLD.cpp プロジェクト: fulletron/BlockGame
	virtual void registerHlms(void)
	{
	GraphicsSystem::registerHlms();

	Ogre::ConfigFile cf;
	cf.load(mResourcePath + "resources2.cfg");

	Ogre::String dataFolder = cf.getSetting("DoNotUseAsResource", "Hlms", "");

	if (dataFolder.empty())
	dataFolder = "./";
	else if (*(dataFolder.end() - 1) != '/')
	dataFolder += "/";

	Ogre::RenderSystem *renderSystem = mpRoot->getRenderSystem();

	Ogre::String shaderSyntax = "GLSL";
	if (renderSystem->getName() == "Direct3D11 Rendering Subsystem")
	shaderSyntax = "HLSL";

	Ogre::Archive *archiveLibrary = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Common/" + shaderSyntax,
	"FileSystem", true);
	Ogre::Archive *archiveLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Common/Any",
	"FileSystem", true);
	Ogre::Archive *archivePbsLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Pbs/Any",
	"FileSystem", true);
	Ogre::Archive *pbsLibrary = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Pbs/" + shaderSyntax,
	"FileSystem", true);

	Ogre::ArchiveVec library;
	library.push_back(archiveLibrary);
	library.push_back(archiveLibraryAny);
	library.push_back(archivePbsLibraryAny);
	library.push_back(pbsLibrary);

	Ogre::Archive *archiveTerra = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Terra/" + shaderSyntax,
	"FileSystem", true);
	Ogre::HlmsTerra *hlmsTerra = OGRE_NEW Ogre::HlmsTerra(archiveTerra, &library);
	Ogre::HlmsManager *hlmsManager = mpRoot->getHlmsManager();
	hlmsManager->registerHlms(hlmsTerra);

	//Add Terra's piece files that customize the PBS implementation.
	//These pieces are coded so that they will be activated when
	//we set the HlmsPbsTerraShadows listener and there's an active Terra
	//(see Tutorial_TerrainGameState::createScene01)
	Ogre::Hlms *hlmsPbs = hlmsManager->getHlms(Ogre::HLMS_PBS);
	Ogre::Archive *archivePbs = hlmsPbs->getDataFolder();
	Ogre::ArchiveVec libraryPbs = hlmsPbs->getPiecesLibraryAsArchiveVec();
	libraryPbs.push_back(Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Terra/" + shaderSyntax + "/PbsTerraShadows",
	"FileSystem", true));
	hlmsPbs->reloadFrom(archivePbs, &libraryPbs);
	}
コード例 #10
0
ファイル: rtt.cpp プロジェクト: Joooo/pseudoform
        void rtt::clear(unsigned buffers, const colour &c, float d, unsigned s)
        {
            assert(_viewport);

            Ogre::RenderSystem *rs = Ogre::Root::getSingleton().getRenderSystem();

            rs->_setViewport(_viewport);
            rs->clearFrameBuffer(buffers, c, d, s);
        }
コード例 #11
0
void RenderedCompassImpl::_setCompass(Compass* compass)
{
	Ogre::MaterialPtr originalMaterial = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(mMaterialName));
	if (originalMaterial) {
		originalMaterial->load();
		mCompassMaterial = originalMaterial->clone(OgreInfo::createUniqueResourceName(originalMaterial->getName()));
		if (Ogre::Technique* tech = mCompassMaterial->getBestTechnique()) {
			Ogre::Pass* pass = nullptr;
			if (tech->getNumPasses() && (pass = tech->getPass(0))) {
				mCompassMaterialMapTUS = pass->getTextureUnitState("Background");
				if (mCompassMaterialMapTUS) {
					//Make sure that the compass material is using the map texture for the base rendering
					mCompassMaterialMapTUS->setTexture(mMap->getTexture());

					mTexture = Ogre::TextureManager::getSingleton().createManual("RenderedCompass", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 128, 128, 1, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET);
					mRenderTexture = mTexture->getBuffer()->getRenderTarget();
					mRenderTexture->removeAllViewports();
					mRenderTexture->setAutoUpdated(false);
					mRenderTexture->setActive(true);

					mCamera = mSceneManager->createCamera("RenderedCompassCamera");
					mViewport = mRenderTexture->addViewport(mCamera);
					mViewport->setOverlaysEnabled(false);
					mViewport->setShadowsEnabled(false);
					mViewport->setSkiesEnabled(false);
					mViewport->setClearEveryFrame(true);
					mViewport->setBackgroundColour(Ogre::ColourValue::ZERO);

					mMapRectangle = OGRE_NEW Ogre::Rectangle2D(true);
					auto mapMaterialPtr = Ogre::MaterialManager::getSingleton().getByName(mCompassMaterial->getName(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
					if (mapMaterialPtr) {
						mMapRectangle->setMaterial(mapMaterialPtr);
					}

					//We need to maximise the rendered texture to cover the whole screen
					Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
					Ogre::Real hOffset = rs->getHorizontalTexelOffset() / (0.5 * mViewport->getActualWidth());
					Ogre::Real vOffset = rs->getVerticalTexelOffset() / (0.5 * mViewport->getActualHeight());
					mMapRectangle->setCorners(-1 + hOffset, 1 - vOffset, 1 + hOffset, -1 - vOffset);

					//Since a Rectangle2D instance is a moveable object it won't be rendered unless it's in the frustrum. If we set the axis aligned box to be "infinite" it will always be rendered.
					Ogre::AxisAlignedBox aabInf;
					aabInf.setInfinite();
					mMapRectangle->setBoundingBox(aabInf);

					//We can't attach something to the root node, so we'll attach it to a newly created node. We won't keep a reference to this node since it will be destroyed along with the scene manager when we ourselves are destroyed.
					mSceneManager->getRootSceneNode()->createChildSceneNode()->attachObject(mMapRectangle);

					//Return early since everything is good.
					return;
				}
			}
		}
	}
	S_LOG_WARNING("Could not load material '" << mMaterialName << "' for the compass.");
}
コード例 #12
0
ファイル: McsHudGui.cpp プロジェクト: 1am3r/cubicplanets
void FrameGraphRenderable::fillHardwareBuffers()
{
    Ogre::HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
    Ogre::Real *vertices = static_cast<Ogre::Real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));

    Ogre::HardwareVertexBufferSharedPtr vcbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(1);
    Ogre::RGBA* pColours = static_cast<Ogre::RGBA*>(vcbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));

    Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
    uint16_t index = 0;
    for (uint16_t i = 0; i < mNumFrames; i++) {
        float x = i * mLineSpace - 1.0f;

        // OgreTime line
        vertices[index +  0] = x;
        vertices[index +  1] = -1;
        vertices[index +  2] = 0;	// Vertex
        rs->convertColourValue(Ogre::ColourValue(1.0f, 0.0f, 0.0f), pColours++);		// Color
        vertices[index +  3] = x;
        vertices[index +  4] = -1;
        vertices[index +  5] = 0;	// Vertex
        rs->convertColourValue(Ogre::ColourValue(1.0f, 0.0f, 0.0f), pColours++);		// Color

        // BulletTime line
        vertices[index +  6] = x;
        vertices[index +  7] = -1;
        vertices[index +  8] = 0;	// Vertex
        rs->convertColourValue(Ogre::ColourValue(0.0f, 1.0f, 0.0f), pColours++);		// Color
        vertices[index +  9] = x;
        vertices[index + 10] = -1;
        vertices[index + 11] = 0;	// Vertex
        rs->convertColourValue(Ogre::ColourValue(0.0f, 1.0f, 0.0f), pColours++);		// Color

        // WorldTime line
        vertices[index + 12] = x;
        vertices[index + 13] = -1;
        vertices[index + 14] = 0;	// Vertex
        rs->convertColourValue(Ogre::ColourValue(0.0f, 0.0f, 1.0f), pColours++);		// Color
        vertices[index + 15] = x;
        vertices[index + 16] = -1;
        vertices[index + 17] = 0;	// Vertex
        rs->convertColourValue(Ogre::ColourValue(0.0f, 0.0f, 1.0f), pColours++);		// Color

        // UnknownTime line
        vertices[index + 18] = x;
        vertices[index + 19] = -1;
        vertices[index + 20] = 0;	// Vertex
        rs->convertColourValue(Ogre::ColourValue(1.0f, 1.0f, 1.0f), pColours++);		// Color
        vertices[index + 21] = x;
        vertices[index + 22] = -1;
        vertices[index + 23] = 0;	// Vertex
        rs->convertColourValue(Ogre::ColourValue(1.0f, 1.0f, 1.0f), pColours++);		// Color

        index += ValuesPerGraphLine;
    }
    vcbuf->unlock();
    vbuf->unlock();

    mBox.setInfinite();
}
コード例 #13
0
	void OgreRTTexture::end()
	{
		Ogre::RenderSystem* system = Ogre::Root::getSingleton().getRenderSystem();
		system->_setViewport(mSaveViewport);
#if OGRE_VERSION >= MYGUI_DEFINE_VERSION(1, 7, 0) && OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0
		Ogre::OrientationMode orient = mSaveViewport->getOrientationMode();
		system->_setProjectionMatrix(Ogre::Matrix4::IDENTITY * Ogre::Quaternion(Ogre::Degree(orient * 90.f), Ogre::Vector3::UNIT_Z));
#else
		system->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
#endif
	}
コード例 #14
0
ファイル: manager.cpp プロジェクト: jhooks1/openmw
 void updateRenderInfo()
 {
     if (mRenderSystem != nullptr)
     {
         mInfo.maximumDepth = mRenderSystem->getMaximumDepthInputValue();
         mInfo.hOffset = mRenderSystem->getHorizontalTexelOffset() / float(mViewSize.width);
         mInfo.vOffset = mRenderSystem->getVerticalTexelOffset() / float(mViewSize.height);
         mInfo.aspectCoef = float(mViewSize.height) / float(mViewSize.width);
         mInfo.pixScaleX = 1.0f / float(mViewSize.width);
         mInfo.pixScaleY = 1.0f / float(mViewSize.height);
     }
 }
コード例 #15
0
/** The Ogre renderQueueStarted implementation
  *
  * The more used parameter is the queueGroupId. 90 is for the 
  * object to be highlighted, 91 is its outline.
  *
  * \param queueGroupId The queue group identifier (90 and 91 are treated)
  * \param invocation Unused Ogre provided parameter
  * \param repeatThisInvocation Unused Ogre provided parameter
  *
  */
void RainbruRPG::Core::HighlightQueueListener::
renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, 
		 bool& repeatThisInvocation)
{
  if (( queueGroupId == 90 ) || ( queueGroupId == 91 )){
    Ogre::RenderSystem * rendersys = Ogre::Root::getSingleton()
      .getRenderSystem();

    rendersys->setStencilCheckEnabled(false);
    rendersys->setStencilBufferParams();
  }
}
コード例 #16
0
ファイル: GameMain.cpp プロジェクト: oksangman/Ant
void GameMain::CreateRenderer()
{

	m_pkRoot = new Ogre::Root();

	mD3D9Plugin = new Ogre::D3D9Plugin();
	m_pkRoot->installPlugin(mD3D9Plugin);
	mOctreePlugin = new Ogre::OctreePlugin();
	m_pkRoot->installPlugin(mOctreePlugin);
	mBSPPlugin = new BspSceneManagerPlugin();
	m_pkRoot->installPlugin(mBSPPlugin);
	mCgPlugin = new CgPlugin();
	m_pkRoot->installPlugin(mCgPlugin);
	mParticleFXPlugin = new ParticleFXPlugin();
	m_pkRoot->installPlugin(mParticleFXPlugin);

	//	Initialize window
	Ogre::RenderSystem *selectedRenderSystem = m_pkRoot->getRenderSystemByName("Direct3D9 Rendering Subsystem");
	m_pkRoot->setRenderSystem(selectedRenderSystem);
	selectedRenderSystem->setConfigOption("Full Screen", "No");
	selectedRenderSystem->setConfigOption("VSync","Yes");
	char value[128];
	sprintf(value, "%d x %d @ %d-bit colour", Chapter::ms_nWidth, Chapter::ms_nHeight, 32);
	selectedRenderSystem->setConfigOption("Video Mode", value);



	m_pkWindow = m_pkRoot->initialise(false, "Test Bullet");

	Ogre::NameValuePairList parms;
	parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);

	m_pkWindow = m_pkRoot->createRenderWindow("Test Bullet", Chapter::ms_nWidth, Chapter::ms_nHeight, !Chapter::ms_bWindowed, &parms);

	Chapter::ms_hWnd = m_hWnd;
	Chapter::m_pkRoot = m_pkRoot;
	Chapter::m_pkWindow = m_pkWindow;

	m_pkRoot->addFrameListener( this );

	m_pkWindow->setActive(true);
	m_pkWindow->update();


	//	Add media path
	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);


	m_fCurrentTime =  GetTickCount();
}
コード例 #17
0
bool OgreApplication::initStart(void)
{

    mPluginsCfg = "../configs/plugins.cfg";
    mResourcesCfg = "../configs/resources.cfg";

    Ogre::LogManager * lm = new Ogre::LogManager();
    lm->createLog("OgreLogfile.log", true, false, false);

    // construct Ogre::Root
    mRoot = new Ogre::Root(mPluginsCfg, "", "");

    Ogre::ConfigFile cf;
    cf.load(mResourcesCfg);

    // Go through all sections & settings in the file
    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

    Ogre::String secName, typeName, archName;
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            typeName = i->first;
            archName = i->second;
            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
                archName, typeName, secName);
        }
    }

    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../assets/", "FileSystem");

    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../assets/particles", "FileSystem");

    // Do not add this to the application
    Ogre::RenderSystem *rs = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
    mRoot->setRenderSystem(rs);
    rs->setConfigOption("Full Screen", "No");
    rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
    rs->setStencilCheckEnabled(true);

    mRoot->initialise(false);

    running = true;
    return true;
}
コード例 #18
0
ファイル: QtWidget.cpp プロジェクト: Smiter/Ogre_editor
void OgreWidget::init( std::string plugins_file,  std::string ogre_cfg_file, std::string ogre_log )
{
  mOgreRoot = new Ogre::Root( plugins_file, ogre_cfg_file, ogre_log );
  Ogre::RenderSystemList renderers = mOgreRoot->getAvailableRenderers();
  assert( !renderers.empty() );
  Ogre::RenderSystem *renderSystem = chooseRenderer(& renderers );
  assert( renderSystem );
  mOgreRoot->setRenderSystem( renderSystem );
  QString dimensions = QString( "%1x%2" ).arg(this->width()).arg(this->height());
  renderSystem->setConfigOption( "Video Mode", dimensions.toStdString() );
  mOgreRoot->getRenderSystem()->setConfigOption( "Full Screen", "No" );
  mOgreRoot->saveConfig();
  mOgreRoot->initialise(false);
  initResourses();
}
コード例 #19
0
ファイル: scene_manager.cpp プロジェクト: jmecosta/Navlaser3
//-------------------------------------------------------------------------------------
bool THIS::configure(void)
{

    cout << "<TRACE><LOG><SceneManager><configure> Start" << endl;
    // Show the configuration dialog and initialise the system
    // You can skip this and use root.restoreConfig() to load configuration
    // settings if you were sure there are valid ones saved in ogre.cfg
    //mRoot->showConfigDialog();
    //{
    // If returned true, user clicked OK so initialise
    // Here we choose to let the system create a default rendering window by passing 'true'
    //     mWindow = mRoot->initialise(true, "TutorialApplication Render Window");

    //return true;
    //}
    //else
    //{
    //    return false;
    //}

    // setup a renderer
    Ogre::RenderSystemList::const_iterator renderers = mRoot->getAvailableRenderers().begin();
    while(renderers != mRoot->getAvailableRenderers().end())
    {
        Ogre::String rName = (*renderers)->getName();
        if (rName == "OpenGL Rendering Subsystem")
            break;
        renderers++;
    }

    Ogre::RenderSystem *renderSystem = *renderers;

    mRoot->setRenderSystem( renderSystem );
    QString dimensions = QString( "%1x%2" )
            .arg(this->width())
            .arg(this->height());

    renderSystem->setConfigOption( "Video Mode", dimensions.toStdString() );

    // initialize without creating window
    mRoot->getRenderSystem()->setConfigOption( "Full Screen", "No" );
    mRoot->saveConfig();

    cout << "<TRACE><LOG><SceneManager><configure> initialize" << endl;
    mRoot->initialise(false); // don't create a window

}
コード例 #20
0
    void GameSettings::update()
    {
        Root* root = Ogre::Root::getSingletonPtr();
        
		Ogre::RenderSystem* renderer = root->getRenderSystem();

#if OGRE_VERSION_MINOR == 7 || OGRE_VERSION_MINOR == 8
        const RenderSystemList& renderers = root->getAvailableRenderers();
#else 
        const RenderSystemList renderers = *root->getAvailableRenderers();
#endif        
        createElements(mVideoRenderer, renderers.size());

        for (unsigned int i = 0; i < renderers.size(); ++i)
        {
			Ogre::RenderSystem* cur = renderers[i];
            ListboxItem* item = mVideoRenderer->getListboxItemFromIndex(i);
            item->setText(cur->getName());
            if (cur == renderer)
            {
                mVideoRenderer->setItemSelectState(item, true);
            }
        }
        
        ConfigOptionMap config = renderer->getConfigOptions();
        
        setOption(config, "Full Screen", mVideoFullscreen);
        std::vector<RadioButton*> videoColorDepth;
        videoColorDepth.push_back(mVideoColorDepth32);
        videoColorDepth.push_back(mVideoColorDepth16);
        
        setOption(config, "Colour Depth", videoColorDepth);
        std::vector<RadioButton*> videoAntiAliasing;
        videoAntiAliasing.push_back(mVideoFsaa0);
        videoAntiAliasing.push_back(mVideoFsaa2);
        videoAntiAliasing.push_back(mVideoFsaa4);
        videoAntiAliasing.push_back(mVideoFsaa8);
        setOption(config, "FSAA", videoAntiAliasing);
        
		std::vector<RadioButton*> videoRttMode;
        videoRttMode.push_back(mVideoRttModeFBO);
        videoRttMode.push_back(mVideoRttModePBuffer);
        videoRttMode.push_back(mVideoRttModeCopy);
        setOption(config, "RTT Preferred Mode", videoRttMode);
        
        setOption(config, "Video Mode", mVideoResolution);
    }
コード例 #21
0
/**
 * Setup application configuration options
 */
bool Robot::Application::configure()
{
	// Always load the GL render system
	this->mRoot->loadPlugin("./RenderSystem_GL");

	// Get the GL Render system and set it on the root
	Ogre::RenderSystem* RS = this->mRoot->getAvailableRenderers()[0];
	this->mRoot->setRenderSystem(RS);

	// Dont use full-screen
	RS->setConfigOption("Full Screen", "no");

	// Setup the root window
	this->mWindow = this->mRoot->initialise(true, "CG - Project 4");

	return true;
}
コード例 #22
0
//------------------------------------------------------------------------------
void wxOgreRenderSystem::SelectOgreRenderSystem(const Ogre::String& render)
{
    Ogre::RenderSystemList renderList;
    Ogre::RenderSystemList::iterator it;

    renderList = m_root->getAvailableRenderers();
    // check through all available renderers, if there is one the
    // string is "render"
    for (it = renderList.begin(); it != renderList.end(); ++it) {
        Ogre::RenderSystem* renderSys = *it;
        if (std::string (renderSys->getName()) == render) {
            m_root->setRenderSystem(renderSys);
            break;
        }
    }

}
コード例 #23
0
ファイル: render_system.cpp プロジェクト: CURG/rviz
void RenderSystem::detectGlVersion()
{
  if ( force_gl_version_ )
  {
    gl_version_ = force_gl_version_;
  }
  else
  {
    Ogre::RenderSystem *renderSys = ogre_root_->getRenderSystem();
    renderSys->createRenderSystemCapabilities();
    const Ogre::RenderSystemCapabilities* caps = renderSys->getCapabilities();
    int major = caps->getDriverVersion().major;
    int minor = caps->getDriverVersion().minor;
    gl_version_ = major * 100 + minor*10;
  }

  switch ( gl_version_ )
  {
    case 200:
      glsl_version_ = 110;
      break;
    case 210:
      glsl_version_ = 120;
      break;
    case 300:
      glsl_version_ = 130;
      break;
    case 310:
      glsl_version_ = 140;
      break;
    case 320:
      glsl_version_ = 150;
      break;
    default:
      if ( gl_version_ > 320 )
      {
        glsl_version_  = gl_version_;
      }
      else
      {
        glsl_version_ = 0;
      }
      break;
  }
  ROS_INFO_STREAM( "OpenGl version: " << (float)gl_version_ / 100.0 << " (GLSL " << (float)glsl_version_ / 100.0 << ")." );
}
コード例 #24
0
	void OgreRTTexture::begin()
	{
		Ogre::RenderTexture* rtt = mTexture->getBuffer()->getRenderTarget();

		if (mViewport == nullptr)
		{
			mViewport = rtt->addViewport(nullptr);
			mViewport->setClearEveryFrame(false);
			mViewport->setOverlaysEnabled(false);
		}

		Ogre::RenderSystem* system = Ogre::Root::getSingleton().getRenderSystem();
		system->_setProjectionMatrix(mProjectMatrix);
		mSaveViewport = system->_getViewport();
		system->_setViewport(mViewport);
		system->clearFrameBuffer(Ogre::FBT_COLOUR, Ogre::ColourValue::ZERO);
	}
コード例 #25
0
ファイル: ogreapp.cpp プロジェクト: dorgonman/cocos2d-x-ogre
/** Sets up the application - returns false if the user chooses to abandon configuration. */
bool OgreApp::setup(void){
	String cfgPath = mResourcePath + resource_cfg_file;

	mRoot = new Root();

#if( CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID )
	Ogre::GLES2Plugin* plugin = new Ogre::GLES2Plugin();
#else
	Ogre::GLPlugin* plugin = new Ogre::GLPlugin();
	//Ogre::GLES2Plugin* plugin = new Ogre::GLES2Plugin();
#endif

	mRoot->installPlugin(plugin);
	Ogre::RenderSystem* rs = mRoot->getRenderSystemByName( "OpenGL Rendering Subsystem" );
	assert( rs );

//    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCSize frameSize = CCDirector::sharedDirector()->getWinSize();
	char buff[256]; memset( buff, 0x00, sizeof(buff) );
	sprintf( buff, "%dx%d", (int)frameSize.width, (int)frameSize.height );
//	sprintf( buff, "%dx%d", 200, 200 );
	rs->setConfigOption( "Video Mode", buff );
	rs->setConfigOption( "Full Screen", "No" );

	mRoot->setRenderSystem( rs );
	mWindow = mRoot->initialise(true);

	setupResources();

	chooseSceneManager();
	createCamera();
	createViewports();

	// Set default mipmap level (NB some APIs ignore this)
	TextureManager::getSingleton().setDefaultNumMipmaps(5);

	// Create any resource listeners (for loading screens)
	createResourceListener();
	// Load resources

#if( CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID )
	//android 不需要?
	loadResources();
#endif
	return true;
}
コード例 #26
0
/** The Ogre renderQueueStarted implementation
  *
  * The more used parameter is the queueGroupId. 90 is for the 
  * object to be highlighted, 91 is its outline.
  *
  * \param queueGroupId The queue group identifier (90 and 91 are treated)
  * \param invocation Unused Ogre provided parameter
  * \param skipThisInvocation Unused Ogre provided parameter
  *
  */
void RainbruRPG::Core::HighlightQueueListener::
renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, 
		   bool& skipThisInvocation)

{
  //RenderQueue containing the object to be highlighted
  if (queueGroupId == 90){
    Ogre::RenderSystem * rendersys = Ogre::Root::getSingleton()
      .getRenderSystem();
		
    rendersys->clearFrameBuffer(Ogre::FBT_STENCIL);
    rendersys->setStencilCheckEnabled(true);
    rendersys->setStencilBufferParams(Ogre::CMPF_ALWAYS_PASS,1,0xFFFFFFFF,
				      Ogre::SOP_KEEP,Ogre::SOP_KEEP,
				      Ogre::SOP_REPLACE,false);      
  }
  
  //RenderQueue containing the outline
  if (queueGroupId == 91){
    Ogre::RenderSystem * rendersys = Ogre::Root::getSingleton()
      .getRenderSystem();
    
    rendersys->setStencilCheckEnabled(true);
    rendersys->setStencilBufferParams(Ogre::CMPF_NOT_EQUAL,1,0xFFFFFFFF,
				      Ogre::SOP_KEEP,Ogre::SOP_KEEP,
				      Ogre::SOP_KEEP,false);      
    }
}
コード例 #27
0
	void LayerManager::_windowResized(const FloatSize& _size)
	{
		// новый размер
		mViewSize = _size;

		mPixScaleX = 1.0 / _size.width;
		mPixScaleY = 1.0 / _size.height;
		mAspectCoef = _size.height / _size.width;

		Ogre::RenderSystem * render = Ogre::Root::getSingleton().getRenderSystem();

        mHOffset = render->getHorizontalTexelOffset() / _size.width;
        mVOffset = render->getVerticalTexelOffset() / _size.height;

		// обновить всех
		mUpdate = true;

	}
コード例 #28
0
void RenderSystem::setupRenderSystem()
{
    Ogre::RenderSystem *renderSys;
    const Ogre::RenderSystemList *rsList;

    // Get the list of available renderers.
#if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR == 6
    rsList = ogre_root_->getAvailableRenderers();
#else
    rsList = &(ogre_root_->getAvailableRenderers());
#endif

    // Look for the OpenGL one, which we require.
    renderSys = NULL;
    for( unsigned int i = 0; i < rsList->size(); i++ )
    {
        renderSys = rsList->at( i );
        if( renderSys->getName().compare("OpenGL Rendering Subsystem")== 0 )
        {
            break;
        }
    }

    if( renderSys == NULL )
    {
        throw std::runtime_error( "Could not find the opengl rendering subsystem!\n" );
    }

    // We operate in windowed mode
    renderSys->setConfigOption("Full Screen","No");

    /// We used to allow the user to set the RTT mode to PBuffer, FBO, or Copy.
    ///   Copy is slow, and there doesn't seem to be a good reason to use it
    ///   PBuffer limits the size of the renderable area of the RTT to the
    ///           size of the first window created.
    ///   FBO seem to be the only good option
    //  renderSys->setConfigOption("RTT Preferred Mode", "FBO");

    // Set the Full Screen Anti-Aliasing factor.
    renderSys->setConfigOption("FSAA", "2");

    ogre_root_->setRenderSystem(renderSys);
}
コード例 #29
0
ファイル: manager.cpp プロジェクト: Allxere/openmw
    void doRender(IVertexBuffer* _buffer, ITexture* _texture, size_t _count)
    {
        if (getManualRender())
        {
            begin();
            setManualRender(false);
        }

        // ADDED
        if (!mVertexProgramNoTexture)
            initShaders();

        if (_texture)
        {
            Ogre::Root::getSingleton().getRenderSystem()->bindGpuProgram(mVertexProgramOneTexture);
            Ogre::Root::getSingleton().getRenderSystem()->bindGpuProgram(mFragmentProgramOneTexture);
        }
        else
        {
            Ogre::Root::getSingleton().getRenderSystem()->bindGpuProgram(mVertexProgramNoTexture);
            Ogre::Root::getSingleton().getRenderSystem()->bindGpuProgram(mFragmentProgramNoTexture);
        }

        if (_texture)
        {
            OgreTexture* texture = static_cast<OgreTexture*>(_texture);
            Ogre::TexturePtr texture_ptr = texture->getOgreTexture();
            if (!texture_ptr.isNull())
            {
                mRenderSystem->_setTexture(0, true, texture_ptr);
                mRenderSystem->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
            }
        }

        OgreVertexBuffer* buffer = static_cast<OgreVertexBuffer*>(_buffer);
        Ogre::RenderOperation* operation = buffer->getRenderOperation();
        operation->vertexData->vertexCount = _count;

        mRenderSystem->_render(*operation);

        ++ mCountBatch;
    }
コード例 #30
0
void OgreImGui::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation,bool& repeatThisInvocation)
{
    if ((queueGroupId != Ogre::RENDER_QUEUE_OVERLAY) || (invocation == "SHADOWS"))
    {
        return;
    }

    Ogre::RenderSystem* renderSys = Ogre::Root::getSingletonPtr()->getRenderSystem();
    Ogre::Viewport* vp = renderSys->_getViewport();

    if ((vp == nullptr) || (!vp->getTarget()->isPrimary()) || mFrameEnded)
    {
        return;
    }

    mFrameEnded = true;
    ImGui::Render();
    this->updateVertexData();
    ImGuiIO& io = ImGui::GetIO();

    // Construct projection matrix, taking texel offset corrections in account (important for DirectX9)
    // See also:
    //     - OGRE-API specific hint: http://www.ogre3d.org/forums/viewtopic.php?f=5&p=536881#p536881
    //     - IMGUI Dx9 demo solution: https://github.com/ocornut/imgui/blob/master/examples/directx9_example/imgui_impl_dx9.cpp#L127-L138
    const float texelOffsetX = renderSys->getHorizontalTexelOffset();
    const float texelOffsetY = renderSys->getVerticalTexelOffset();
    const float L = texelOffsetX;
    const float R = io.DisplaySize.x + texelOffsetX;
    const float T = texelOffsetY;
    const float B = io.DisplaySize.y + texelOffsetY;

    Ogre::Matrix4 projMatrix(       2.0f/(R-L),    0.0f,         0.0f,       (L+R)/(L-R),
                                    0.0f,         -2.0f/(B-T),   0.0f,       (T+B)/(B-T),
                                    0.0f,          0.0f,        -1.0f,       0.0f,
                                    0.0f,          0.0f,         0.0f,       1.0f);

    mPass->getVertexProgramParameters()->setNamedConstant("ProjectionMatrix", projMatrix);
    for(std::list<ImGUIRenderable*>::iterator it = mRenderables.begin(); it!=mRenderables.end(); ++it)
    {
        mSceneMgr->_injectRenderWithPass(mPass, (*it), false, false, nullptr);
    }
}