示例#1
0
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();
}
示例#2
0
文件: graphics.cpp 项目: Mononofu/OTE
bool GraphicsImpl::configure()
{
	Dout <<"Setting Rendering Subsystem" ;

	Ogre::RenderSystemList renderers = root->getAvailableRenderers();

	if (renderers.empty()) {
		Dout <<"No rendering system available" ;
		return false;
	}

	root->setRenderSystem(renderers.front());

	Dout <<"Init Root" ;

	root->initialise(false);

	Dout <<"Create window" ;

	window = root->createRenderWindow("Manual Ogre Window", boost::any_cast<int>(SettingsManager::Instance().getSetting("x_res").data), boost::any_cast<int>(SettingsManager::Instance().getSetting("y_res").data), false, 0);                      // use defaults for all other values


	return true;
}
示例#3
0
/*!
 * Initialize the application, in particular initialize OGRE and OIS
 * (the input system, see \ref InputHandler).
 *
 * \return TRUE on success, otherwise FALSE. The application should be
 * quit, if initializing failed.
 */
bool TestApp::initialize() {
    if (mOgreRoot) {
        // already initialized
        return true;
    }
    Ogre::String pluginFileName = "plugins.cfg"; // don't use any plugin config file
                                      // (we specify everything by code)
    Ogre::String configFileName = "ogre.cfg"; // don't use any config file
                                      // (we specify everything by code)

    // AB: we create our own logmanager - ogre will use that one.
    Ogre::String logFileName = "Ogre.log"; // AB: name to identify the log - won't necessarily write to a file!
    mOgreLogManager = new Ogre::LogManager();

    // create a default log that ogre itself is going to use.
    bool suppressFileOutput = false;
    bool outputToConsole = true;
    Ogre::Log* log = mOgreLogManager->createLog(logFileName, true, outputToConsole, suppressFileOutput);
    log->addListener(mMyOgreLogListener);

    // AB: atm we don't specify the 3rd parameter and thus use the default Ogre
    //     log filename (Ogre.log in the current dir)
    //     we could just use "" to disable the logfile.
    mOgreRoot = new Ogre::Root(pluginFileName, configFileName);

    // we use OpenGL
    //#if defined __APPLE__ || defined WIN32
    //    mOgreRoot->loadPlugin("RenderSystem_GL");
    //#else
    //    mOgreRoot->loadPlugin(DCOLLIDE_OGRE_PLUGIN_DIR "/RenderSystem_GL");
    //#endif

    Ogre::RenderSystemList* renderSystemList = mOgreRoot->getAvailableRenderers();
    if (renderSystemList->empty()) {
        std::cerr << "Could not load any renderers?!" << std::endl;
        return false;
    }
    Ogre::RenderSystem* renderSystem = renderSystemList->at(0);
    mOgreRoot->setRenderSystem(renderSystem);
    mOgreRoot->initialise(false);


    // Create a window
    int width = 1024;
    int height = 768;
    bool fullscreen = false;
    mRenderWindow = mOgreRoot->createRenderWindow("d-collide test application", width, height, fullscreen);
    if (!mUseGUI) {
        mRenderWindow->setVisible(false);
    }
    mWindowEventListener = new MyWindowEventListener(mRenderWindow);

    mOgreRoot->addResourceLocation("../resources/textures", "FileSystem", "DCollideMaterials");

    mOgreRoot->addResourceLocation("../resources/models", "FileSystem", "DCollideModels");

    // input
    int windowHandle = 0;
    mRenderWindow->getCustomAttribute("WINDOW", &windowHandle);
    mInputHandler = new InputHandler(windowHandle);
    mInputHandler->setTestApp(this);
    mInputHandler->setWindowSize(width, height);
    mWindowEventListener->setInputHandler(mInputHandler);

    // GUI
    mGui = new Gui(mOgreRoot, mRenderWindow);
    mGui->setInputHandler(mInputHandler);
    mGui->addFrameHistory(mFrameHistory, false);
    mGui->addFrameHistory(mGraphicFrameHistory, true);
    mGui->addFrameHistory(mSceneUpdateHistory, true);
    mGui->addFrameHistory(mPhysicsStepHistory, true);
    mGui->addFrameHistory(mCollisionFrameHistory, true);
    if (!mGui->initialize()) {
        std::cerr << "Could not initialize the GUI" << std::endl;
        return false;
    }

    // our actual scene
    changeCurrentScene("default");

    if (!mScene) {
        //error() << "NULL current scene: could not initialize default scene";
        return false;
    }

    mInputHandler->initActions();

    return true;
}