Ejemplo n.º 1
0
    //-----------------------------------------------------------------------
    void Root::saveConfig(void)
    {
        if (mConfigFileName.empty ())
            return;

		std::ofstream of(mConfigFileName.c_str());

        if (!of)
            OGRE_EXCEPT(Exception::ERR_CANNOT_WRITE_TO_FILE, "Cannot create settings file.",
            "Root::saveConfig");

        if (mActiveRenderer)
        {
            of << "Render System=" << mActiveRenderer->getName() << std::endl;
        }
        else
        {
            of << "Render System=" << std::endl;
        }

        for (RenderSystemList::const_iterator pRend = getAvailableRenderers()->begin(); pRend != getAvailableRenderers()->end(); ++pRend)
        {
            RenderSystem* rs = *pRend;
            of << std::endl;
            of << "[" << rs->getName() << "]" << std::endl;
            const ConfigOptionMap& opts = rs->getConfigOptions();
            for (ConfigOptionMap::const_iterator pOpt = opts.begin(); pOpt != opts.end(); ++pOpt)
            {
				of << pOpt->first << "=" << pOpt->second.currentValue << std::endl;
            }
        }

        of.close();

    }
Ejemplo n.º 2
0
int main(char argc, char** argv)
{


    // Try D3D
    try 
    {
        Root root("", "", "OgreCapsReportD3D9.log");
        StringStream str;
        str << "RenderSystem_Direct3D9" << OGRE_LIB_SUFFIX;
        root.loadPlugin(str.str());

        RenderSystem* rs = root.getAvailableRenderers()->at(0);
        ConfigOption& opt = 
            rs->getConfigOptions().find("Rendering Device")->second;
        opt.currentValue = opt.possibleValues[0];
        root.setRenderSystem(rs);
        root.initialise(false);
        root.createRenderWindow("probe", 100, 100, false);

    }
    catch(std::exception&)
    {
        // failed D3D9
        LogManager::getSingleton().logMessage("D3D9 testing failed - perhaps you "
            "don't have the D3D9 runtime installed on this machine?");
    }



    // Try GL
    try 
    {
        Root root("", "", "OgreCapsReportGL.log");
        StringStream str;
        str << "RenderSystem_GL" << OGRE_LIB_SUFFIX;
        root.loadPlugin(str.str());

        RenderSystem* rs = root.getAvailableRenderers()->at(0);
        root.setRenderSystem(rs);
        root.initialise(false);
        root.createRenderWindow("probe", 100, 100, false);
    }
    catch(std::exception&)
    {
        // failed GL
        LogManager::getSingleton().logMessage("GL testing failed - perhaps you "
            "don't have a GL driver installed on this machine?");
    }


}
void GLXConfigurator::SetRenderer(RenderSystem *r) {
	mRenderer = r;

	// Destroy each widget of GUI of previously selected renderer
	for(std::list<Widget>::iterator i=mRenderOptionWidgets.begin(); i!=mRenderOptionWidgets.end(); i++)
		XtDestroyWidget(*i);
	mRenderOptionWidgets.clear();
	mConfigCallbackData.back();

	// Create option GUI
	int cury = ystart + 1*rowh + 10;

	ConfigOptionMap options = mRenderer->getConfigOptions();
	// Process each option and create an optionmenu widget for it
	for (ConfigOptionMap::iterator it = options.begin();
					it != options.end(); it++) {
		// if the config option does not have any possible value, then skip it.
		// if we create a popup with zero entries, it will crash when you click
		// on it.
		if (it->second.possibleValues.empty())
			continue;

		Widget lb1 = XtVaCreateManagedWidget("topLabel", labelWidgetClass, box, XtNlabel, it->second.name.c_str(), XtNborderWidth, 0,
			XtNwidth, col1w, 	// Fixed width
			XtNheight, 18,
			XtNleft, XawChainLeft,
			XtNtop, XawChainTop,
			XtNright, XawChainLeft,
			XtNbottom, XawChainTop,
			XtNhorizDistance, col1x,
			XtNvertDistance, cury,
			XtNjustify, XtJustifyLeft,
			NULL);
		mRenderOptionWidgets.push_back(lb1);
		Widget mb1 = XtVaCreateManagedWidget("Menu", menuButtonWidgetClass, box, XtNlabel, it->second.currentValue.c_str(),
			XtNresize, false,
			XtNresizable, false,
			XtNwidth, col2w, 	// Fixed width
			XtNheight, 18,
			XtNleft, XawChainLeft,
			XtNtop, XawChainTop,
			XtNright, XawChainLeft,
			XtNbottom, XawChainTop,
			XtNhorizDistance, col2x,
			XtNvertDistance, cury,
			NULL);
		mRenderOptionWidgets.push_back(mb1);

		Widget menu = XtVaCreatePopupShell("menu", simpleMenuWidgetClass, mb1,
			0, NULL);

		// Process each choice
		StringVector::iterator opt_it;
		for (opt_it = it->second.possibleValues.begin();
		                opt_it != it->second.possibleValues.end(); opt_it++) {
			// Create callback data
			mConfigCallbackData.push_back(ConfigCallbackData(this, it->second.name, *opt_it, mb1));

			Widget entry = XtVaCreateManagedWidget("menuentry", smeBSBObjectClass, menu,
				XtNlabel, (*opt_it).c_str(),
				0, NULL);
			XtAddCallback(entry, XtNcallback, (XtCallbackProc)&GLXConfigurator::configOptionHandler, &mConfigCallbackData.back());
		}
		cury += rowh;
	}
}