Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/Samples/Gui/src/Gui.cpp @ 5

Last change on this file since 5 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

File size: 19.6 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10You may use this sample code for anything you like, it is not covered by the
11LGPL like the rest of the engine.
12-----------------------------------------------------------------------------
13*/
14
15/**
16    \file
17        Gui.cpp
18    \brief
19        An example of CEGUI's features
20*/
21
22#include <CEGUI/CEGUIImageset.h>
23#include <CEGUI/CEGUISystem.h>
24#include <CEGUI/CEGUILogger.h>
25#include <CEGUI/CEGUISchemeManager.h>
26#include <CEGUI/CEGUIWindowManager.h>
27#include <CEGUI/CEGUIWindow.h>
28#include <CEGUI/CEGUIPropertyHelper.h>
29#include <CEGUI/elements/CEGUICombobox.h>
30#include <CEGUI/elements/CEGUIListbox.h>
31#include <CEGUI/elements/CEGUIListboxTextItem.h>
32#include <CEGUI/elements/CEGUIPushButton.h>
33#include <CEGUI/elements/CEGUIScrollbar.h>
34#include "OgreCEGUIRenderer.h"
35#include "OgreCEGUIResourceProvider.h"
36
37#include "ExampleApplication.h"
38
39//----------------------------------------------------------------//
40CEGUI::MouseButton convertOISMouseButtonToCegui(int buttonID)
41{
42    switch (buttonID)
43    {
44        case 0: return CEGUI::LeftButton;
45        case 1: return CEGUI::RightButton;
46        case 2: return CEGUI::MiddleButton;
47        case 3: return CEGUI::X1Button;
48        default: return CEGUI::LeftButton;
49    }
50}
51
52class GuiFrameListener : public ExampleFrameListener, public OIS::KeyListener, public OIS::MouseListener
53{
54private:
55    CEGUI::Renderer* mGUIRenderer;
56    bool mShutdownRequested;
57
58public:
59    // NB using buffered input, this is the only change
60    GuiFrameListener(RenderWindow* win, Camera* cam, CEGUI::Renderer* renderer)
61        : ExampleFrameListener(win, cam, true, true, true), 
62          mGUIRenderer(renderer),
63          mShutdownRequested(false)
64    {
65                mMouse->setEventCallback(this);
66                mKeyboard->setEventCallback(this);
67    }
68
69    /// Tell the frame listener to exit at the end of the next frame
70    void requestShutdown(void)
71    {
72        mShutdownRequested = true;
73    }
74
75    bool frameEnded(const FrameEvent& evt)
76    {
77        if (mShutdownRequested)
78            return false;
79        else
80            return ExampleFrameListener::frameEnded(evt);
81    }
82        //----------------------------------------------------------------//
83        bool mouseMoved( const OIS::MouseEvent &arg )
84        {
85                CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
86                return true;
87        }
88
89        //----------------------------------------------------------------//
90        bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
91        {
92                CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id));
93                return true;
94        }
95
96        //----------------------------------------------------------------//
97        bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
98        {
99                CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
100                return true;
101        }
102
103        //----------------------------------------------------------------//
104        bool keyPressed( const OIS::KeyEvent &arg )
105        {
106                if( arg.key == OIS::KC_ESCAPE )
107                        mShutdownRequested = true;
108                CEGUI::System::getSingleton().injectKeyDown( arg.key );
109                CEGUI::System::getSingleton().injectChar( arg.text );
110                return true;
111        }
112
113        //----------------------------------------------------------------//
114        bool keyReleased( const OIS::KeyEvent &arg )
115        {
116                CEGUI::System::getSingleton().injectKeyUp( arg.key );
117                return true;
118        }
119};
120
121class GuiApplication : public ExampleApplication
122{
123private:
124    CEGUI::OgreCEGUIRenderer* mGUIRenderer;
125    CEGUI::System* mGUISystem;
126    CEGUI::Window* mEditorGuiSheet;
127        CEGUI::Scrollbar* mRed;
128        CEGUI::Scrollbar* mGreen;
129        CEGUI::Scrollbar* mBlue;
130        CEGUI::Window* mPreview; // StaticImage
131        CEGUI::Window* mTip;
132        CEGUI::Listbox* mList;
133        CEGUI::Window* mEditBox;
134        typedef std::map<CEGUI::String, CEGUI::String> DescriptionMap;
135        DescriptionMap mDescriptionMap;
136
137public:
138    GuiApplication()
139      : mGUIRenderer(0),
140        mGUISystem(0),
141        mEditorGuiSheet(0)
142    {
143                mDescriptionMap[(CEGUI::utf8*)"Demo8"] = 
144                        (CEGUI::utf8*)"The main containing panel";
145                mDescriptionMap[(CEGUI::utf8*)"Demo8/Window1"] = 
146                        (CEGUI::utf8*)"A test window";
147                mDescriptionMap[(CEGUI::utf8*)"Demo8/Window1/Listbox"] = 
148                        (CEGUI::utf8*)"A list box";
149                mDescriptionMap[(CEGUI::utf8*)"Demo8/Window1/Controls/Red"] = 
150                        (CEGUI::utf8*)"A colour slider";
151                mDescriptionMap[(CEGUI::utf8*)"Demo8/Window1/Controls/Green"] = 
152                        (CEGUI::utf8*)"A colour slider";
153                mDescriptionMap[(CEGUI::utf8*)"Demo8/Window1/Controls/Blue"] = 
154                        (CEGUI::utf8*)"A colour slider";
155                mDescriptionMap[(CEGUI::utf8*)"Demo8/Window1/Controls/ColourSample"] = 
156                        (CEGUI::utf8*)"The colour that will be used for the selection when added to the list";
157                mDescriptionMap[(CEGUI::utf8*)"Demo8/Window1/Controls/Editbox"] = 
158                        (CEGUI::utf8*)"An edit box; this text will be added to the list";
159                mDescriptionMap[(CEGUI::utf8*)"Demo8/Window1/Controls/Add"] = 
160                        (CEGUI::utf8*)"Adds the text to the list";
161                mDescriptionMap[(CEGUI::utf8*)"Demo8/Window1/Controls/ins1"] = 
162                        (CEGUI::utf8*)"Some static text";
163
164
165        }
166
167    ~GuiApplication()
168    {
169        if(mEditorGuiSheet)
170        {
171            CEGUI::WindowManager::getSingleton().destroyWindow(mEditorGuiSheet);
172        }
173        if(mGUISystem)
174        {
175            delete mGUISystem;
176            mGUISystem = 0;
177        }
178        if(mGUIRenderer)
179        {
180            delete mGUIRenderer;
181            mGUIRenderer = 0;
182        }
183    }
184
185protected:
186    // Just override the mandatory create scene method
187    void createScene(void)
188    {
189        // Set ambient light
190        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
191
192        // Create a skydome
193        mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
194
195        // Create a light
196        Light* l = mSceneMgr->createLight("MainLight");
197        // Accept default settings: point light, white diffuse, just set position
198        // NB I could attach the light to a SceneNode if I wanted it to move automatically with
199        //  other objects, but I don't
200        l->setPosition(20,80,50);
201
202        // setup GUI system
203        mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, 
204            Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
205
206        mGUISystem = new CEGUI::System(mGUIRenderer);
207
208        CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
209
210        Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
211
212        SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
213        headNode->attachObject(ogreHead);
214
215
216        // Setup Render To Texture for preview window
217        RenderTexture* rttTex = mRoot->getRenderSystem()->createRenderTexture( "RttTex", 512, 512, TEX_TYPE_2D, PF_R8G8B8 );
218        {
219            Camera* rttCam = mSceneMgr->createCamera("RttCam");
220            SceneNode* camNode = 
221                mSceneMgr->getRootSceneNode()->createChildSceneNode("rttCamNode");
222            camNode->attachObject(rttCam);
223            rttCam->setPosition(0,0,200);
224            //rttCam->setVisible(true);
225
226            Viewport *v = rttTex->addViewport( rttCam );
227            v->setOverlaysEnabled(false);
228            v->setClearEveryFrame( true );
229            v->setBackgroundColour( ColourValue::Black );
230        }
231
232        // Retrieve CEGUI texture for the RTT
233        CEGUI::Texture* rttTexture = mGUIRenderer->createTexture((CEGUI::utf8*)"RttTex");
234
235        CEGUI::Imageset* rttImageSet = 
236            CEGUI::ImagesetManager::getSingleton().createImageset(
237                    (CEGUI::utf8*)"RttImageset", rttTexture);
238
239        rttImageSet->defineImage((CEGUI::utf8*)"RttImage", 
240                CEGUI::Point(0.0f, 0.0f),
241                CEGUI::Size(rttTexture->getWidth(), rttTexture->getHeight()),
242                CEGUI::Point(0.0f,0.0f));
243
244        // load scheme and set up defaults
245        CEGUI::SchemeManager::getSingleton().loadScheme(
246                (CEGUI::utf8*)"TaharezLookSkin.scheme");
247        mGUISystem->setDefaultMouseCursor(
248                (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
249        mGUISystem->setDefaultFont((CEGUI::utf8*)"BlueHighway-12");
250
251        CEGUI::Window* sheet = 
252            CEGUI::WindowManager::getSingleton().loadWindowLayout(
253                (CEGUI::utf8*)"ogregui.layout"); 
254        mGUISystem->setGUISheet(sheet);
255
256        CEGUI::Combobox* objectComboBox = (CEGUI::Combobox*)CEGUI::WindowManager::getSingleton().getWindow("OgreGuiDemo/TabCtrl/Page2/ObjectTypeList");
257
258        CEGUI::ListboxTextItem* item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"FrameWindow", 0);
259        objectComboBox->addItem(item);
260        item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"Horizontal Scrollbar", 1);
261        objectComboBox->addItem(item);
262        item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"Vertical Scrollbar", 2);
263        objectComboBox->addItem(item);
264        item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"StaticText", 3);
265        objectComboBox->addItem(item);
266        item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"StaticImage", 4);
267        objectComboBox->addItem(item);
268        item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"Render to Texture", 5);
269        objectComboBox->addItem(item);
270
271        setupEventHandlers();
272    }
273
274    // Create new frame listener
275    void createFrameListener(void)
276    {
277        mFrameListener= new GuiFrameListener(mWindow, mCamera, mGUIRenderer);
278        mRoot->addFrameListener(mFrameListener);
279    }
280
281    void setupEventHandlers(void)
282    {
283                CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
284        wmgr.getWindow((CEGUI::utf8*)"OgreGuiDemo/TabCtrl/Page1/QuitButton")
285                        ->subscribeEvent(
286                                CEGUI::PushButton::EventClicked, 
287                                CEGUI::Event::Subscriber(&GuiApplication::handleQuit, this));
288        wmgr.getWindow((CEGUI::utf8*)"OgreGuiDemo/TabCtrl/Page1/NewButton")
289                        ->subscribeEvent(
290                                CEGUI::PushButton::EventClicked, 
291                                CEGUI::Event::Subscriber(&GuiApplication::handleNew, this));
292        wmgr.getWindow((CEGUI::utf8*)"OgreGuiDemo/TabCtrl/Page1/LoadButton")
293                        ->subscribeEvent(
294                                CEGUI::PushButton::EventClicked, 
295                                CEGUI::Event::Subscriber(&GuiApplication::handleLoad, this));
296        wmgr.getWindow((CEGUI::utf8*)"OgreGuiDemo/TabCtrl/Page2/ObjectTypeList")
297                        ->subscribeEvent(
298                                CEGUI::Combobox::EventListSelectionAccepted, 
299                                CEGUI::Event::Subscriber(&GuiApplication::handleObjectSelection, this));
300
301    }
302
303        void setupEnterExitEvents(CEGUI::Window* win)
304        {
305                win->subscribeEvent(
306                        CEGUI::Window::EventMouseEnters, 
307                        CEGUI::Event::Subscriber(&GuiApplication::handleMouseEnters, this));
308                win->subscribeEvent(
309                        CEGUI::Window::EventMouseLeaves, 
310                        CEGUI::Event::Subscriber(&GuiApplication::handleMouseLeaves, this));
311                for (unsigned int i = 0; i < win->getChildCount(); ++i)
312                {
313                        CEGUI::Window* child = win->getChildAtIdx(i);
314                        setupEnterExitEvents(child);
315                }
316
317        }
318
319        void setupLoadedLayoutHandlers(void)
320        {
321                CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
322                mRed = static_cast<CEGUI::Scrollbar*>(
323                        wmgr.getWindow((CEGUI::utf8*)"Demo8/Window1/Controls/Red"));
324                mGreen = static_cast<CEGUI::Scrollbar*>(
325                        wmgr.getWindow((CEGUI::utf8*)"Demo8/Window1/Controls/Green"));
326                mBlue = static_cast<CEGUI::Scrollbar*>(
327                        wmgr.getWindow((CEGUI::utf8*)"Demo8/Window1/Controls/Blue"));
328                mPreview = wmgr.getWindow((CEGUI::utf8*)"Demo8/Window1/Controls/ColourSample");
329                mList = static_cast<CEGUI::Listbox*>(
330                        wmgr.getWindow((CEGUI::utf8*)"Demo8/Window1/Listbox"));
331                mEditBox = 
332                        wmgr.getWindow((CEGUI::utf8*)"Demo8/Window1/Controls/Editbox");
333                mTip = 
334                        wmgr.getWindow((CEGUI::utf8*)"Demo8/Window2/Tips");
335       
336                mRed->subscribeEvent(
337                                CEGUI::Scrollbar::EventScrollPositionChanged, 
338                                CEGUI::Event::Subscriber(&GuiApplication::handleColourChanged, this));
339                mGreen->subscribeEvent(
340                        CEGUI::Scrollbar::EventScrollPositionChanged, 
341                        CEGUI::Event::Subscriber(&GuiApplication::handleColourChanged, this));
342                mBlue->subscribeEvent(
343                        CEGUI::Scrollbar::EventScrollPositionChanged, 
344                        CEGUI::Event::Subscriber(&GuiApplication::handleColourChanged, this));
345
346                wmgr.getWindow((CEGUI::utf8*)"Demo8/Window1/Controls/Add")
347                        ->subscribeEvent(
348                        CEGUI::PushButton::EventClicked, 
349                        CEGUI::Event::Subscriber(&GuiApplication::handleAdd, this));
350
351                CEGUI::Window* root = wmgr.getWindow("Demo8");
352                setupEnterExitEvents(root);
353
354
355
356        }
357
358    CEGUI::Window* createRttGuiObject(void)
359    {
360        static unsigned int rttCounter = 0;
361                String guiObjectName = "NewRttImage" + StringConverter::toString(rttCounter);
362
363        CEGUI::Imageset* rttImageSet = 
364            CEGUI::ImagesetManager::getSingleton().getImageset(
365                (CEGUI::utf8*)"RttImageset");
366        CEGUI::Window* si = CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"TaharezLook/StaticImage", (CEGUI::utf8*)guiObjectName.c_str());
367        si->setSize(CEGUI::UVector2( CEGUI::UDim(0.5f, 0), CEGUI::UDim(0.4f, 0)));
368        si->setProperty("Image", CEGUI::PropertyHelper::imageToString(
369            &rttImageSet->getImage((CEGUI::utf8*)"RttImage")));
370
371        rttCounter++;
372
373        return si;
374    }
375
376    CEGUI::Window* createStaticImageObject(void)
377    {
378        static unsigned int siCounter = 0;
379        String guiObjectName = "NewStaticImage" + StringConverter::toString(siCounter);
380
381        CEGUI::Imageset* imageSet = 
382            CEGUI::ImagesetManager::getSingleton().getImageset(
383                (CEGUI::utf8*)"TaharezLook");
384
385        CEGUI::Window* si = CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"TaharezLook/StaticImage", (CEGUI::utf8*)guiObjectName.c_str());
386        si->setSize(CEGUI::UVector2( CEGUI::UDim(0.2f, 0), CEGUI::UDim(0.2f, 0)));
387        si->setProperty("Image", CEGUI::PropertyHelper::imageToString(
388            &imageSet->getImage((CEGUI::utf8*)"ClientBrush")));
389
390        siCounter++;
391
392        return si;
393    }
394
395    bool handleQuit(const CEGUI::EventArgs& e)
396    {
397        static_cast<GuiFrameListener*>(mFrameListener)->requestShutdown();
398        return true;
399    }
400
401    bool handleNew(const CEGUI::EventArgs& e)
402    {
403        if(mEditorGuiSheet)
404            CEGUI::WindowManager::getSingleton().destroyWindow(mEditorGuiSheet);
405
406        mEditorGuiSheet = CEGUI::WindowManager::getSingleton().createWindow("DefaultGUISheet", "NewLayout");
407
408        CEGUI::Window* editorWindow = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"OgreGuiDemo2/MainWindow");
409        editorWindow->addChildWindow(mEditorGuiSheet);
410
411        return true;
412    }
413
414    bool handleLoad(const CEGUI::EventArgs& e)
415    {
416        if(mEditorGuiSheet)
417            CEGUI::WindowManager::getSingleton().destroyWindow(mEditorGuiSheet);
418
419        mEditorGuiSheet = 
420            CEGUI::WindowManager::getSingleton().loadWindowLayout(
421                (CEGUI::utf8*)"cegui8.layout"); 
422                setupLoadedLayoutHandlers();
423
424        CEGUI::Window* editorWindow = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"OgreGuiDemo2/MainWindow");
425        editorWindow->addChildWindow(mEditorGuiSheet);
426
427        return true;
428    }
429
430
431    bool handleObjectSelection(const CEGUI::EventArgs& e)
432    {
433        static unsigned int windowNumber = 0;
434        static unsigned int vertScrollNumber = 0;
435        static unsigned int horizScrollNumber = 0;
436        static unsigned int textScrollNumber = 0;
437        String guiObjectName;
438        CEGUI::Window* window = 0;
439
440        // Set a random position to place this object.
441        Real posX = Math::RangeRandom(0.0, 0.7); 
442        Real posY = Math::RangeRandom(0.1, 0.7); 
443
444        const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(e);
445        CEGUI::ListboxItem* item = static_cast<CEGUI::Combobox*>(windowEventArgs.window)->getSelectedItem();
446
447        CEGUI::Window* editorWindow = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"OgreGuiDemo2/MainWindow");
448
449        switch(item->getID())
450        {
451        case 0:
452            guiObjectName = "NewWindow" + StringConverter::toString(windowNumber);
453            window = CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"TaharezLook/FrameWindow", (CEGUI::utf8*)guiObjectName.c_str());
454            window->setSize(CEGUI::UVector2(CEGUI::UDim(0.3f,0), CEGUI::UDim(0.3f,0)));
455            window->setText((CEGUI::utf8*)"New Window");
456            windowNumber++;
457            break;
458        case 1:
459            guiObjectName = "NewHorizScroll" + StringConverter::toString(horizScrollNumber);
460            window = CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"TaharezLook/HorizontalScrollbar", (CEGUI::utf8*)guiObjectName.c_str());
461            window->setSize(CEGUI::UVector2(CEGUI::UDim(0.75f,0), CEGUI::UDim(0.03f,0)));
462            horizScrollNumber++;
463            break;
464        case 2:
465            guiObjectName = "NewVertScroll" + StringConverter::toString(vertScrollNumber);
466            window = CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"TaharezLook/VerticalScrollbar", (CEGUI::utf8*)guiObjectName.c_str());
467            window->setSize(CEGUI::UVector2(CEGUI::UDim(0.03f,0), CEGUI::UDim(0.75f,0)));
468            vertScrollNumber++;
469            break;
470        case 3:
471            guiObjectName = "NewStaticText" + StringConverter::toString(textScrollNumber);
472            window = CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"TaharezLook/StaticText", (CEGUI::utf8*)guiObjectName.c_str());
473            window->setSize(CEGUI::UVector2(CEGUI::UDim(0.25f,0), CEGUI::UDim(0.1f,0)));
474            window->setText((CEGUI::utf8*)"Example static text");
475            textScrollNumber++;
476            break;
477        case 4:
478            window = createStaticImageObject();
479            break;
480        case 5:
481            window = createRttGuiObject();
482            break;
483        };
484
485        editorWindow->addChildWindow(window);
486        window->setPosition(CEGUI::UVector2(CEGUI::UDim(posX, 0), CEGUI::UDim(posY, 0)));
487
488        return true;
489    }
490
491        bool handleColourChanged(const CEGUI::EventArgs& e)
492        {
493        mPreview->setProperty("ImageColours",
494            CEGUI::PropertyHelper::colourToString(CEGUI::colour(
495                mRed->getScrollPosition() / 255.0f,
496                mGreen->getScrollPosition() / 255.0f,
497                mBlue->getScrollPosition() / 255.0f)));
498
499                return true;
500
501        }
502
503        bool handleAdd(const CEGUI::EventArgs& e)
504        {
505                CEGUI::ListboxTextItem *listboxitem = 
506                        new CEGUI::ListboxTextItem (mEditBox->getText());
507                listboxitem->setSelectionBrushImage("TaharezLook", "ListboxSelectionBrush");
508                listboxitem->setSelected(mList->getItemCount() == 0);
509                listboxitem->setSelectionColours(
510            CEGUI::PropertyHelper::stringToColourRect(mPreview->getProperty("ImageColours")));
511                mList->addItem(listboxitem);
512                return true;
513        }
514
515        bool handleMouseEnters(const CEGUI::EventArgs& e)
516        {
517                CEGUI::WindowEventArgs& we = ((CEGUI::WindowEventArgs&)e);
518                DescriptionMap::iterator i = 
519                        mDescriptionMap.find(we.window->getName());
520                if (i != mDescriptionMap.end())
521                {
522                        mTip->setText(i->second);
523                }
524                else
525                {
526                        mTip->setText((CEGUI::utf8*)"");
527                }
528               
529                return true;
530        }
531        bool handleMouseLeaves(const CEGUI::EventArgs& e)
532        {
533                mTip->setText((CEGUI::utf8*)"");
534                return true;
535        }
536
537};
538
539#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
540#define WIN32_LEAN_AND_MEAN
541#include "windows.h"
542
543INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
544#else
545int main(int argc, char *argv[])
546#endif
547{
548
549    // Create application object
550    GuiApplication app;
551
552    try {
553        app.go();
554    } catch( Ogre::Exception& e ) {
555#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
556        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
557#else
558        std::cerr << "An exception has occured: " <<
559            e.getFullDescription().c_str() << std::endl;
560#endif
561    }
562
563
564    return 0;
565}
566
Note: See TracBrowser for help on using the repository browser.