a question

Problems building or running the engine, queries about how to use features etc.
limbo
Kobold
Posts: 27
Joined: Fri Dec 10, 2004 7:08 am

a question

Post by limbo »

Can somebody explain how the following code works? I know it just makes an instance of the application and let it run. But what are the INT, WINAPI, HINSTANCE and etc kind of things? Where does ogre declare them? Or are they some key words of C++? Sorry if my question sounds silly, but I really want to know the answer. Thank you!!!!!!!!!

Code: Select all

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
{

     LightApplication app;

    try {
        app.go();
    } catch( Ogre::Exception& e ) {
        MessageBox( NULL, e.getFullDescription().c_str(), "error!", MB_OK | MB_ICONERROR | MB_TASKMODAL );
    }

    return 0;
}
User avatar
eugen
OGRE Expert User
OGRE Expert User
Posts: 1422
Joined: Sat May 22, 2004 5:28 am
Location: Bucharest
x 8

Post by eugen »

:) this is standard windows programming style...all those are defines having keywords behind or just keywords.
that is the main function a windows program will call when u will run the program.

Code: Select all

LightApplication app;
- this defines your ogre application

Code: Select all

try { 
        app.go(); 
    } catch( Ogre::Exception& e ) { 
        MessageBox( NULL, e.getFullDescription().c_str(), "error!", MB_OK | MB_ICONERROR | MB_TASKMODAL ); 
    } 
this is runnning your application, calling the go method...the try(){}catch() is just an exception handler (if an error is raised inside the ogre app, this handler will catch it)...here the application will popup a message box in case of an ogre error!
the your function returns, and the program ends!
User avatar
eugen
OGRE Expert User
OGRE Expert User
Posts: 1422
Joined: Sat May 22, 2004 5:28 am
Location: Bucharest
x 8

Post by eugen »

sorry...i should looked better...
those are defined internally by windows!! u shouldnt worry about them!
limbo
Kobold
Posts: 27
Joined: Fri Dec 10, 2004 7:08 am

Post by limbo »

Don't say sorry, your reply is very helpful! I'm not sure whether they are C++ keywords or not before reading your post :oops: