1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#include <Ogre.h>
class Application
{
public :
Application();
~Application();
void Start();
void Run();
void Exit();
public :
Ogre::Root* pRoot;
Ogre::SceneManager* pSceneManager;
Ogre::RenderWindow* pRenderWindow;
Ogre::Viewport* pViewport;
Ogre::Camera* pCamera;
};
Application::Application()
{
pRoot = 0;
pSceneManager = 0;
pRenderWindow = 0;
pViewport = 0;
pCamera = 0;
};
Application::~Application()
{
Exit();
}
void Application::Run()
{
pRoot->startRendering();
}
void Application::Start()
{
pRoot = new Ogre ::Root();
pRenderWindow = pRoot->initialise(true,"Ma premiere application Ogre");
pSceneManager = pRoot->createSceneManager(Ogre::ST_GENERIC, "MonGestionnaireDeScene");
pCamera = pSceneManager->createCamera("MaCamera");
pViewport = pRenderWindow->addViewport(pCamera);
}
void Application::Exit()
{
if (pRoot!=0) delete pRoot;
}
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
try {
Application MonApplication ;
MonApplication.Start ();
MonApplication.Run() ;
MonApplication.Exit();
} catch( Ogre::Exception &e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.what(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occurred: %s\n",
e.what());
#endif
}
return 0;
} |
Partager