1 // ----------------------------------------------------------------------------
2 // Include the main OGRE header files
3 // Ogre.h just expands to including lots of individual OGRE header files
4 // ----------------------------------------------------------------------------
5 #include <Ogre.h>
6 // ----------------------------------------------------------------------------
7 // Include the OGRE example framework
8 // This includes the classes defined to make getting an OGRE application running
9 // a lot easier. It automatically sets up all the main objects and allows you to
10 // just override the bits you want to instead of writing it all from scratch.
11 // ----------------------------------------------------------------------------
12 #include <ExampleApplication.h>
13 
14 // ----------------------------------------------------------------------------
15 // Define the application object
16 // This is derived from ExampleApplication which is the class OGRE provides to
17 // make it easier to set up OGRE without rewriting the same code all the time.
18 // You can override extra methods of ExampleApplication if you want to further
19 // specialise the setup routine, otherwise the only mandatory override is the
20 // 'createScene' method which is where you set up your own personal scene.
21 // ----------------------------------------------------------------------------
22 class SampleApp : public ExampleApplication
23 {
24 public:
25     // Basic constructor
SampleApp()26     SampleApp()
27     {}
28 
29 protected:
30 
31     // Just override the mandatory create scene method
createScene(void)32     void createScene(void)
33     {
34         // Create the SkyBox
35         mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox");
36 
37         // Create a light
38         Light* myLight = mSceneMgr->createLight("Light0");
39         myLight->setType(Light::LT_POINT);
40         myLight->setPosition(0, 40, 0);
41         myLight->setDiffuseColour(1, 1, 1);
42         myLight->setSpecularColour(1, 1, 1);
43     }
44 };
45 
46 
47 // ----------------------------------------------------------------------------
48 // Main function, just boots the application object
49 // ----------------------------------------------------------------------------
50 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
51 #define WIN32_LEAN_AND_MEAN
52 #include "windows.h"
WinMain(HINSTANCE hInst,HINSTANCE,LPSTR strCmdLine,INT)53 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
54 #else
55 int main(int argc, char **argv)
56 #endif
57 {
58     // Create application object
59     SampleApp app;
60 
61     try
62     {
63         app.go();
64     }
65     catch( Exception& e )
66     {
67 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
68         MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
69 #else
70 
71         std::cerr << "An exception has occured: " << e.getFullDescription();
72 #endif
73     }
74 
75     return 0;
76 }
77