Advertisement
lzedl

Irrlicht test

Nov 29th, 2012
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. int main()
  2. {
  3.     irr::IrrlichtDevice *device = irr::createDevice(irr::video::EDT_OPENGL, irr::core::dimension2d<irr::u32>(640, 480), 16, false, false, false, 0);
  4.     if (!device) return 1;
  5.  
  6.     device->setWindowCaption(L"Hello World!");
  7.     irr::video::IVideoDriver* driver = device->getVideoDriver();
  8.     irr::scene::ISceneManager* smgr = device->getSceneManager();
  9.     irr::gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
  10.     guienv->addStaticText(L"Hello World!", irr::core::rect<irr::s32>(10, 10, 260, 22), true);
  11.     irr::scene::IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
  12.     if (!mesh)
  13.     {
  14.         device->drop();
  15.         return 1;
  16.     }
  17.     irr::scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
  18.     irr::scene::IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh);
  19.     if (node)
  20.     {
  21.         node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
  22.         node->setMD2Animation(irr::scene::EMAT_RUN);
  23.         node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
  24.         node->setPosition(irr::core::vector3df(0, 0, 0));
  25.         node2->setMaterialFlag(irr::video::EMF_LIGHTING, false);
  26.         node2->setMD2Animation(irr::scene::EMAT_RUN);
  27.         node2->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
  28.         node2->setPosition(irr::core::vector3df(300, 0, 0));
  29.     }
  30.     smgr->addCameraSceneNode(0, irr::core::vector3df(0, 300, -300), irr::core::vector3df(0, 0, 0));
  31.     int i = 0;
  32.     while(device->run())
  33.     {
  34.         driver->beginScene(true, true, irr::video::SColor(255, 100, 101, 140));
  35.         smgr->getActiveCamera()->render();
  36.         node->OnAnimate(i);
  37.         node2->OnAnimate(i);
  38.         node->render();
  39.         node2->render();
  40.         driver->endScene();
  41.         i+=10;
  42.     }
  43.     device->drop();
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement