/// @brief  Configures the render system ogre uses.
/// @return Returns true if a valid configuration was selected, false otherwise.
bool ServerGraphics::configureRenderer (void)
{
    // Automatically initialise with the config dialog
    //if (mRoot->showConfigDialog())
        //return true;
    //return false;

    // Manually initialise
    RenderSystem* rs = NULL;
    RenderSystemList systems = Root::getSingleton().getAvailableRenderers();

    // Check if any render systems exist
    if (systems.empty())
        return false;
    // Check if OpenGL is one of those rendering systems (should be)
    for (RenderSystemList::iterator itr = systems.begin(); itr != systems.end(); itr++)
        if (!strcmp((*itr)->getName().c_str(), "OpenGL Rendering Subsystem"))
            rs = *itr;
    // If it wasn't, default to the first renderer
    if (rs == NULL)
    {
        //OutputDebugString("OpenGL not found, defaulting to the first item.\n");
        rs = *systems.begin();
    }

    Root::getSingleton().setRenderSystem(rs);
    rs->setConfigOption("Video Mode", "640 x 480");
#ifdef _WIN32
    rs->setConfigOption("Colour Depth", "32");
#endif
    rs->setConfigOption("Full Screen", "No");
    rs->setConfigOption("FSAA", "0");

    return true;
}
Exemplo n.º 2
0
    //---------------------------------------------------------------------
    void Viewport::setOrientationMode(OrientationMode orientationMode, bool setDefault)
    {
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
        OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
                    "Setting Viewport orientation mode is not supported",
                    __FUNCTION__);
#endif
        mOrientationMode = orientationMode;

        if (setDefault)
        {
            setDefaultOrientationMode(orientationMode);
        }

        if (mCamera)
        {
            mCamera->setOrientationMode(mOrientationMode);
        }

	// Update the render system config
#if OGRE_PLATFORM == OGRE_PLATFORM_IPHONE
        RenderSystem* rs = Root::getSingleton().getRenderSystem();
        if(mOrientationMode == OR_LANDSCAPELEFT)
            rs->setConfigOption("Orientation", "Landscape Left");
        else if(mOrientationMode == OR_LANDSCAPERIGHT)
            rs->setConfigOption("Orientation", "Landscape Right");
        else if(mOrientationMode == OR_PORTRAIT)
            rs->setConfigOption("Orientation", "Portrait");
#endif
    }
Exemplo n.º 3
0
void OgreFramework::manualRenderInit() {
  const RenderSystemList &renderers = Root::getSingleton().getAvailableRenderers();

  if (renderers.empty()) {
    return;
  }

  RenderSystem *renderer = *renderers.begin();
  Root::getSingleton().setRenderSystem(renderer);

  renderer->setConfigOption("Video Mode", " 640 x  480");
  renderer->setConfigOption("Full Screen", "No");
}
void GLXConfigurator::SetConfigOption(const std::string &optionName, const std::string &valueName) {
	if(!mRenderer)
		// No renderer set -- how can this be called?
		return;
	mRenderer->setConfigOption(optionName, valueName);
	SetRenderer(mRenderer);
}
Exemplo n.º 5
0
    bool ConfigDialog::display()
    {
        // TODO: Fix OS X Config dialog
        const RenderSystemList& renderers = Root::getSingleton().getAvailableRenderers();
        RenderSystem* renderer = renderers.front();

        // WARNING: restoreConfig() should not be invoked here as Root calls
        // it before this method anyway, and invoking restoreConfig() here
        // forces the client application to use Ogre.cfg, while it may have
        // different plans.
        if(!Root::getSingleton().restoreConfig())
        {
            // Set some defaults
            renderer->setConfigOption("Video Mode", "800 x 600");
            renderer->setConfigOption("Colour Depth", "32");
            renderer->setConfigOption("FSAA", "0");
            renderer->setConfigOption("Full Screen", "No");
            renderer->setConfigOption("RTT Preferred Mode", "FBO");
            // Set the rendersystem and save the config.
            Root::getSingleton().setRenderSystem(renderer);
        }
        return true;
    }
Exemplo n.º 6
0
void OgreRenderer::configure(const std::string &logPath,
                            const std::string& renderSystem,
                             const std::string& rttMode
                            )
{
    mOgreInit = new OgreInit::OgreInit();
    mRoot = mOgreInit->init(logPath + "/ogre.log");

    RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
    if (rs == 0)
        throw std::runtime_error ("RenderSystem with name " + renderSystem + " not found, make sure the plugins are loaded");
    mRoot->setRenderSystem(rs);

    if (rs->getName().find("OpenGL") != std::string::npos)
        rs->setConfigOption ("RTT Preferred Mode", rttMode);
}
Exemplo n.º 7
0
int main()
{
  Root *root = new Root(StringUtil::BLANK, StringUtil::BLANK);
  GLPlugin *glPlugin = new GLPlugin();
  root->installPlugin(glPlugin);
  RenderSystem *renderSystem = root->getAvailableRenderers().at(0);
  renderSystem->setConfigOption("Fixed Pipeline Enabled", "No");
  root->setRenderSystem(renderSystem);
  root->initialise(false);
  RenderWindow *window = root->createRenderWindow("Hello, OGRE", 800, 600, false);
  SceneManager *sceneManager = root->createSceneManager(ST_GENERIC);
  ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
  RTShader::ShaderGenerator::initialize();
  RTShader::ShaderGenerator::getSingleton().addSceneManager(sceneManager);

  createSphereMesh("SphereMesh", 10.f, 16, 16);
  ResourceGroupManager::getSingleton().addResourceLocation("shader", "FileSystem");
  createSphereMaterial("SphereMaterial", 1.f, 0.f, 0.f);

  Camera *camera = sceneManager->createCamera("Camera");
  camera->setPosition(0.f, 0.f, 80.f);
  camera->lookAt(0.f, 0.f, 0.f);
  camera->setNearClipDistance(5.f);
  Viewport *viewport = window->addViewport(camera);
  viewport->setBackgroundColour(ColourValue(0.f, 0.f, 0.f));
  viewport->setMaterialScheme(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
  camera->setAspectRatio((Real)(viewport->getActualWidth()) / (Real)(viewport->getActualHeight()));

  sceneManager->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f));
  Light *light = sceneManager->createLight("Light");
  light->setPosition(50.f, 50.f, 50.f);

  Entity *sphereEntity = sceneManager->createEntity("SphereEntity", "SphereMesh");
  sphereEntity->setMaterialName("SphereMaterial");
  SceneNode *sphereNode = sceneManager->getRootSceneNode()->createChildSceneNode();
  sphereNode->attachObject(sphereEntity);

  HelloOgreFrameListener *frameListener = new HelloOgreFrameListener(window);
  root->addFrameListener(frameListener);
  root->startRendering();

  delete frameListener;
  delete root;
  delete glPlugin;

  return 0;
}
Exemplo n.º 8
0
void OgreRenderer::configure(const std::string &logPath,
                            const std::string& renderSystem,
                             const std::string& rttMode,
                            bool _logging)
{
    // Set up logging first
    new LogManager;
    Log *log = LogManager::getSingleton().createLog(logPath + std::string("Ogre.log"));
    logging = _logging;

    if(logging)
        // Full log detail
        log->setLogDetail(LL_BOREME);
    else
        // Disable logging
        log->setDebugOutputEnabled(false);

#if defined(__APPLE__) && !defined(__LP64__)
    mRoot = new CustomRoot("", "", "");
#else
    mRoot = new Root("", "", "");
#endif

    #if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX)
    loadPlugins();
    #endif

    std::string pluginDir;
    const char* pluginEnv = getenv("OPENMW_OGRE_PLUGIN_DIR");
    if (pluginEnv)
        pluginDir = pluginEnv;
    else
    {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        pluginDir = ".\\";
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
        pluginDir = OGRE_PLUGIN_DIR;
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
        pluginDir = OGRE_PLUGIN_DIR_REL;
#endif
    }

    boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));

    pluginDir = absPluginPath.string();

    Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mRoot);
    Files::loadOgrePlugin(pluginDir, "RenderSystem_GL3Plus", *mRoot);
    Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mRoot);
    Files::loadOgrePlugin(pluginDir, "Plugin_CgProgramManager", *mRoot);

    RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
    if (rs == 0)
        throw std::runtime_error ("RenderSystem with name " + renderSystem + " not found, make sure the plugins are loaded");
    mRoot->setRenderSystem(rs);

    if (rs->getName().find("OpenGL") != std::string::npos)
        rs->setConfigOption ("RTT Preferred Mode", rttMode);
}
Exemplo n.º 9
0
    //-----------------------------------------------------------------------
    bool Root::restoreConfig(void)
    {
        if (mConfigFileName.empty ())
            return true;

        // Restores configuration from saved state
        // Returns true if a valid saved configuration is
        //   available, and false if no saved config is
        //   stored, or if there has been a problem
        ConfigFile cfg;
        //RenderSystemList::iterator pRend;

        try {
            // Don't trim whitespace
            cfg.load(mConfigFileName, "\t:=", false);
        }
        catch (Exception& e)
        {
            if (e.getNumber() == Exception::ERR_FILE_NOT_FOUND)
            {
                return false;
            }
            else
            {
                throw;
            }
        }

        ConfigFile::SectionIterator iSection = cfg.getSectionIterator();
        while (iSection.hasMoreElements())
        {
            const String& renderSystem = iSection.peekNextKey();
            const ConfigFile::SettingsMultiMap& settings = *iSection.getNext();

            RenderSystem* rs = getRenderSystemByName(renderSystem);
            if (!rs)
            {
                // Unrecognised render system
                continue;
            }

            ConfigFile::SettingsMultiMap::const_iterator i;
            for (i = settings.begin(); i != settings.end(); ++i)
            {
                rs->setConfigOption(i->first, i->second);
            }
        }

        RenderSystem* rs = getRenderSystemByName(cfg.getSetting("Render System"));
        if (!rs)
        {
            // Unrecognised render system
            return false;
        }

        setRenderSystem(rs);

        // Successful load
        return true;

    }