source: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/main.cpp @ 699

Revision 699, 1.9 KB checked in by igarcia, 18 years ago (diff)
Line 
1#include <LBBC.h>
2#include <LBBCPrerequisites.h>
3
4struct CommandLineOptions
5{
6        Ogre::String cfg;
7};
8
9int findCommandLineOpts(int numargs, char** argv, Ogre::UnaryOptionList& unaryOptList,
10                                                Ogre::BinaryOptionList& binOptList)
11{
12    int startIndex = 1;
13    for (int i = 1; i < numargs; ++i)
14    {
15                Ogre::String tmp(argv[i]);
16                if (Ogre::StringUtil::startsWith(tmp, "-"))
17        {
18                        Ogre::UnaryOptionList::iterator ui = unaryOptList.find(argv[i]);
19            if(ui != unaryOptList.end())
20            {
21                ui->second = true;
22                ++startIndex;
23                continue;
24            }
25                        Ogre::BinaryOptionList::iterator bi = binOptList.find(argv[i]);
26            if(bi != binOptList.end())
27            {
28                bi->second = argv[i+1];
29                startIndex += 2;
30                ++i;
31                continue;
32            }
33
34            // Invalid option
35            cout<<"Invalid option "<<tmp<<endl;
36
37        }
38    }
39    return startIndex;
40}
41
42CommandLineOptions parseArgs(int numArgs, char **args)
43{
44    CommandLineOptions opts;
45
46        Ogre::UnaryOptionList unOpt;
47        Ogre::BinaryOptionList binOpt;
48
49    binOpt["-cfg"] = "";
50   
51        int startIndex = findCommandLineOpts(numArgs, args, unOpt, binOpt);
52        Ogre::UnaryOptionList::iterator ui;
53        Ogre::BinaryOptionList::iterator bi;
54       
55    bi = binOpt.find("-cfg");
56    if (!bi->second.empty())
57    {
58                opts.cfg = bi->second; 
59    }   
60
61    return opts;
62}
63
64void help()
65{
66        cout<<"Please specify the parameter: -cfg sample.cfg"<<endl;
67}
68
69int main(int numargs, char** args)
70{       
71        /*
72        if (numargs < 2)
73    {
74        help();
75        return -1;
76    }
77    */
78
79        CommandLineOptions opts = parseArgs(numargs, args);
80
81        LBBC::Manager* manager = new LBBC::Manager();
82        LBBC::Manager::getSingleton().initialize();     
83
84        manager->runSample(Ogre::String(opts.cfg));     
85
86        LBBC::Manager::getSingleton().shutdown();
87        delete manager;
88
89        return 0;
90}
91
Note: See TracBrowser for help on using the repository browser.