Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# OgreSDLConfig_cli.cpp

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright © 2000-2002 The OGRE Team
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023 -----------------------------------------------------------------------------
    00024 */
    00025
    00026
    00027 #include "OgreSDLConfig.h"
    00028 #include "OgreException.h"
    00029
    00030 using namespace Ogre;
    00031
    00032 bool SDLConfig::display(void)
    00033 {
    00034     std::cout << "OGRE Configuration" << std::endl << "------------------" <<  std::endl;
    00035
    00036     // Get the renderer
    00037     std::cout << "Select Renderer:" << std::endl;
    00038     int x = 1, choice = 0;
    00039     RenderSystemList* renderers = Root::getSingleton().getAvailableRenderers();
    00040     for (RenderSystemList::iterator pRend = renderers->begin();
    00041             pRend != renderers->end(); pRend++)
    00042     {
    00043         std::cout << "    " << x << ") " << (*pRend)->getName() << std::endl;;
    00044         x++;
    00045     }
    00046
    00047     std::cin >> choice;
    00048
    00049     if (choice<=0 || choice>=x) {
    00050         Except(Exception::ERR_INVALIDPARAMS,
    00051             "Invalid RenderSystem number",
    00052             "SDLConfig::display");
    00053     }
    00054     RenderSystem* renderer = (*renderers)[choice-1];
    00055
    00056     ConfigOptionMap options = renderer->getConfigOptions();
    00057
    00058     // Process each option
    00059     for (ConfigOptionMap::iterator it = options.begin();
    00060             it != options.end(); it++)
    00061     {
    00062         std::cout << it->second.name << ": " << std::endl;
    00063         x = 1;
    00064         StringVector::iterator opt_it;
    00065         for (opt_it = it->second.possibleValues.begin();
    00066                 opt_it != it->second.possibleValues.end(); opt_it++)
    00067         {
    00068             if ((*opt_it) == it->second.currentValue)
    00069                 std::cout << "--> ";
    00070             else
    00071                 std::cout << "    ";
    00072             std::cout << x << ") " << (*opt_it) << std::endl;
    00073             x++;
    00074         }
    00075
    00076         choice = 0;
    00077         std::cin >> choice;
    00078         if (choice<=0 || choice>=x) {
    00079             Except(Exception::ERR_INVALIDPARAMS,
    00080                 "Invalid number chosen for '"+it->second.name+"' option",
    00081                 "SDLConfig::display");
    00082         }
    00083         opt_it = it->second.possibleValues.begin();
    00084         renderer->setConfigOption(it->second.name, opt_it[choice-1]);
    00085     }
    00086
    00087     // All done
    00088     Root::getSingleton().setRenderSystem(renderer);
    00089     Root::getSingleton().saveConfig();
    00090
    00091     return true;
    00092 }

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:45 2004