MCPcopy Create free account
hub / github.com/OGRECave/ogre / main

Function main

Samples/Tutorials/Bootstrap.cpp:23–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21//! [key_handler]
22
23int main(int argc, char *argv[])
24{
25//! [constructor]
26 OgreBites::ApplicationContext ctx("OgreTutorialApp");
27 ctx.initApp();
28//! [constructor]
29
30//! [setup]
31 // get a pointer to the already created root
32 Ogre::Root* root = ctx.getRoot();
33 Ogre::SceneManager* scnMgr = root->createSceneManager();
34
35 // register our scene with the RTSS
36 Ogre::RTShader::ShaderGenerator* shadergen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
37 shadergen->addSceneManager(scnMgr);
38
39 // without light we would just get a black screen
40 Ogre::Light* light = scnMgr->createLight("MainLight");
41 Ogre::SceneNode* lightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
42 lightNode->setPosition(0, 10, 15);
43 lightNode->attachObject(light);
44
45 // also need to tell where we are
46 Ogre::SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();
47 camNode->setPosition(0, 0, 15);
48 camNode->lookAt(Ogre::Vector3(0, 0, -1), Ogre::Node::TS_PARENT);
49
50 // create the camera
51 Ogre::Camera* cam = scnMgr->createCamera("myCam");
52 cam->setNearClipDistance(5); // specific to this sample
53 cam->setAutoAspectRatio(true);
54 camNode->attachObject(cam);
55
56 // and tell it to render into the main window
57 ctx.getRenderWindow()->addViewport(cam);
58
59 // finally something to render
60 Ogre::Entity* ent = scnMgr->createEntity("Sinbad.mesh");
61 Ogre::SceneNode* node = scnMgr->getRootSceneNode()->createChildSceneNode();
62 node->attachObject(ent);
63//! [setup]
64
65//! [main]
66 // register for input events
67 KeyHandler keyHandler;
68 ctx.addInputListener(&keyHandler);
69
70 ctx.getRoot()->startRendering();
71 ctx.closeApp();
72//! [main]
73 return 0;
74}

Callers

nothing calls this directly

Calls 15

Vector3Class · 0.85
initAppMethod · 0.80
addSceneManagerMethod · 0.80
getRootSceneNodeMethod · 0.80
attachObjectMethod · 0.80
setNearClipDistanceMethod · 0.80
setAutoAspectRatioMethod · 0.80
addViewportMethod · 0.80
getRenderWindowMethod · 0.80
createEntityMethod · 0.80
startRenderingMethod · 0.80
closeAppMethod · 0.80

Tested by

no test coverage detected